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
# 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
    render Icon.new(:x, size: 14)
    span(class: "pk-sr-only") { "Close" }
  end
end