Class: Daisy::Feedback::RadialProgressComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Feedback::RadialProgressComponent
- Defined in:
- app/components/daisy/feedback/radial_progress_component.rb
Overview
The RadialProgressComponent displays a circular progress indicator that can be customized with different sizes, thicknesses, and colors. The component can also contain content within its circular display.
The progress is always displayed as a percentage (0-100) due to the way the component is rendered using CSS custom properties.
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
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(*args, **kws, &block) ⇒ RadialProgressComponent
constructor
Creates a new Radial Progress component.
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) ⇒ RadialProgressComponent
Creates a new Radial Progress component.
47 48 49 50 51 52 53 |
# File 'app/components/daisy/feedback/radial_progress_component.rb', line 47 def initialize(*args, **kws, &block) super @value = config_option(:value) @size = config_option(:size) @thickness = config_option(:thickness) end |
Instance Method Details
#before_render ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/components/daisy/feedback/radial_progress_component.rb', line 55 def before_render add_css(:component, "radial-progress") styles = [] styles << "--value: #{@value}" if @value != nil styles << "--size: #{@size}" if @size != nil styles << "--thickness: #{@thickness}" if @thickness != nil add_html(:component, { role: "progressbar" }) add_html(:component, { style: styles.join(";") }) if styles.present? end |
#call ⇒ Object
68 69 70 |
# File 'app/components/daisy/feedback/radial_progress_component.rb', line 68 def call part(:component) { content } end |