Class: PhlexKit::ToastIcon
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::ToastIcon
- Defined in:
- app/components/phlex_kit/toast/toast_icon.rb
Overview
Leading status icon for a PhlexKit::ToastItem. Renders nothing for :default / nil (matching ruby_ui — only the status-ful variants get an icon); the toaster swaps its innerHTML when a toast mutates (e.g. loading → success). See toast_region.rb.
Instance Method Summary collapse
-
#initialize(variant: nil, **attrs) ⇒ ToastIcon
constructor
A new instance of ToastIcon.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(variant: nil, **attrs) ⇒ ToastIcon
Returns a new instance of ToastIcon.
7 8 9 10 |
# File 'app/components/phlex_kit/toast/toast_icon.rb', line 7 def initialize(variant: nil, **attrs) @variant = variant&.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 26 27 28 29 |
# File 'app/components/phlex_kit/toast/toast_icon.rb', line 12 def view_template return unless renderable? span(**mix({ class: "pk-toast-icon", data: { slot: "icon" } }, @attrs)) do svg( xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewbox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: svg_classes, "aria-hidden": "true" ) { |s| paths(s) } end end |