Module: NitroKit::ToastHelper

Defined in:
app/helpers/nitro_kit/toast_helper.rb

Instance Method Summary collapse

Instance Method Details

#nk_toast(**attrs, &block) ⇒ Object



5
6
7
# File 'app/helpers/nitro_kit/toast_helper.rb', line 5

def nk_toast(**attrs, &block)
  render(Toast.from_template(**attrs), &block)
end

#nk_toast_action(title: nil, description: nil, event: nil) ⇒ Object



9
10
11
12
13
14
15
# File 'app/helpers/nitro_kit/toast_helper.rb', line 9

def nk_toast_action(title: nil, description: nil, event: nil)
  {
    action: "#{event ? "#{event}->" : ""}nk--toast#toast",
    nk__toast_title_param: title,
    nk__toast_description_param: description
  }
end

#nk_toast_flash_messagesObject



17
18
19
# File 'app/helpers/nitro_kit/toast_helper.rb', line 17

def nk_toast_flash_messages
  render(Toast::FlashMessages.from_template(flash))
end

#nk_toast_turbo_stream_refreshObject



21
22
23
# File 'app/helpers/nitro_kit/toast_helper.rb', line 21

def nk_toast_turbo_stream_refresh
  turbo_stream.append("nk--toast-sink", nk_toast_flash_messages)
end