Class: Daisy::Feedback::SkeletonComponent

Inherits:
LocoMotion::BaseComponent show all
Defined in:
app/components/daisy/feedback/skeleton_component.rb

Overview

The SkeletonComponent creates loading placeholder elements that mimic the shape and size of content that is being loaded. This provides users with a visual indication of the content's layout before it arrives, reducing perceived loading times and improving user experience.

Skeletons can be used in two ways:

  1. As standalone shapes with custom dimensions.
  2. As a modifier class on existing components to create component-specific loading states.

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

#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(*args, **kws, &block) ⇒ SkeletonComponent

Creates a new Skeleton component.

Parameters:

  • args (Array)

    Positional arguments passed to the parent class.

  • kws (Hash)

    Keyword arguments for customizing the skeleton.

Options Hash (**kws):

  • css (String)

    Additional CSS classes for styling. Common options include:

    • Dimensions: w-24, h-20
    • Shapes: rounded-full, rounded-lg
    • Colors: bg-base-200
    • Text shimmer: skeleton-text (animates text with the shimmer gradient — use alongside skeleton on the same element) When using with other components, combine with text-transparent to hide placeholder text.


56
57
58
# File 'app/components/daisy/feedback/skeleton_component.rb', line 56

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

Instance Method Details

#before_renderObject



60
61
62
# File 'app/components/daisy/feedback/skeleton_component.rb', line 60

def before_render
  add_css(:component, "skeleton")
end

#callObject



64
65
66
# File 'app/components/daisy/feedback/skeleton_component.rb', line 64

def call
  part(:component) { content }
end