Class: Daisy::Navigation::MenuItemComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Navigation::MenuItemComponent
- Defined in:
- app/components/daisy/navigation/menu_component.rb
Overview
A menu item component that can optionally have a title and be disabled.
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
Adds the relevant Daisy classes and applies the disabled state if provided (utilizes Tailwind pointer-events-none).
-
#call ⇒ Object
Renders the menu item component including a title if present.
-
#initialize(*args, **kws) ⇒ MenuItemComponent
constructor
Create a new instance of the MenuItemComponent.
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) ⇒ MenuItemComponent
Create a new instance of the MenuItemComponent.
73 74 75 76 77 78 |
# File 'app/components/daisy/navigation/menu_component.rb', line 73 def initialize(*args, **kws) super(**kws) @simple_title = config_option(:title, args[0]) @disabled = config_option(:disabled) end |
Instance Method Details
#before_render ⇒ Object
Adds the relevant Daisy classes and applies the disabled state if provided (utilizes Tailwind pointer-events-none).
84 85 86 87 88 89 90 |
# File 'app/components/daisy/navigation/menu_component.rb', line 84 def before_render set_tag_name(:component, :li) add_css(:component, "menu-disabled pointer-events-none") if @disabled set_tag_name(:title, :h2) add_css(:title, "menu-title") end |
#call ⇒ Object
Renders the menu item component including a title if present.
95 96 97 98 99 100 |
# File 'app/components/daisy/navigation/menu_component.rb', line 95 def call part(:component) do concat(part(:title) { @simple_title }) if @simple_title concat(content) end end |