Class: Shadcn::Menubar::Trigger::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/menubar/trigger/component.rb

Overview

One name on the bar.

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

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

Constructor Details

This class inherits a constructor from Shadcn::ApplicationViewComponent

Instance Method Details

#element_attributes(**defaults) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/components/shadcn/menubar/trigger/component.rb', line 19

def element_attributes(**defaults)
  super(**{
    type: "button",
    role: "menuitem",
    "aria-haspopup" => "menu",
    "aria-expanded" => "false",
    "data-state" => "closed",
    "data-shadcn--dropdown-menu-target" => "trigger",
    "data-shadcn--menubar-target" => "trigger",
    # Two controllers listening to one element: the menu's, which opens
    # and closes it, and the bar's, which decides what the arrows do and
    # what a hover means while another menu is already open.
    "data-action" => "click->shadcn--dropdown-menu#toggle " \
                     "keydown->shadcn--dropdown-menu#triggerKeydown " \
                     "keydown->shadcn--menubar#keydown " \
                     "pointerenter->shadcn--menubar#pointerEnter " \
                     "focus->shadcn--menubar#focused"
  }.merge(defaults))
end