Class: Primer::HeadingComponent
- Defined in:
- app/components/primer/heading_component.rb
Overview
‘Heading` should be used to communicate page organization and hierarchy.
-
Set tag to one of ‘:h1`, `:h2`, `:h3`, `:h4`, `:h5`, `:h6` based on what is appropriate for the page context.
-
Use ‘Heading` as the title of a section or sub section.
-
Do not use ‘Heading` for styling alone. For simply styling text, consider using <%= link_to_component(Primer::Beta::Text) %> with relevant <%= link_to_typography_docs %> such as `font_size` and `font_weight`.
-
Do not jump heading levels. For instance, do not follow a ‘<h1>` with an `<h3>`. Heading levels should increase by one in ascending order.
Constant Summary collapse
- TAG_FALLBACK =
:h2- TAG_OPTIONS =
[:h1, TAG_FALLBACK, :h3, :h4, :h5, :h6].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
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag:, **system_arguments) ⇒ HeadingComponent
constructor
A new instance of HeadingComponent.
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
Constructor Details
#initialize(tag:, **system_arguments) ⇒ HeadingComponent
Returns a new instance of HeadingComponent.
35 36 37 38 |
# File 'app/components/primer/heading_component.rb', line 35 def initialize(tag:, **system_arguments) @system_arguments = system_arguments @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_FALLBACK) end |
Instance Method Details
#call ⇒ Object
40 41 42 |
# File 'app/components/primer/heading_component.rb', line 40 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |