Class: PhlexKit::SidebarMenuButton
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::SidebarMenuButton
- Defined in:
- app/components/phlex_kit/sidebar/sidebar_menu_button.rb
Overview
The interactive element of a SidebarMenuItem. as: is :button (default) or :a
(pass href:); active: true marks the current page (drives the highlight via
data-active — a named kwarg, not an attr, since mix would merge a repeated
attribute rather than override). Attrs pass through via mix. See sidebar.rb.
Instance Method Summary collapse
-
#initialize(as: :button, active: false, **attrs) ⇒ SidebarMenuButton
constructor
A new instance of SidebarMenuButton.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(as: :button, active: false, **attrs) ⇒ SidebarMenuButton
Returns a new instance of SidebarMenuButton.
7 8 9 10 11 |
# File 'app/components/phlex_kit/sidebar/sidebar_menu_button.rb', line 7 def initialize(as: :button, active: false, **attrs) @as = as @active = active @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
13 14 15 |
# File 'app/components/phlex_kit/sidebar/sidebar_menu_button.rb', line 13 def view_template(&block) send(@as, **mix({ class: "pk-sidebar-menu-button", "data-active": (@active ? "true" : "false") }, @attrs), &block) end |