Class: PhlexKit::SidebarMenuButton

Inherits:
BaseComponent show all
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

Methods inherited from BaseComponent

#on

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