Class: Primer::UnderlineNavComponent
- Includes:
- TabbedComponentHelper
- Defined in:
- app/components/primer/underline_nav_component.rb
Overview
Use ‘UnderlineNav` to style navigation with a minimal underlined selected state, typically used for navigation placed at the top of the page.
Constant Summary collapse
- ALIGN_DEFAULT =
:left- ALIGN_OPTIONS =
[ALIGN_DEFAULT, :right].freeze
- BODY_TAG_DEFAULT =
:div- BODY_TAG_OPTIONS =
[BODY_TAG_DEFAULT, :ul].freeze
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
-
#initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, wrapper_arguments: {}, **system_arguments) ⇒ UnderlineNavComponent
constructor
A new instance of UnderlineNavComponent.
Methods included from TabbedComponentHelper
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(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, wrapper_arguments: {}, **system_arguments) ⇒ UnderlineNavComponent
Returns a new instance of UnderlineNavComponent.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'app/components/primer/underline_nav_component.rb', line 139 def initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, wrapper_arguments: {}, **system_arguments) @with_panel = with_panel @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT) @wrapper_arguments = wrapper_arguments @system_arguments = system_arguments @system_arguments[:tag] = (with_panel) @system_arguments[:classes] = class_names( @system_arguments[:classes], "UnderlineNav", "UnderlineNav--right" => @align == :right ) @body_arguments = body_arguments @body_tag = fetch_or_fallback(BODY_TAG_OPTIONS, body_arguments[:tag]&.to_sym, BODY_TAG_DEFAULT) @body_arguments[:tag] = @body_tag @body_arguments[:classes] = class_names( "UnderlineNav-body", @body_arguments[:classes], "list-style-none" => list? ) if with_panel @body_arguments[:role] = :tablist @body_arguments[:"aria-label"] = label else @system_arguments[:"aria-label"] = label end end |