Class: Primer::Beta::NavList::Heading

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/beta/nav_list/heading.rb

Overview

The heading placed above a ‘NavList`’s items.

See <%= link_to_component(Primer::Beta::NavList) %> for usage examples.

Direct Known Subclasses

Alpha::NavList::Heading

Constant Summary

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(title:, id: self.class.generate_id, heading_level: 2, **system_arguments) ⇒ Heading

Returns a new instance of Heading.

Parameters:

  • title (String)

    The text content of the heading.

  • id (String) (defaults to: self.class.generate_id)

    The value of the ID HTML attribute. Auto-generated by default.

  • heading_level (Integer) (defaults to: 2)

    The heading level, i.e. 2 for an ‘<h2>`, 3 for an `<h3>`, etc.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



16
17
18
19
20
21
# File 'app/components/primer/beta/nav_list/heading.rb', line 16

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

Instance Attribute Details

#heading_levelObject (readonly)

Returns the value of attribute heading_level.



10
11
12
# File 'app/components/primer/beta/nav_list/heading.rb', line 10

def heading_level
  @heading_level
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'app/components/primer/beta/nav_list/heading.rb', line 10

def id
  @id
end

#system_argumentsObject (readonly)

Returns the value of attribute system_arguments.



10
11
12
# File 'app/components/primer/beta/nav_list/heading.rb', line 10

def system_arguments
  @system_arguments
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'app/components/primer/beta/nav_list/heading.rb', line 10

def title
  @title
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
31
32
# File 'app/components/primer/beta/nav_list/heading.rb', line 23

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