Class: Shadcn::Tooltip::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Tooltip::Component
- Defined in:
- app/components/shadcn/tooltip/component.rb
Overview
Port of registry/new-york-v4/ui/tooltip.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.
-
#delay_duration ⇒ Object
readonly
Returns the value of attribute delay_duration.
-
#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(side: :top, align: :center, side_offset: 0, delay_duration: 0, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(side: :top, align: :center, side_offset: 0, delay_duration: 0, **attributes) ⇒ Component
Returns a new instance of Component.
14 15 16 17 18 19 20 |
# File 'app/components/shadcn/tooltip/component.rb', line 14 def initialize(side: :top, align: :center, side_offset: 0, delay_duration: 0, **attributes) @side = side&.to_sym || :top @align = align&.to_sym || :center @side_offset = side_offset @delay_duration = delay_duration super(**attributes) end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
12 13 14 |
# File 'app/components/shadcn/tooltip/component.rb', line 12 def align @align end |
#delay_duration ⇒ Object (readonly)
Returns the value of attribute delay_duration.
12 13 14 |
# File 'app/components/shadcn/tooltip/component.rb', line 12 def delay_duration @delay_duration end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
12 13 14 |
# File 'app/components/shadcn/tooltip/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/tooltip/component.rb', line 12 def side_offset @side_offset end |
Instance Method Details
#call ⇒ Object
33 34 35 |
# File 'app/components/shadcn/tooltip/component.rb', line 33 def call render_element(body: safe_join([ trigger, tooltip_content, content ].compact)) end |
#element_attributes(**defaults) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/shadcn/tooltip/component.rb', line 22 def element_attributes(**defaults) super(**{ style: merged_style(CONTENTS_STYLE), "data-controller" => "shadcn--tooltip", "data-shadcn--tooltip-side-value" => side, "data-shadcn--tooltip-align-value" => align, "data-shadcn--tooltip-side-offset-value" => side_offset, "data-shadcn--tooltip-delay-value" => delay_duration }.merge(defaults)) end |