Class: Primer::Beta::Subhead
- Defined in:
- app/components/primer/beta/subhead.rb
Overview
Use ‘Subhead` as the start of a section. The `:heading` slot will render an `<h2>` font-sized text.
-
Optionally set the ‘:description` slot to render a short description and the `:actions` slot for a related action.
-
Use a succinct, one-line description for the ‘:description` slot. For longer descriptions, omit the description slot and render a paragraph below the `Subhead`.
-
Use the actions slot to render a related action to the right of the heading. Use <%= link_to_component(Primer::ButtonComponent) %> or <%= link_to_component(Primer::Beta::Link) %>.
Constant Summary collapse
- DEFAULT_HEADING_TAG =
:div
- HEADING_TAG_OPTIONS =
[DEFAULT_HEADING_TAG, :h1, :h2, :h3, :h4, :h5, :h6].freeze
- DEFAULT_HEADING_SIZE =
:large
- HEADING_SIZE_MAP =
{ DEFAULT_HEADING_SIZE => "Subhead-heading--large", :medium => "Subhead-heading--medium" }.freeze
- HEADING_SIZE_OPTIONS =
HEADING_SIZE_MAP.keys.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 AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
-
#initialize(spacious: false, hide_border: false, **system_arguments) ⇒ Subhead
constructor
A new instance of Subhead.
- #render? ⇒ 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 AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(spacious: false, hide_border: false, **system_arguments) ⇒ Subhead
Returns a new instance of Subhead.
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/components/primer/beta/subhead.rb', line 69 def initialize(spacious: false, hide_border: false, **system_arguments) @system_arguments = deny_tag_argument(**system_arguments) @system_arguments[:tag] = :div @system_arguments[:classes] = class_names( @system_arguments[:classes], "Subhead", "Subhead--spacious": spacious, "border-bottom-0": hide_border ) @system_arguments[:mb] ||= hide_border ? 0 : nil end |
Instance Method Details
#render? ⇒ Boolean
83 84 85 |
# File 'app/components/primer/beta/subhead.rb', line 83 def render? heading.present? end |