Class: Pulse::ActionList::Heading
- Defined in:
- app/components/pulse/action_list/heading.rb
Overview
Heading used to describe each sub list within an action list.
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
Constants included from Pulse::AttributesHelper
Pulse::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Pulse::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
generate_id, #merge_attributes, #merge_classes
Methods included from SvgHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean
Methods included from Pulse::AttributesHelper
#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Constructor Details
#initialize(title:, heading_level: 3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments) ⇒ Heading
Returns a new instance of Heading.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/pulse/action_list/heading.rb', line 24 def initialize(title:, heading_level: 3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments) unless HEADING_LEVELS.include?(heading_level) raise "Heading level must be between #{HEADING_MIN} and " \ "#{HEADING_MAX}" end @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.
17 18 19 |
# File 'app/components/pulse/action_list/heading.rb', line 17 def subtitle_id @subtitle_id end |
#title_id ⇒ Object (readonly)
Returns the value of attribute title_id.
17 18 19 |
# File 'app/components/pulse/action_list/heading.rb', line 17 def title_id @title_id end |
Instance Method Details
#subtitle? ⇒ Boolean
47 48 49 |
# File 'app/components/pulse/action_list/heading.rb', line 47 def subtitle? @subtitle.present? end |