a11yist/app/javascript/controllers/toast_controller.js
david 4dd445be57
Some checks failed
/ Run tests (push) Successful in 7m57s
/ Run system tests (push) Failing after 4m18s
/ Build, push and deploy image (push) Failing after 59s
wip: wcag structure
2025-05-16 19:02:33 +02:00

14 lines
488 B
JavaScript

import { Controller } from "@hotwired/stimulus"
import * as bootstrap from "bootstrap"
// Connects to data-controller="toast"
export default class extends Controller {
connect() {
const shownKey = `toastsShown[${this.element.getAttribute("data-ts")}]`
if(!window.sessionStorage.getItem(shownKey)) {
window.sessionStorage.setItem(shownKey, Date.now());
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(this.element)
toastBootstrap.show()
}
}
}