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). tooltip: labels the button while an icon-collapsed rail hides its text (pure-CSS hover bubble). Attrs pass through via mix. See sidebar.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(as: :button, active: false, tooltip: nil, **attrs) ⇒ SidebarMenuButton

Returns a new instance of SidebarMenuButton.



9
10
11
12
13
14
# File 'app/components/phlex_kit/sidebar/sidebar_menu_button.rb', line 9

def initialize(as: :button, active: false, tooltip: nil, **attrs)
  @as = as
  @active = active
  @tooltip = tooltip
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



16
17
18
19
20
# File 'app/components/phlex_kit/sidebar/sidebar_menu_button.rb', line 16

def view_template(&block)
  base = { class: "pk-sidebar-menu-button", "data-active": (@active ? "true" : "false") }
  base["data-tooltip"] = @tooltip if @tooltip
  send(@as, **mix(base, @attrs), &block)
end