Class: Daisy::DataDisplay::TextRotateComponent::ItemComponent

Inherits:
LocoMotion::BasicComponent show all
Includes:
LocoMotion::Concerns::IconableComponent, LocoMotion::Concerns::LinkableComponent
Defined in:
app/components/daisy/data_display/text_rotate_component.rb

Overview

Renders an individual text item within the rotation. Supports optional links (via LocoMotion::Concerns::LinkableComponent) and icons (via LocoMotion::Concerns::IconableComponent).

Instance Method Summary collapse

Methods included from LocoMotion::Concerns::IconableComponent

#has_icons?, #left_icon_html, #render_left_icon, #render_right_icon, #right_icon_html

Methods inherited from LocoMotion::BasicComponent

name

Constructor Details

#initialize(**kws, &block) ⇒ ItemComponent

Creates a new Text Rotate item.

rubocop:disable Lint/UselessMethodDefinition

Parameters:

  • kws (Hash)

    The keyword arguments for the component.

Options Hash (**kws):

  • href (String)

    A path or URL to which the user will be directed when the item is clicked. Forces the item to use an <a> tag.

  • target (String)

    The HTML target attribute for the <a> tag (_blank, _parent, or a specific tab / window / iframe, etc).

  • title (String)

    The HTML title attribute for the <a> tag, shown as a native tooltip on hover. Only applied when href is also provided.

  • turbo_frame (String)

    The Turbo Frame to target, rendered as data-turbo-frame.

  • turbo_action (String, Symbol)

    How Turbo Drive updates the browser history for the visit, rendered as data-turbo-action (e.g. :advance or :replace).

  • turbo_method (String, Symbol)

    The HTTP method Turbo should use for the request, rendered as data-turbo-method (e.g. :delete).

  • turbo_confirm (String)

    A confirmation prompt Turbo shows before submitting, rendered as data-turbo-confirm.

  • action (String)

    A Stimulus action wired to the item via its data-action attribute. Stimulus infers the click event, so action: "my-controller#handle" works as a shorthand for action: "click->my-controller#handle".

  • icon (String)

    The icon to render, as a qualified [library:]name[/variant] token. This is an alias of left_icon.

  • icon_css (String)

    The CSS classes to apply to the icon. This is an alias of left_icon_css.

  • icon_options (Hash)

    Additional keyword arguments forwarded to the icon component. This is an alias of left_icon_options.

  • icon_html (Hash)

    Additional HTML attributes to apply to the icon. This is an alias of left_icon_html.

  • left_icon (String)

    The icon to render to the left of the content, as a qualified [library:]name[/variant] token.

  • left_icon_css (String)

    The CSS classes to apply to the left icon.

  • left_icon_options (Hash)

    Additional keyword arguments forwarded to the left icon component (e.g. tip:).

  • left_icon_html (Hash)

    Additional HTML attributes to apply to the left icon.

  • right_icon (String)

    The icon to render to the right of the content, as a qualified [library:]name[/variant] token.

  • right_icon_css (String)

    The CSS classes to apply to the right icon.

  • right_icon_options (Hash)

    Additional keyword arguments forwarded to the right icon component (e.g. tip:).

  • right_icon_html (Hash)

    Additional HTML attributes to apply to the right icon.



138
139
140
# File 'app/components/daisy/data_display/text_rotate_component.rb', line 138

def initialize(**kws, &block)
  super
end

Instance Method Details

#before_renderObject

Runs item-specific setup before rendering. Runs before super so that LinkableComponent can override the tag name to <a> when an href is set.



147
148
149
150
151
# File 'app/components/daisy/data_display/text_rotate_component.rb', line 147

def before_render
  setup_component

  super
end

#callObject

Renders the item, including optional left/right icons around the content.



156
157
158
159
160
161
162
# File 'app/components/daisy/data_display/text_rotate_component.rb', line 156

def call
  part(:component) do
    concat(render_left_icon)
    concat(content)
    concat(render_right_icon)
  end
end