Class: ShadcnPhlexcomponents::Popover
- Inherits:
-
Base
- Object
- Phlex::HTML
- Base
- ShadcnPhlexcomponents::Popover
show all
- Defined in:
- lib/shadcn_phlexcomponents/components/popover.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) ⇒ Popover
Returns a new instance of Popover.
14
15
16
17
18
|
# File 'lib/shadcn_phlexcomponents/components/popover.rb', line 14
def initialize(open: false, **attributes)
@open = open
@aria_id = "popover-#{SecureRandom.hex(5)}"
super(**attributes)
end
|
Instance Method Details
#content(**attributes) ⇒ Object
24
25
26
|
# File 'lib/shadcn_phlexcomponents/components/popover.rb', line 24
def content(**attributes, &)
PopoverContent(aria_id: @aria_id, **attributes, &)
end
|
#default_attributes ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/shadcn_phlexcomponents/components/popover.rb', line 28
def default_attributes
{
data: {
controller: "popover",
popover_is_open_value: @open.to_s,
},
}
end
|
#trigger(**attributes) ⇒ Object
20
21
22
|
# File 'lib/shadcn_phlexcomponents/components/popover.rb', line 20
def trigger(**attributes, &)
PopoverTrigger(aria_id: @aria_id, **attributes, &)
end
|
#view_template ⇒ Object
37
38
39
|
# File 'lib/shadcn_phlexcomponents/components/popover.rb', line 37
def view_template(&)
div(**@attributes, &)
end
|