Class: PhlexKit::SidebarMenuSubButton
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::SidebarMenuSubButton
- Defined in:
- app/components/phlex_kit/sidebar/sidebar_menu_sub_button.rb
Overview
The interactive element of a SidebarMenuSubItem, ported from shadcn/ui's
SidebarMenuSubButton. as: is :a (their default — pass href:) or :button;
active: true highlights with the accent role (shadcn subs use accent, not
primary). Kwarg rather than attr for the same mix-merge reason as
SidebarMenuButton. See sidebar.rb.
Instance Method Summary collapse
-
#initialize(as: :a, active: false, **attrs) ⇒ SidebarMenuSubButton
constructor
A new instance of SidebarMenuSubButton.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(as: :a, active: false, **attrs) ⇒ SidebarMenuSubButton
Returns a new instance of SidebarMenuSubButton.
8 9 10 11 12 |
# File 'app/components/phlex_kit/sidebar/sidebar_menu_sub_button.rb', line 8 def initialize(as: :a, active: false, **attrs) @as = as @active = active @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
14 15 16 |
# File 'app/components/phlex_kit/sidebar/sidebar_menu_sub_button.rb', line 14 def view_template(&block) send(@as, **mix({ class: "pk-sidebar-menu-sub-button", "data-active": (@active ? "true" : "false") }, @attrs), &block) end |