Files
Atay-Makhzan/web_src/js/standalone/devtest.ts
T

19 lines
742 B
TypeScript
Raw Normal View History

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
function initDevtestToast() {
2025-12-03 03:13:16 +01:00
const levelMap: LevelMap = {info: showInfoToast, warning: showWarningToast, error: showErrorToast};
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')!;
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.
initDevtestToast();