Class: PhlexKit::Spinner
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Spinner
- Defined in:
- app/components/phlex_kit/spinner/spinner.rb
Overview
Loading spinner, ported from shadcn/ui's Spinner (a spinning loader icon;
not in ruby_ui). Sizes via SIZES.fetch. .pk-spinner (spinner.css).
Constant Summary collapse
- SIZES =
{ sm: "sm", md: nil, lg: "lg" }.freeze
Instance Method Summary collapse
-
#initialize(size: :md, **attrs) ⇒ Spinner
constructor
A new instance of Spinner.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(size: :md, **attrs) ⇒ Spinner
Returns a new instance of Spinner.
7 8 9 10 |
# File 'app/components/phlex_kit/spinner/spinner.rb', line 7 def initialize(size: :md, **attrs) @size = size.to_sym @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/phlex_kit/spinner/spinner.rb', line 12 def view_template svg(**mix({ xmlns: "http://www.w3.org/2000/svg", viewbox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: [ "pk-spinner", SIZES.fetch(@size) ].compact.join(" "), role: "status", aria: { label: "Loading" } }, @attrs)) { |s| s.path(d: "M21 12a9 9 0 1 1-6.219-8.56") } end |