Class: PhlexKit::ToastClose

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/toast/toast_close.rb

Overview

The ×-in-the-corner close button, shown when the region has close_button: true (or a spawn asks for one). See toast_region.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ ToastClose

Returns a new instance of ToastClose.



5
6
7
# File 'app/components/phlex_kit/toast/toast_close.rb', line 5

def initialize(**attrs)
  @attrs = attrs
end

Instance Method Details

#view_templateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/phlex_kit/toast/toast_close.rb', line 9

def view_template
  button(**mix({
    type: :button,
    class: "pk-toast-close",
    aria: { label: "Close toast" },
    data: { slot: "close", action: "click->phlex-kit--toast#dismiss" }
  }, @attrs)) do
    svg(
      xmlns: "http://www.w3.org/2000/svg",
      width: "14",
      height: "14",
      viewbox: "0 0 24 24",
      fill: "none",
      stroke: "currentColor",
      "stroke-width": "2",
      "stroke-linecap": "round",
      "stroke-linejoin": "round",
      "aria-hidden": "true"
    ) do |s|
      s.path(d: "M18 6 6 18")
      s.path(d: "m6 6 12 12")
    end
    span(class: "pk-sr-only") { "Close" }
  end
end