Class: Shadcn::DropdownMenu::SubTrigger::Component

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

Overview

DropdownMenuSubTrigger — a menu item that opens the nested menu.

Direct Known Subclasses

Menubar::SubTrigger::Component

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

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

Constructor Details

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

Returns a new instance of Component.



23
24
25
26
27
# File 'app/components/shadcn/dropdown_menu/sub_trigger/component.rb', line 23

def initialize(inset: false, disabled: false, **attributes)
  @inset = inset
  @disabled = disabled
  super(**attributes)
end

Instance Attribute Details

#disabledObject (readonly)

Returns the value of attribute disabled.



21
22
23
# File 'app/components/shadcn/dropdown_menu/sub_trigger/component.rb', line 21

def disabled
  @disabled
end

#insetObject (readonly)

Returns the value of attribute inset.



21
22
23
# File 'app/components/shadcn/dropdown_menu/sub_trigger/component.rb', line 21

def inset
  @inset
end

Instance Method Details

#callObject



46
47
48
# File 'app/components/shadcn/dropdown_menu/sub_trigger/component.rb', line 46

def call
  render_element(body: safe_join([ content, chevron ]))
end

#element_attributes(**defaults) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/shadcn/dropdown_menu/sub_trigger/component.rb', line 29

def element_attributes(**defaults)
  super(**{
    role: "menuitem",
    tabindex: "-1",
    "aria-haspopup" => "menu",
    "aria-expanded" => "false",
    "data-state" => "closed",
    "data-inset" => (true if inset),
    "data-disabled" => (true if disabled),
    "data-shadcn--dropdown-menu-target" => "trigger",
    "data-action" => "click->shadcn--dropdown-menu#toggle " \
                     "keydown->shadcn--dropdown-menu#triggerKeydown " \
                     "pointerenter->shadcn--dropdown-menu#open " \
                     "pointerleave->shadcn--dropdown-menu#closeLater"
  }.merge(defaults))
end