feat: render flash messages as toasts
Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
5a6db29205
commit
9b35c730ab
9 files changed
+75
-14
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
import Toastify from 'toastify-js';
|
||||
|
||||
/**
|
||||
* Turns one flash message into one toast. The element itself stays empty and invisible --
|
||||
* Toastify appends its own node to the body, which is why a toast outlives the out-of-band
|
||||
* swap of #flashes that spawned it.
|
||||
*/
|
||||
export default class extends Controller {
|
||||
static values = { text: String, class: String };
|
||||
|
||||
connect() {
|
||||
Toastify({
|
||||
text: this.textValue,
|
||||
className: this.classValue,
|
||||
duration: 5000,
|
||||
gravity: 'top',
|
||||
position: 'right',
|
||||
close: true,
|
||||
}).showToast();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user