Class: Daisy::Navigation::DockSectionComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Navigation::DockSectionComponent
- Defined in:
- app/components/daisy/navigation/dock_component.rb
Overview
A section within a Dock component.
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
-
#before_render ⇒ Object
Configure the component before rendering.
-
#call ⇒ String
Render the dock section component with icon, title, and content.
-
#initialize(**kws) ⇒ DockSectionComponent
constructor
Creates a new dock section.
Methods included from LocoMotion::Concerns::IconableComponent
#has_icons?, #left_icon_html, #render_left_icon, #render_right_icon, #right_icon_html
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(**kws) ⇒ DockSectionComponent
Creates a new dock section.
74 75 76 77 78 79 80 |
# File 'app/components/daisy/navigation/dock_component.rb', line 74 def initialize(**kws) super(**kws) @icon_variant = config_option(:icon_variant, :outline) @title = config_option(:title) @active = config_option(:active, false) end |
Instance Method Details
#before_render ⇒ Object
Configure the component before rendering.
Adds the dock-active class if this section is active and configures the title with appropriate styling.
86 87 88 89 90 91 92 93 94 |
# File 'app/components/daisy/navigation/dock_component.rb', line 86 def before_render super set_tag_name(:component, "button") unless @href add_css(:component, "dock-active") if @active set_tag_name(:title, :span) add_css(:title, "dock-label") end |
#call ⇒ String
Render the dock section component with icon, title, and content.
99 100 101 102 103 104 105 |
# File 'app/components/daisy/navigation/dock_component.rb', line 99 def call part(:component) do concat(render_icon) concat(part(:title) { @title }) if @title concat(content) end end |