Class: PhlexKit::ToastCancel

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

Overview

Subtle dismiss button in a toast (the "Cancel" counterpart to ToastAction). Dismisses via the phlex-kit--toast controller. See toast_region.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(label:, **attrs) ⇒ ToastCancel

Returns a new instance of ToastCancel.



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

def initialize(label:, **attrs)
  @label = label
  @attrs = attrs
end

Instance Method Details

#view_templateObject



10
11
12
13
14
15
16
# File 'app/components/phlex_kit/toast/toast_cancel.rb', line 10

def view_template
  button(**mix({
    type: :button,
    class: "pk-toast-cancel",
    data: { slot: "cancel", action: "click->phlex-kit--toast#dismiss" }
  }, @attrs)) { @label }
end