Add administration submenu and refine controls and toast states
This commit is contained in:
1 parent
cd821abb51
commit
aece8e59cd
125 files changed
+898
-57
No files matched your search
+6
-9
@@ -1,3 +1,4 @@
|
||||
import { createNotifier } from "../components/toast.js";
|
||||
import { icons, iconNames, iconSvg } from "./icons.js";
|
||||
import { tokensFor, cssVars } from "../concepts/registry.js";
|
||||
const $ = (s) => document.querySelector(s);
|
||||
@@ -13,8 +14,7 @@ const categories = {
|
||||
};
|
||||
for (const [id, label] of Object.entries(categories))
|
||||
$("#category").add(new Option(label, id));
|
||||
let theme = "light",
|
||||
timer;
|
||||
let theme = "light";
|
||||
try {
|
||||
theme =
|
||||
JSON.parse(localStorage.getItem("anidev.preferences") || "{}").theme ===
|
||||
@@ -54,22 +54,19 @@ $("#theme").addEventListener("click", () => {
|
||||
theme = theme === "dark" ? "light" : "dark";
|
||||
applyTheme();
|
||||
});
|
||||
const notify = createNotifier($("#toast"));
|
||||
$("#icon-grid").addEventListener("click", async (e) => {
|
||||
const tile = e.target.closest("[data-icon]");
|
||||
if (!tile) return;
|
||||
const toast = $("#toast");
|
||||
toast.popover = "manual";
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(
|
||||
iconSvg(tile.dataset.icon, { size: Number($("#size").value) }),
|
||||
);
|
||||
toast.textContent = `SVG скопирован: ${tile.dataset.icon}`;
|
||||
notify(`SVG скопирован: ${tile.dataset.icon}`, { type: "success" });
|
||||
} catch {
|
||||
toast.textContent = "Не удалось скопировать. Скачайте SVG-пак.";
|
||||
notify("Не удалось скопировать. Скачайте SVG-пак.", { type: "error" });
|
||||
}
|
||||
toast.showPopover();
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => toast.hidePopover(), 2800);
|
||||
});
|
||||
applyTheme();
|
||||
render();
|
||||
Reference in new issue
Block a user