Class: ShadcnPhlexcomponents::Tooltip

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/tooltip.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) ⇒ Tooltip

Returns a new instance of Tooltip.



14
15
16
17
18
# File 'lib/shadcn_phlexcomponents/components/tooltip.rb', line 14

def initialize(open: false, **attributes)
  @open = open
  @aria_id = "tooltip-#{SecureRandom.hex(5)}"
  super(**attributes)
end

Instance Method Details

#content(**attributes) ⇒ Object



24
25
26
# File 'lib/shadcn_phlexcomponents/components/tooltip.rb', line 24

def content(**attributes, &)
  TooltipContent(aria_id: @aria_id, **attributes, &)
end

#default_attributes ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/shadcn_phlexcomponents/components/tooltip.rb', line 28

def default_attributes
  {
    data: {
      controller: "tooltip",
      tooltip_is_open_value: @open.to_s,
    },
  }
end

#trigger(**attributes) ⇒ Object



20
21
22
# File 'lib/shadcn_phlexcomponents/components/tooltip.rb', line 20

def trigger(**attributes, &)
  TooltipTrigger(aria_id: @aria_id, **attributes, &)
end

#view_template ⇒ Object



37
38
39
# File 'lib/shadcn_phlexcomponents/components/tooltip.rb', line 37

def view_template(&)
  div(**@attributes, &)
end