2026-03-29 12:24:30 +02:00
|
|
|
import '../../css/standalone/devtest.css';
|
2025-12-03 03:13:16 +01:00
|
|
|
import {showInfoToast, showWarningToast, showErrorToast, type Toast} from '../modules/toast.ts';
|
|
|
|
|
|
|
|
|
|
type LevelMap = Record<string, (message: string) => Toast | null>;
|
2023-06-27 04:45:24 +02:00
|
|
|
|
2024-06-27 21:58:38 +08:00
|
|
|
function initDevtestToast() {
|
2025-12-03 03:13:16 +01:00
|
|
|
const levelMap: LevelMap = {info: showInfoToast, warning: showWarningToast, error: showErrorToast};
|
2024-06-27 21:58:38 +08:00
|
|
|
for (const el of document.querySelectorAll('.toast-test-button')) {
|
|
|
|
|
el.addEventListener('click', () => {
|
2025-12-03 03:13:16 +01:00
|
|
|
const level = el.getAttribute('data-toast-level')!;
|
|
|
|
|
const message = el.getAttribute('data-toast-message')!;
|
2024-06-27 21:58:38 +08:00
|
|
|
levelMap[level](message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-08 16:59:31 +08:00
|
|
|
// NOTICE: keep in mind that this file is not in "index.js", they do not share the same module system.
|
2024-06-27 21:58:38 +08:00
|
|
|
initDevtestToast();
|