Class: Shadcn::DropdownMenu::Item::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/dropdown_menu/item/component.rb

Overview

DropdownMenuItem

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary collapse

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name

Constructor Details

#initialize(variant: :default, inset: false, disabled: false, **attributes) ⇒ Component

Returns a new instance of Component.



28
29
30
31
32
33
# File 'app/components/shadcn/dropdown_menu/item/component.rb', line 28

def initialize(variant: :default, inset: false, disabled: false, **attributes)
  @variant = variant&.to_sym || :default
  @inset = inset
  @disabled = disabled
  super(**attributes)
end

Instance Attribute Details

#disabledObject (readonly)

Returns the value of attribute disabled.



26
27
28
# File 'app/components/shadcn/dropdown_menu/item/component.rb', line 26

def disabled
  @disabled
end

#insetObject (readonly)

Returns the value of attribute inset.



26
27
28
# File 'app/components/shadcn/dropdown_menu/item/component.rb', line 26

def inset
  @inset
end

#variantObject (readonly)

Returns the value of attribute variant.



26
27
28
# File 'app/components/shadcn/dropdown_menu/item/component.rb', line 26

def variant
  @variant
end

Instance Method Details

#element_attributes(**defaults) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/components/shadcn/dropdown_menu/item/component.rb', line 35

def element_attributes(**defaults)
  super(**{
    role: "menuitem",
    tabindex: "-1",
    "data-variant" => variant,
    "data-inset" => (true if inset),
    "data-disabled" => (true if disabled),
    "data-shadcn--dropdown-menu-target" => "item",
    "data-action" => "click->shadcn--dropdown-menu#select " \
                     "pointerenter->shadcn--dropdown-menu#pointerenter"
  }.merge(defaults))
end