Sha256: 2626e6d84fa8f9cfe83461ce69c3c831ad7c5a1887cf57564ed3045ebad09f05

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Primer
  module Alpha
    class NavList
      # The heading placed above a `NavList`'s items.
      #
      # See <%= link_to_component(Primer::Alpha::NavList) %> for usage examples.
      class Heading < Primer::Component
        attr_reader :title, :id, :heading_level, :system_arguments

        # @param title [String] The text content of the heading.
        # @param id [String] The value of the ID HTML attribute. Auto-generated by default.
        # @param heading_level [Integer] The heading level, i.e. 2 for an `<h2>`, 3 for an `<h3>`, etc.
        # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
        def initialize(title:, id: self.class.generate_id, heading_level: 2, **system_arguments)
          @title = title
          @id = id
          @heading_level = heading_level
          @system_arguments = system_arguments
        end

        def call
          render(
            Primer::BaseComponent.new(
              tag: :"h#{heading_level}",
              id: id,
              classes: "ActionListHeader",
              **system_arguments
            ).with_content(title)
          )
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.11.0 app/components/primer/alpha/nav_list/heading.rb
openproject-primer_view_components-0.10.0 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.9.0 app/components/primer/alpha/nav_list/heading.rb
openproject-primer_view_components-0.9.1 app/components/primer/alpha/nav_list/heading.rb
openproject-primer_view_components-0.9.0 app/components/primer/alpha/nav_list/heading.rb
openproject-primer_view_components-0.8.0 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.8.0 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.7.0 app/components/primer/alpha/nav_list/heading.rb
openproject-primer_view_components-0.7.0 app/components/primer/alpha/nav_list/heading.rb
openproject-primer_view_components-0.6.3 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.6.0 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.5.1 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.5.0 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.4.0 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.3.1 app/components/primer/alpha/nav_list/heading.rb
primer_view_components-0.3.0 app/components/primer/alpha/nav_list/heading.rb