Class: Daisy::Actions::DropdownComponent::ItemComponent
- Inherits:
-
LocoMotion::BasicComponent
- Object
- LocoMotion::BaseComponent
- LocoMotion::BasicComponent
- Daisy::Actions::DropdownComponent::ItemComponent
- Defined in:
- app/components/daisy/actions/dropdown_component.rb
Overview
A single dropdown menu item (<li class="menu-item">). Pass a block for
fully custom content (the original behavior), or use the structured
options/slots to build a selectable row: a leading slot, a label, a
trailing slot, and an active (selected) state.
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(label: nil, href: nil, selected: false, **kws) ⇒ ItemComponent
constructor
A new instance of ItemComponent.
Methods inherited from LocoMotion::BasicComponent
Constructor Details
#initialize(label: nil, href: nil, selected: false, **kws) ⇒ ItemComponent
Returns a new instance of ItemComponent.
98 99 100 101 102 103 104 |
# File 'app/components/daisy/actions/dropdown_component.rb', line 98 def initialize(label: nil, href: nil, selected: false, **kws) @label = label @href = href @selected = selected super(**kws) end |
Instance Method Details
#before_render ⇒ Object
106 107 108 109 110 111 |
# File 'app/components/daisy/actions/dropdown_component.rb', line 106 def before_render set_tag_name(:component, :li) add_css(:component, "menu-item") super end |
#call ⇒ Object
113 114 115 116 117 |
# File 'app/components/daisy/actions/dropdown_component.rb', line 113 def call part(:component) do structured? ? render_row : content end end |