Class: IronAdmin::Ui::TooltipComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Ui::TooltipComponent
- Defined in:
- app/components/iron_admin/ui/tooltip_component.rb
Overview
Renders a tooltip that appears on hover.
Constant Summary collapse
- POSITIONS =
Position class mappings.
{ top: "bottom-full left-1/2 -translate-x-1/2 mb-2", bottom: "top-full left-1/2 -translate-x-1/2 mt-2", left: "right-full top-1/2 -translate-y-1/2 mr-2", right: "left-full top-1/2 -translate-y-1/2 ml-2", }.freeze
Instance Attribute Summary collapse
-
#position ⇒ Symbol
readonly
Position (:top, :bottom, :left, :right).
-
#text ⇒ String
readonly
Tooltip text.
Instance Method Summary collapse
-
#initialize(text:, position: :top) ⇒ TooltipComponent
constructor
A new instance of TooltipComponent.
-
#position_classes ⇒ String
private
CSS classes for tooltip position.
-
#tooltip_classes ⇒ String
private
CSS classes for tooltip container.
Constructor Details
#initialize(text:, position: :top) ⇒ TooltipComponent
Returns a new instance of TooltipComponent.
29 30 31 32 |
# File 'app/components/iron_admin/ui/tooltip_component.rb', line 29 def initialize(text:, position: :top) @text = text @position = position.to_sym end |
Instance Attribute Details
#position ⇒ Symbol (readonly)
Returns Position (:top, :bottom, :left, :right).
16 17 18 |
# File 'app/components/iron_admin/ui/tooltip_component.rb', line 16 def position @position end |
#text ⇒ String (readonly)
Returns Tooltip text.
13 14 15 |
# File 'app/components/iron_admin/ui/tooltip_component.rb', line 13 def text @text end |
Instance Method Details
#position_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for tooltip position.
36 37 38 |
# File 'app/components/iron_admin/ui/tooltip_component.rb', line 36 def position_classes POSITIONS[@position] || POSITIONS[:top] end |
#tooltip_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for tooltip container.
42 43 44 45 46 |
# File 'app/components/iron_admin/ui/tooltip_component.rb', line 42 def tooltip_classes "absolute #{position_classes} px-2 py-1 text-xs font-medium text-white bg-gray-900 " \ "rounded whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible " \ "transition-all duration-150 z-50" end |