Class: ShadcnPhlexcomponents::DropdownMenu
- Inherits:
-
Base
- Object
- Phlex::HTML
- Base
- ShadcnPhlexcomponents::DropdownMenu
show all
- Defined in:
- lib/shadcn_phlexcomponents/components/dropdown_menu.rb
Constant Summary
Constants inherited
from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary
collapse
Methods inherited from Base
#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child
Constructor Details
#initialize(open: false, **attributes) ⇒ DropdownMenu
Returns a new instance of DropdownMenu.
14
15
16
17
18
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 14
def initialize(open: false, **attributes)
@aria_id = "dropdown-menu-#{SecureRandom.hex(5)}"
@open = open
super(**attributes)
end
|
Instance Method Details
#content(**attributes) ⇒ Object
24
25
26
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 24
def content(**attributes, &)
DropdownMenuContent(aria_id: @aria_id, side: @side, **attributes, &)
end
|
#default_attributes ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 52
def default_attributes
{
data: {
controller: "dropdown-menu",
dropdown_menu_is_open_value: @open.to_s,
},
}
end
|
#group(**attributes) ⇒ Object
48
49
50
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 48
def group(**attributes, &)
DropdownMenuGroup(**attributes, &)
end
|
#item(**attributes) ⇒ Object
32
33
34
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 32
def item(**attributes, &)
DropdownMenuItem(**attributes, &)
end
|
#item_to(name = nil, options = nil, html_options = nil) ⇒ Object
36
37
38
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 36
def item_to(name = nil, options = nil, html_options = nil, &)
DropdownMenuItemTo(name, options, html_options, &)
end
|
#label(**attributes) ⇒ Object
28
29
30
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 28
def label(**attributes, &)
DropdownMenuLabel(**attributes, &)
end
|
#separator(**attributes) ⇒ Object
40
41
42
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 40
def separator(**attributes, &)
DropdownMenuSeparator(**attributes, &)
end
|
#sub(**attributes) ⇒ Object
44
45
46
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 44
def sub(**attributes, &)
DropdownMenuSub(aria_id: "#{@aria_id}-sub-#{SecureRandom.hex(5)}", **attributes, &)
end
|
#trigger(**attributes) ⇒ Object
20
21
22
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 20
def trigger(**attributes, &)
DropdownMenuTrigger(aria_id: @aria_id, **attributes, &)
end
|
#view_template ⇒ Object
61
62
63
|
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 61
def view_template(&)
div(**@attributes, &)
end
|