Turbo
Flash messages
Your controllers' flash, shown as toasts, with no change to how you set it.
Render flash_toasts once, in the layout, and every flash your controllers set shows as a toast.
It dismisses itself after duration: milliseconds, waits while it's hovered or focused, and
survives a morph refresh while it's on screen.
<%= flash_toasts %>Setting a flash
Nothing changes in the controller:
redirect_to labels_path, notice: "Label saved."Tones
Each flash type has a tone: notice and success are good, alert and
error are bad, warning warns, and anything else is info. Map your own types in an
initializer:
Unmagic::Components.configure do |config|
config.flash_tones = config.flash_tones.merge("saved" => :good)
endOptions
duration: 0 keeps toasts up until they're dismissed, which also helps a system test that
checks for one. position: defaults to :top_end. Pass the flashes yourself to
leave some out:
<%= flash_toasts flash.to_hash.except("copy_link"), duration: 8000 %>
For a toast outside the flash cycle, use turbo_stream.toast.
Needs import "unmagic/components/toasts".