Class: Primer::TabNavComponent::TabComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Primer::TabNavComponent::TabComponent
- Defined in:
- app/components/primer/tab_nav_component.rb
Overview
Tabs to be rendered.
Constant Summary
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Attribute Summary collapse
-
#selected ⇒ Object
readonly
Returns the value of attribute selected.
Instance Method Summary collapse
- #call ⇒ Object
- #hidden? ⇒ Boolean
-
#initialize(title:, selected: false, **system_arguments) ⇒ TabComponent
constructor
A new instance of TabComponent.
- #panel ⇒ Object
Methods included from JoinStyleArgumentsHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Constructor Details
#initialize(title:, selected: false, **system_arguments) ⇒ TabComponent
Returns a new instance of TabComponent.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/components/primer/tab_nav_component.rb', line 74 def initialize(title:, selected: false, **system_arguments) @title = title @selected = selected @system_arguments = system_arguments @system_arguments[:tag] ||= :a @system_arguments[:role] = :tab if selected if @system_arguments[:tag] == :a @system_arguments[:"aria-current"] = :page else @system_arguments[:"aria-selected"] = true end end @system_arguments[:classes] = class_names( "tabnav-tab", system_arguments[:classes] ) end |
Instance Attribute Details
#selected ⇒ Object (readonly)
Returns the value of attribute selected.
72 73 74 |
# File 'app/components/primer/tab_nav_component.rb', line 72 def selected @selected end |
Instance Method Details
#call ⇒ Object
95 96 97 |
# File 'app/components/primer/tab_nav_component.rb', line 95 def call render(Primer::BaseComponent.new(**@system_arguments)) { @title } end |
#hidden? ⇒ Boolean
103 104 105 |
# File 'app/components/primer/tab_nav_component.rb', line 103 def hidden? !@selected end |
#panel ⇒ Object
99 100 101 |
# File 'app/components/primer/tab_nav_component.rb', line 99 def panel content end |