Class: Primer::Tooltip
- Defined in:
- app/components/primer/tooltip.rb
Overview
‘Tooltip` is a wrapper component that will apply a tooltip to the provided content.
Constant Summary collapse
- DIRECTION_DEFAULT =
:n
- ALIGN_DEFAULT =
:default
- MULTILINE_DEFAULT =
false
- DELAY_DEFAULT =
false
- ALIGN_MAPPING =
{ ALIGN_DEFAULT => "", :left_1 => "tooltipped-align-left-1", :right_1 => "tooltipped-align-right-1", :left_2 => "tooltipped-align-left-2", :right_2 => "tooltipped-align-right-2" }.freeze
- DIRECTION_OPTIONS =
[DIRECTION_DEFAULT] + %i[ nw ne w e sw s se ]
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
Primer::TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(label:, direction: DIRECTION_DEFAULT, align: ALIGN_DEFAULT, multiline: MULTILINE_DEFAULT, no_delay: DELAY_DEFAULT, **system_arguments) ⇒ Tooltip
constructor
A new instance of Tooltip.
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(label:, direction: DIRECTION_DEFAULT, align: ALIGN_DEFAULT, multiline: MULTILINE_DEFAULT, no_delay: DELAY_DEFAULT, **system_arguments) ⇒ Tooltip
Returns a new instance of Tooltip.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/components/primer/tooltip.rb', line 37 def initialize( label:, direction: DIRECTION_DEFAULT, align: ALIGN_DEFAULT, multiline: MULTILINE_DEFAULT, no_delay: DELAY_DEFAULT, **system_arguments ) @system_arguments = system_arguments @system_arguments[:tag] ||= :span # rubocop:disable Primer/NoTagMemoize @system_arguments[:aria] = { label: label } @system_arguments[:skip_aria_label_check] = true @system_arguments[:classes] = class_names( @system_arguments[:classes], "tooltipped", "tooltipped-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}", ALIGN_MAPPING[fetch_or_fallback(ALIGN_MAPPING.keys, align, ALIGN_DEFAULT)], "tooltipped-no-delay" => fetch_or_fallback_boolean(no_delay, DELAY_DEFAULT), "tooltipped-multiline" => fetch_or_fallback_boolean(multiline, MULTILINE_DEFAULT) ) end |
Instance Method Details
#call ⇒ Object
60 61 62 |
# File 'app/components/primer/tooltip.rb', line 60 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |