Class: Fluxbit::SpinnerPercentComponent
- Includes:
- Config::SpinnerPercentComponent
- Defined in:
- app/components/fluxbit/spinner_percent_component.rb
Overview
The ‘Fluxbit::SpinnerPercentComponent` is a component for rendering progress spinners with percentage display.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ Fluxbit::SpinnerPercentComponent
constructor
Initializes the SpinnerPercent component with various customization options.
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::SpinnerPercentComponent
Initializes the SpinnerPercent component with various customization options.
23 24 25 26 27 28 29 30 31 32 33 34 35 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 |
# File 'app/components/fluxbit/spinner_percent_component.rb', line 23 def initialize(**props) super @props = props @color = @props.delete(:color), collection: styles[:colors].keys, default: @@color @size = @props.delete(:size), collection: (0..styles[:sizes].count - 1).to_a, default: @@size @percent = [ @props.delete(:percent) || @@percent, 0 ].max @percent = [ @percent, 100 ].min @label = @props.delete(:label) || @@label @show_percent = @props.delete(:show_percent) @show_percent = @@show_percent if @show_percent.nil? @text = @props.delete(:text) || @@text @label_html = @props.delete(:label_html) || {} @animate = @props.delete(:animate) @animate = @@animate if @animate.nil? @speed = @props.delete(:speed), collection: styles[:speeds].keys, default: @@speed add class: [ styles[:base], styles[:sizes][@size] ], to: @props # Add accessibility attributes @props[:role] = "progressbar" @props[:"aria-label"] = @label @props[:"aria-valuenow"] = @percent @props[:"aria-valuemin"] = "0" @props[:"aria-valuemax"] = "100" # Add Stimulus controller @props[:data] ||= {} @props[:data][:controller] = "fx-spinner-percent" @props[:data][:"fx-spinner-percent-percent-value"] = @percent @props[:data][:"fx-spinner-percent-animate-value"] = @animate @props[:data][:"fx-spinner-percent-speed-value"] = @speed @props[:data][:"fx-spinner-percent-has-custom-text-value"] = !@text.nil? remove_class_from_props(@props) end |
Instance Method Details
#call ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/components/fluxbit/spinner_percent_component.rb', line 63 def call content_tag(:div, **@props) do concat svg_content concat text_content concat screen_reader_content end end |