Method: Primer::Alpha::Tooltip#initialize
- Defined in:
- app/components/primer/alpha/tooltip.rb
permalink #initialize(type:, for_id:, text:, direction: DIRECTION_DEFAULT, **system_arguments) ⇒ Tooltip
Returns a new instance of Tooltip.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/components/primer/alpha/tooltip.rb', line 39 def initialize(type:, for_id:, text:, direction: DIRECTION_DEFAULT, **system_arguments) raise TypeError, "tooltip text must be a string" unless text.is_a?(String) @text = text @system_arguments = system_arguments @id = @system_arguments[:id] ||= self.class.generate_id @system_arguments[:tag] = :"tool-tip" @system_arguments[:for] = for_id @system_arguments[:popover] = "manual" @system_arguments[:classes] = class_names( @system_arguments[:classes], "sr-only" ) @system_arguments[:position] = :absolute @system_arguments[:"data-direction"] = fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT).to_s @system_arguments[:"data-type"] = fetch_or_fallback(TYPE_OPTIONS, type, TYPE_FALLBACK).to_s end |