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, **attrs) ⇒ Progress
constructor
A new instance of Progress.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(value: 0, **attrs) ⇒ Progress
Returns a new instance of Progress.
7 8 9 10 |
# File 'app/components/phlex_kit/progress/progress.rb', line 7 def initialize(value: 0, **attrs) @value = value.to_f.clamp(0.0, 100.0) @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/phlex_kit/progress/progress.rb', line 12 def view_template div(**mix({ role: "progressbar", "aria-valuenow": @value, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuetext": "#{@value}%", class: "pk-progress" }, @attrs)) do div(class: "pk-progress-indicator", style: "transform: translateX(-#{100 - @value}%)") end end |