Class: Shadcn::ContextMenu::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::ContextMenu::Component
- Defined in:
- app/components/shadcn/context_menu/component.rb
Overview
Port of registry/new-york-v4/ui/context-menu.tsx.
Driven by shadcn--dropdown-menu, not a controller of its own: the two
families declare the same slots and the menu's whole behaviour once open
— roving focus, typeahead, submenus, checkbox and radio items — is the
dropdown's. What differs is the way in, which is one action and one value.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(loop: false, **attributes) ⇒ Component
constructor
loop:is the dropdown's own addition, kept here because both share the controller — Radix has it as a prop and shadcn passes it in neither file.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(loop: false, **attributes) ⇒ Component
loop: is the dropdown's own addition, kept here because both share the
controller — Radix has it as a prop and shadcn passes it in neither file.
21 22 23 24 |
# File 'app/components/shadcn/context_menu/component.rb', line 21 def initialize(loop: false, **attributes) @loop = loop super(**attributes) end |
Instance Attribute Details
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
17 18 19 |
# File 'app/components/shadcn/context_menu/component.rb', line 17 def loop @loop end |
Instance Method Details
#call ⇒ Object
40 41 42 |
# File 'app/components/shadcn/context_menu/component.rb', line 40 def call render_element(body: safe_join([ trigger, , content ].compact)) end |
#element_attributes(**defaults) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/components/shadcn/context_menu/component.rb', line 26 def element_attributes(**defaults) super(**{ style: merged_style(CONTENTS_STYLE), "data-controller" => "shadcn--dropdown-menu", "data-shadcn--dropdown-menu-prefix-value" => "context-menu", "data-shadcn--dropdown-menu-loop-value" => loop, # A context menu opens where the pointer is, so it has no side to # prefer and no gap to leave: the point *is* the corner. "data-shadcn--dropdown-menu-side-value" => "bottom", "data-shadcn--dropdown-menu-align-value" => "start", "data-shadcn--dropdown-menu-side-offset-value" => 0 }.merge(defaults)) end |