Class: PhlexKit::Progress
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Progress
- Defined in:
- app/components/phlex_kit/progress/progress.rb
Overview
Progress bar, ported from ruby_ui's RubyUI::Progress. value: (0–100,
clamped) drives an inner indicator translated into view. Presentational, no
JS; width comes from a caller class:/style:. Tailwind → vanilla
.pk-progress* (progress.css).
Instance Method Summary collapse
-
#initialize(value: 0, value_text: nil, **attrs) ⇒ Progress
constructor
value_text: is a named kwarg (not read from **attrs) because
mixwould fuse a caller "aria-valuetext" with the generated default. - #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(value: 0, value_text: nil, **attrs) ⇒ Progress
value_text: is a named kwarg (not read from **attrs) because mix
would fuse a caller "aria-valuetext" with the generated default.
value: nil renders the INDETERMINATE state (Radix parity): a sliding
animation, data-state="indeterminate", and no aria-valuenow — which is
exactly how ARIA marks a progressbar of unknown value.
12 13 14 15 16 |
# File 'app/components/phlex_kit/progress/progress.rb', line 12 def initialize(value: 0, value_text: nil, **attrs) @value = value.nil? ? nil : value.to_f.clamp(0.0, 100.0) @value_text = value_text @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
18 19 20 21 22 |
# File 'app/components/phlex_kit/progress/progress.rb', line 18 def view_template div(**mix(root_attrs, @attrs)) do div(class: "pk-progress-indicator") end end |