Class: Daisy::DataDisplay::StatComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::DataDisplay::StatComponent
- Includes:
- LocoMotion::Concerns::IconableComponent, LocoMotion::Concerns::LinkableComponent, LocoMotion::Concerns::TippableComponent
- Defined in:
- app/components/daisy/data_display/stat_component.rb
Overview
Stats have a transparent background by default. Use ‘bg-base-100` if you need a background color.
The Stat component displays a statistic or metric with optional title, description, and figure. It’s perfect for dashboards, summaries, or any situation where you need to highlight important numbers or metrics.
Includes the LocoMotion::Concerns::TippableComponent module to enable easy tooltip addition.
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary collapse
-
#simple_description ⇒ String
readonly
The description text when using the simple description option.
-
#simple_title ⇒ String
readonly
The title text when using the simple title option.
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
- #before_render ⇒ Object
- #default_icon_size ⇒ Object
-
#initialize(*args, **kws, &block) ⇒ StatComponent
constructor
Creates a new stat component.
Methods included from LocoMotion::Concerns::IconableComponent
#has_icons?, #left_icon_html, #render_left_icon, #render_right_icon, #right_icon_html
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) ⇒ StatComponent
Creates a new stat component.
87 88 89 90 91 92 93 |
# File 'app/components/daisy/data_display/stat_component.rb', line 87 def initialize(*args, **kws, &block) super @simple_title = config_option(:title) @simple_description = config_option(:description) @src = config_option(:src) end |
Instance Attribute Details
#simple_description ⇒ String (readonly)
Returns The description text when using the simple description option.
64 65 66 |
# File 'app/components/daisy/data_display/stat_component.rb', line 64 def simple_description @simple_description end |
#simple_title ⇒ String (readonly)
Returns The title text when using the simple title option.
60 61 62 |
# File 'app/components/daisy/data_display/stat_component.rb', line 60 def simple_title @simple_title end |
Instance Method Details
#before_render ⇒ Object
95 96 97 98 99 |
# File 'app/components/daisy/data_display/stat_component.rb', line 95 def before_render setup_component super end |
#default_icon_size ⇒ Object
101 102 103 |
# File 'app/components/daisy/data_display/stat_component.rb', line 101 def default_icon_size "where:size-8" end |