Class: Primer::Alpha::ActionList::Heading
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Primer::Alpha::ActionList::Heading
- Defined in:
- app/components/primer/alpha/action_list/heading.rb
Overview
Heading used to describe each sub list within an action list.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_SCHEME =
:subtle
- SCHEME_MAPPINGS =
{ DEFAULT_SCHEME => nil, :filled => "ActionList-sectionDivider--filled" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys.freeze
- HEADING_MIN =
1
- HEADING_MAX =
6
- HEADING_LEVELS =
(HEADING_MIN..HEADING_MAX).to_a.freeze
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from Primer::AttributesHelper
Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Attribute Summary collapse
-
#subtitle_id ⇒ Object
readonly
Returns the value of attribute subtitle_id.
-
#title_id ⇒ Object
readonly
Returns the value of attribute title_id.
Instance Method Summary collapse
-
#initialize(title:, heading_level: 3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments) ⇒ Heading
constructor
A new instance of Heading.
- #subtitle? ⇒ Boolean
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from Primer::AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(title:, heading_level: 3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments) ⇒ Heading
Returns a new instance of Heading.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/primer/alpha/action_list/heading.rb', line 25 def initialize(title:, heading_level: 3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments) raise "Heading level must be between #{HEADING_MIN} and #{HEADING_MAX}" unless HEADING_LEVELS.include?(heading_level) @heading_level = heading_level @tag = :"h#{heading_level}" @system_arguments = deny_tag_argument(**system_arguments) @title = title @subtitle = subtitle @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME) @system_arguments[:classes] = class_names( "ActionList-sectionDivider", SCHEME_MAPPINGS[@scheme], @system_arguments[:classes] ) @title_id = self.class.generate_id(base_name: "heading-title") @subtitle_id = self.class.generate_id(base_name: "heading-subtitle") end |
Instance Attribute Details
#subtitle_id ⇒ Object (readonly)
Returns the value of attribute subtitle_id.
18 19 20 |
# File 'app/components/primer/alpha/action_list/heading.rb', line 18 def subtitle_id @subtitle_id end |
#title_id ⇒ Object (readonly)
Returns the value of attribute title_id.
18 19 20 |
# File 'app/components/primer/alpha/action_list/heading.rb', line 18 def title_id @title_id end |
Instance Method Details
#subtitle? ⇒ Boolean
44 45 46 |
# File 'app/components/primer/alpha/action_list/heading.rb', line 44 def subtitle? @subtitle.present? end |