Module: Bootstrap5RailsExtensions::ToastHelper

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

Constant Summary collapse

FLASH_TOAST_COLORS =

コンテナだけを描画(右上固定)。この時点ではStimulusは起動しない。レイアウトで <%= render_toast %> を配置しておき、表示時は turbo_stream.toast で要素を差し込む。

{
  notice: :success,
  alert: :danger,
  error: :danger,
  warning: :warning,
  info: :info,
  success: :success
}.freeze

Instance Method Summary collapse

Instance Method Details

#render_toast(id: "toast-root", position: "top-0 end-0", flash_messages: nil) ⇒ Object



14
15
16
17
# File 'app/helpers/bootstrap5_rails_extensions/toast_helper.rb', line 14

def render_toast(id: "toast-root", position: "top-0 end-0", flash_messages: nil)
  flash_nodes = build_flash_toasts(flash_messages)
  (:div, safe_join(flash_nodes), id: id, class: "toast-container position-fixed #{position} p-3")
end