Class: Shadcn::SidebarMenuSubButtonComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/sidebar_menu_sub_button_component.rb

Overview

SidebarMenuSubButton component - button within submenu item

Constant Summary collapse

SIZES =
{
  sm: "text-xs",
  md: "text-sm"
}.freeze
BASE_CLASSES =
"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground"
ACTIVE_CLASSES =
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(size: :md, is_active: false, href: nil, **options) ⇒ SidebarMenuSubButtonComponent

Returns a new instance of SidebarMenuSubButtonComponent.



14
15
16
17
18
19
# File 'app/components/shadcn/sidebar_menu_sub_button_component.rb', line 14

def initialize(size: :md, is_active: false, href: nil, **options)
  super(**options)
  @size = size.to_sym
  @is_active = is_active
  @href = href
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
# File 'app/components/shadcn/sidebar_menu_sub_button_component.rb', line 21

def call
  if @href
    (:a, content, button_attributes.merge(href: @href))
  else
    (:button, content, button_attributes.merge(type: "button"))
  end
end