Class: Shadcn::MenubarItemComponent

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

Overview

Menubar Item component Individual menu item within menubar content

Constant Summary collapse

BASE_CLASSES =
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
VARIANTS =
{
  default: "",
  destructive: "text-destructive focus:bg-destructive focus:text-destructive-foreground"
}.freeze

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(href: nil, variant: :default, disabled: false, inset: false, **options, &block) ⇒ MenubarItemComponent

Returns a new instance of MenubarItemComponent.

Parameters:

  • href (String, nil) (defaults to: nil)

    Link URL

  • variant (Symbol) (defaults to: :default)

    Item variant (:default, :destructive)

  • disabled (Boolean) (defaults to: false)

    Whether item is disabled

  • inset (Boolean) (defaults to: false)

    Whether to add left padding for icons



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

def initialize(href: nil, variant: :default, disabled: false, inset: false, **options, &block)
  super(**options, &block)
  @href = href
  @variant = variant.to_sym
  @disabled = disabled
  @inset = inset
end

Instance Method Details

#callObject



30
31
32
33
# File 'app/components/shadcn/menubar_item_component.rb', line 30

def call
  tag_name = @href ? :a : :div
  (tag_name, item_content, item_attributes)
end