Class: Daisy::DataDisplay::ListComponent

Inherits:
LocoMotion::BaseComponent show all
Defined in:
app/components/daisy/data_display/list_component.rb,
app/components/daisy/data_display/list_component.rb

Overview

The List component is a vertical layout to display information in rows. It can contain various content types including text, images, and actions arranged in a consistent format.

The List component is useful for displaying structured data like user profiles, media libraries, or content collections with a consistent layout.

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

Constructor Details

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

Create a new List component.



68
69
70
71
72
73
74
# File 'app/components/daisy/data_display/list_component.rb', line 68

def initialize(**kws, &block)
  super

  @simple_header = config_option(:header)
  @header_css = config_option(:header_css)
  @header_html = config_option(:header_html)
end

Instance Attribute Details

#header_cssString (readonly)



51
52
53
# File 'app/components/daisy/data_display/list_component.rb', line 51

def header_css
  @header_css
end

#header_htmlString (readonly)



51
52
53
# File 'app/components/daisy/data_display/list_component.rb', line 51

def header_html
  @header_html
end

#simple_headerString (readonly)



51
52
53
# File 'app/components/daisy/data_display/list_component.rb', line 51

def simple_header
  @simple_header
end

Instance Method Details

#before_renderObject



76
77
78
79
80
81
# File 'app/components/daisy/data_display/list_component.rb', line 76

def before_render
  add_css(:component, "list")
  set_tag_name(:component, :ul)

  with_header(tag_name: :li, css: header_css, html: header_html) { simple_header } if simple_header && !header?
end