Files
devplacepy/devplacepy/static/js/components/AppToast.js
T
retoor 741d7aade6 docs: add block/mute user relations, emoji-sync CLI, and uid indexes
- Add `/block`, `/mute` endpoints with block/unblock and mute/unmute functionality in `routers/relations.py`, hiding blocked users' content everywhere except their own profile while muting only suppresses notifications
- Introduce `devplace emoji-sync` CLI command to regenerate `static/js/emoji-shortcodes.js` from the emoji library, documented in `CLAUDE.md` and wired in `cli.py`
- Create `get_blocked_uids()` database helper and apply it in `content.py` `load_detail()` to filter blocked users' posts from detail views
- Implement `_uid_index()` and `_drop_index()` helpers in `database.py` for unique uid indexes across tables, with `user_relations` added to `SOFT_DELETE_TABLES`
- Document new routes in `AGENTS.md` and `README.md`, including emoji shortcodes rendering behavior distinct from the emoji picker
2026-06-19 08:06:09 +00:00

46 lines
1.4 KiB
JavaScript

// retoor <retoor@molodetz.nl>
import { Component } from "./Component.js";
export class AppToast extends Component {
connectedCallback() {
this.classList.add("dp-toast-host");
}
show(message, options = {}) {
const type = options.type || "info";
const ms = options.ms || 3000;
const toast = document.createElement("div");
toast.className = `dp-toast dp-toast-${type}`;
const assertive = type === "error" || type === "warning";
toast.setAttribute("role", assertive ? "alert" : "status");
toast.setAttribute("aria-live", assertive ? "assertive" : "polite");
toast.setAttribute("aria-atomic", "true");
toast.textContent = message;
const action = this._action(options);
if (action) {
toast.classList.add("dp-toast-link");
toast.addEventListener("click", action);
}
this.appendChild(toast);
requestAnimationFrame(() => toast.classList.add("visible"));
setTimeout(() => {
toast.classList.remove("visible");
setTimeout(() => toast.remove(), 200);
}, ms);
return toast;
}
_action(options) {
if (typeof options.onClick === "function") return options.onClick;
if (options.url) {
return () => {
window.location.href = options.url;
};
}
return null;
}
}
customElements.define("dp-toast", AppToast);