Class: Daisy::Navigation::TabsComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Navigation::TabsComponent
- Defined in:
- app/components/daisy/navigation/tabs_component.rb
Overview
When using radio button tabs, the titles must be simple strings and cannot contain HTML elements or icons.
Creates a tabbed navigation component that can be used either as links or radio buttons with associated content.
Defined Under Namespace
Classes: TabComponent
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#radio ⇒ Object
readonly
Returns the value of attribute radio.
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
- #before_render ⇒ Object
-
#initialize(*args, **kws, &block) ⇒ TabsComponent
constructor
Create a new instance of the TabsComponent.
- #radio? ⇒ Boolean
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Constructor Details
#initialize(*args, **kws, &block) ⇒ TabsComponent
Create a new instance of the TabsComponent.
204 205 206 207 208 209 |
# File 'app/components/daisy/navigation/tabs_component.rb', line 204 def initialize(*args, **kws, &block) super @name = config_option(:name, "tabs-#{SecureRandom.uuid}") @radio = config_option(:radio, false) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
184 185 186 |
# File 'app/components/daisy/navigation/tabs_component.rb', line 184 def name @name end |
#radio ⇒ Object (readonly)
Returns the value of attribute radio.
184 185 186 |
# File 'app/components/daisy/navigation/tabs_component.rb', line 184 def radio @radio end |
Instance Method Details
#before_render ⇒ Object
211 212 213 214 |
# File 'app/components/daisy/navigation/tabs_component.rb', line 211 def before_render add_css(:component, "tabs") add_html(:component, { role: "tablist" }) end |
#radio? ⇒ Boolean
216 217 218 |
# File 'app/components/daisy/navigation/tabs_component.rb', line 216 def radio? radio end |