Class: Polaris::TooltipComponent
- Defined in:
- app/components/polaris/tooltip_component.rb
Constant Summary collapse
- POSITION_OPTIONS =
[:top, :bottom, :left, :right]
- DEFAULT_POSITION =
:bottom
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
-
#initialize(text: nil, position: DEFAULT_POSITION, active: true, **system_arguments) ⇒ TooltipComponent
constructor
A new instance of TooltipComponent.
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested
Methods included from ClassNameHelper
Constructor Details
#initialize(text: nil, position: DEFAULT_POSITION, active: true, **system_arguments) ⇒ TooltipComponent
Returns a new instance of TooltipComponent.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/polaris/tooltip_component.rb', line 6 def initialize( text: nil, position: DEFAULT_POSITION, active: true, **system_arguments ) @text = text @system_arguments = system_arguments @position = fetch_or_fallback(POSITION_OPTIONS, position, DEFAULT_POSITION) @active = active system_arguments[:data] ||= {} prepend_option(system_arguments[:data], :polaris_tooltip_active_value, @active) prepend_option(system_arguments[:data], :polaris_tooltip_position_value, @position) prepend_option( system_arguments[:data], :action, %w[ mouseenter->polaris-tooltip#show mouseleave->polaris-tooltip#hide focus->polaris-tooltip#show blur->polaris-tooltip#hide ].join(" ") ) prepend_option(system_arguments[:data], :controller, "polaris-tooltip") end |