Class: Shadcn::Menubar::Component

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

Overview

Port of registry/new-york-v4/ui/menubar.tsx — the bar itself.

Each menu inside it is a shadcn--dropdown-menu, as the context menu's submenus are: what this controller adds is the bar — one menu open at a time, arrows moving between the triggers, and a menu already open turning the rest into things you merely hover to reach.

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(loop: true, **attributes) ⇒ Component

Radix's loop defaults to true here (menubar.tsx:76), unlike the dropdown's, where it is false. A bar is a ring; a list is not.



22
23
24
25
# File 'app/components/shadcn/menubar/component.rb', line 22

def initialize(loop: true, **attributes)
  @loop = loop
  super(**attributes)
end

Instance Attribute Details

#loopObject (readonly)

Returns the value of attribute loop.



18
19
20
# File 'app/components/shadcn/menubar/component.rb', line 18

def loop
  @loop
end

Instance Method Details

#element_attributes(**defaults) ⇒ Object



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

def element_attributes(**defaults)
  super(**{
    role: "menubar",
    "data-controller" => "shadcn--menubar",
    "data-shadcn--menubar-loop-value" => loop
  }.merge(defaults))
end