Class: Shadcn::DropdownMenu::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::DropdownMenu::Component
- Defined in:
- app/components/shadcn/dropdown_menu/component.rb
Overview
Port of registry/new-york-v4/ui/dropdown-menu.tsx
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#align_offset ⇒ Object
readonly
Returns the value of attribute align_offset.
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
-
#open ⇒ Object
readonly
Returns the value of attribute open.
-
#side ⇒ Object
readonly
Returns the value of attribute side.
-
#side_offset ⇒ Object
readonly
Returns the value of attribute side_offset.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(open: false, side: :bottom, align: :start, side_offset: 4, align_offset: 0, loop: false, **attributes) ⇒ Component
constructor
loopis Radix's own prop, declared on MenuContentImpl and documented@defaultValue false(vendor/radix/ui/menu.tsx:363-368).
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(open: false, side: :bottom, align: :start, side_offset: 4, align_offset: 0, loop: false, **attributes) ⇒ Component
loop is Radix's own prop, declared on MenuContentImpl and documented
@defaultValue false (vendor/radix/ui/menu.tsx:363-368). It rides here
rather than on Content for the same reason side and align do: one
Stimulus controller owns the whole family, and the root is where it is
attached.
19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 19 def initialize(open: false, side: :bottom, align: :start, side_offset: 4, align_offset: 0, loop: false, **attributes) @open = open @side = side&.to_sym || :bottom @align = align&.to_sym || :start @side_offset = side_offset @align_offset = align_offset @loop = loop super(**attributes) end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
12 13 14 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 12 def align @align end |
#align_offset ⇒ Object (readonly)
Returns the value of attribute align_offset.
12 13 14 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 12 def align_offset @align_offset end |
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
12 13 14 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 12 def loop @loop end |
#open ⇒ Object (readonly)
Returns the value of attribute open.
12 13 14 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 12 def open @open end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
12 13 14 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 12 def side @side end |
#side_offset ⇒ Object (readonly)
Returns the value of attribute side_offset.
12 13 14 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 12 def side_offset @side_offset end |
Instance Method Details
#call ⇒ Object
43 44 45 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 43 def call render_element(body: safe_join([ trigger, , content ].compact)) end |
#element_attributes(**defaults) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/shadcn/dropdown_menu/component.rb', line 30 def element_attributes(**defaults) super(**{ style: merged_style(CONTENTS_STYLE), "data-controller" => "shadcn--dropdown-menu", "data-shadcn--dropdown-menu-open-value" => open, "data-shadcn--dropdown-menu-side-value" => side, "data-shadcn--dropdown-menu-align-value" => align, "data-shadcn--dropdown-menu-side-offset-value" => side_offset, "data-shadcn--dropdown-menu-align-offset-value" => align_offset, "data-shadcn--dropdown-menu-loop-value" => loop }.merge(defaults)) end |