Class: Daisy::Feedback::TooltipComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Feedback::TooltipComponent
- Defined in:
- app/components/daisy/feedback/tooltip_component.rb
Overview
The TooltipComponent displays informative text when users hover over an element. It can be used in two ways:
-
As a wrapper component around any HTML content.
-
Through the TippableComponent concern, which many components include.
This component is also aliased as ‘daisy_tip` for convenience.
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
-
#before_render ⇒ Object
Sets up the component’s CSS and HTML attributes.
-
#call ⇒ Object
Renders the component and its content (inline).
-
#initialize(*args, **kws, &block) ⇒ TooltipComponent
constructor
Creates a new Tooltip component.
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Constructor Details
#initialize(*args, **kws, &block) ⇒ TooltipComponent
Creates a new Tooltip component.
55 56 57 58 59 60 |
# File 'app/components/daisy/feedback/tooltip_component.rb', line 55 def initialize(*args, **kws, &block) super # Accept a `tip` keyword argument, or the first positional argument @tip = config_option(:tip, args[0]) end |
Instance Method Details
#before_render ⇒ Object
Sets up the component’s CSS and HTML attributes.
65 66 67 68 |
# File 'app/components/daisy/feedback/tooltip_component.rb', line 65 def before_render add_css(:component, "tooltip") add_html(:component, { data: { tip: @tip } }) if @tip end |
#call ⇒ Object
Renders the component and its content (inline).
73 74 75 |
# File 'app/components/daisy/feedback/tooltip_component.rb', line 73 def call part(:component) { content } end |