Class: Daisy::DataDisplay::TextRotateComponent

Inherits:
LocoMotion::BaseComponent show all
Includes:
LocoMotion::Concerns::TippableComponent
Defined in:
app/components/daisy/data_display/text_rotate_component.rb

Overview

The Text Rotate component displays up to 6 lines of text, one at a time, with an infinite loop CSS animation. The duration is 10 seconds by default and the animation pauses on hover. Common use cases include rotating hero headlines, cycling through feature keywords, or animating taglines on marketing pages.

Defined Under Namespace

Classes: ItemComponent

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary collapse

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

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

Methods included from LocoMotion::Concerns::InspectableComponent

#build_inspect_string

Constructor Details

#initialize(texts: nil, **kws, &block) ⇒ TextRotateComponent

Creates a new Text Rotate component.

Parameters:

  • texts (Array<String>) (defaults to: nil)

    An optional array of strings for simple usage.

  • kws (Hash)

    The keyword arguments for the component.

Options Hash (**kws):

  • :wrapper_css (String)

    CSS classes to apply to the wrapper part that surrounds all of the rotated items.

  • :tip (String)

    The tooltip text to display when hovering over the component.



190
191
192
193
194
# File 'app/components/daisy/data_display/text_rotate_component.rb', line 190

def initialize(texts: nil, **kws, &block)
  super(**kws, &block)

  @texts = texts
end

Instance Attribute Details

#textsObject (readonly)

Returns the value of attribute texts.



174
175
176
# File 'app/components/daisy/data_display/text_rotate_component.rb', line 174

def texts
  @texts
end

Instance Method Details

#before_renderObject



196
197
198
199
200
201
# File 'app/components/daisy/data_display/text_rotate_component.rb', line 196

def before_render
  super

  setup_component
  setup_texts if texts
end