Class: RubyUI::SidebarMenuButton

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/sidebar/sidebar_menu_button.rb

Constant Summary collapse

VARIANT_CLASSES =
{
  default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
  outline:
    "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
}.freeze
SIZE_CLASSES =
{
  default: "h-8 text-sm",
  sm: "h-7 text-xs",
  lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0"
}.freeze

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Constructor Details

#initialize(as: :button, variant: :default, size: :default, active: false, **attrs) ⇒ SidebarMenuButton

Returns a new instance of SidebarMenuButton.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_ui/sidebar/sidebar_menu_button.rb', line 17

def initialize(as: :button, variant: :default, size: :default, active: false, **attrs)
  raise ArgumentError, "Invalid variant: #{variant}" unless VARIANT_CLASSES.key?(variant)
  raise ArgumentError, "Invalid size: #{size}" unless SIZE_CLASSES.key?(size)

  @as = as
  @variant = variant
  @size = size
  @active = active
  super(**attrs)
end

Instance Method Details

#view_templateObject



28
29
30
# File 'lib/ruby_ui/sidebar/sidebar_menu_button.rb', line 28

def view_template(&)
  tag(@as, **attrs, &)
end