20 lines
483 B
JavaScript
20 lines
483 B
JavaScript
// retoor <retoor@molodetz.nl>
|
|||
|
|
import { Component } from "./Component.js";
|
||
|
|
|
||
|
|
export class ToastHost extends Component {
|
||
|
|
static tag = "dp-toast";
|
||
|
|
|
||
|
|
setup() {
|
||
|
|
this.setAttribute("role", "status");
|
||
|
|
this.setAttribute("aria-live", "polite");
|
||
|
|
}
|
||
|
|
|
||
|
|
show(message, kind = "info", ms = 3500) {
|
||
|
|
const item = document.createElement("div");
|
||
|
|
item.className = `toast ${kind}`;
|
||
|
|
item.textContent = message;
|
||
|
|
this.append(item);
|
||
|
|
setTimeout(() => item.remove(), ms);
|
||
|
|
}
|
||
|
|
}
|