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.
Constant Summary collapse
- GLYPHS =
Status → canonical glyph. Error is circle_x (octagon-x has no equivalent outside Lucide, so the cross-library semantic name wins).
{ success: :circle_check, error: :circle_x, warning: :triangle_alert, info: :info, loading: :loader }.freeze
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
22 23 24 25 26 27 |
# File 'app/components/phlex_kit/toast/toast_icon.rb', line 22 def view_template return unless renderable? span(**mix({ class: "pk-toast-icon", data: { slot: "icon" } }, @attrs)) do render Icon.new(fetch_option(GLYPHS, @variant, :glyph), size: 16, class: svg_classes) end end |