Class: Fluxbit::ProgressComponent
- Includes:
- Config::ProgressComponent
- Defined in:
- app/components/fluxbit/progress_component.rb
Overview
The ‘Fluxbit::ProgressComponent` is a customizable progress bar component that extends `Fluxbit::Component`. It allows you to create progress indicators with various styles, sizes, colors, and label positioning options to display completion status or loading progress.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ Fluxbit::ProgressComponent
constructor
Initializes the progress component with the given properties.
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?
Methods included from IconHelpers
#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon
Constructor Details
#initialize(**props) ⇒ Fluxbit::ProgressComponent
Initializes the progress component with the given properties.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/components/fluxbit/progress_component.rb', line 36 def initialize(**props) super @props = props # Use options() function with config defaults @progress = (@props.delete(:progress), default: @@progress) @color = (@props.delete(:color), collection: styles[:bar][:colors].keys, default: @@color) @size = (@props.delete(:size), default: @@size) @text_label = (@props.delete(:text_label), default: @@text_label) @label_progress = (@props.delete(:label_progress), default: @@label_progress) @label_text = (@props.delete(:label_text), default: @@label_text) @progress_label_position = (@props.delete(:progress_label_position), collection: [ :inside, :outside ], default: @@progress_label_position) @text_label_position = (@props.delete(:text_label_position), collection: [ :inside, :outside ], default: @@text_label_position) @label_html = (@props.delete(:label_html), default: @@label_html) @stimulus = (@props.delete(:stimulus), default: @@stimulus) # Sanitize progress value @progress = [ @progress.to_i, 0 ].max @progress = [ @progress, 100 ].min # Apply styling declare_classes # Handle class removal @props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class]) end |
Instance Method Details
#call ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'app/components/fluxbit/progress_component.rb', line 67 def call content_tag(:div) do safe_join([ render_outside_labels, render_progress_container ].compact) end end |