Serve Dock directly and add explicit navigation feedback
This commit is contained in:
1 parent
645afe3ebf
commit
84c4b3030a
77 files changed
+477
-920
No files matched your search
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>Anidev — Concept preview</title>
|
||||
<title>Anidev Dock</title>
|
||||
<link rel="stylesheet" href="../components/system.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
+75
-7
@@ -7,12 +7,27 @@ import {
|
||||
createAccountUI,
|
||||
accountPageIds,
|
||||
} from "../components/account-pages.js";
|
||||
import { exportSystem } from "../components/export-system.js";
|
||||
const identityAdapter = createDemoIdentityAdapter();
|
||||
let preferences = {};
|
||||
try {
|
||||
preferences =
|
||||
JSON.parse(
|
||||
localStorage.getItem("anidev.preferences") ||
|
||||
localStorage.getItem("anidev.lab") ||
|
||||
"{}",
|
||||
) || {};
|
||||
} catch {}
|
||||
const params = new URLSearchParams(location.search),
|
||||
concept = concepts.find((c) => c.id === params.get("concept")) || concepts[0];
|
||||
let theme = params.get("theme") === "dark" ? "dark" : "light",
|
||||
density = params.get("density") || "normal",
|
||||
locale = params.get("locale") === "en" ? "en" : "ru";
|
||||
let theme =
|
||||
(params.get("theme") || preferences.theme) === "dark" ? "dark" : "light",
|
||||
density = ["compact", "normal", "relaxed"].includes(
|
||||
params.get("density") || preferences.density,
|
||||
)
|
||||
? params.get("density") || preferences.density
|
||||
: "compact",
|
||||
locale = (params.get("locale") || preferences.locale) === "en" ? "en" : "ru";
|
||||
const rawAccent = params.get("accent"),
|
||||
accent = /^#[0-9a-f]{6}$/i.test(rawAccent)
|
||||
? rawAccent
|
||||
@@ -312,7 +327,30 @@ function setDockOpen(open, returnFocus = true) {
|
||||
if (returnFocus) toggle.focus();
|
||||
}
|
||||
}
|
||||
function savePreferences() {
|
||||
try {
|
||||
localStorage.setItem(
|
||||
"anidev.preferences",
|
||||
JSON.stringify({ theme, density, locale }),
|
||||
);
|
||||
} catch {}
|
||||
}
|
||||
let initialRender = true;
|
||||
function render() {
|
||||
const route = new URL(location.href);
|
||||
route.searchParams.set("page", page);
|
||||
route.searchParams.set("theme", theme);
|
||||
route.searchParams.set("locale", locale);
|
||||
if (route.href !== location.href) {
|
||||
history[
|
||||
initialRender ||
|
||||
route.searchParams.get("page") ===
|
||||
new URL(location.href).searchParams.get("page")
|
||||
? "replaceState"
|
||||
: "pushState"
|
||||
]({}, "", route);
|
||||
}
|
||||
initialRender = false;
|
||||
dockHoverOpened = false;
|
||||
clearTimeout(dockCloseTimer);
|
||||
document.body.classList.remove("dock-open");
|
||||
@@ -508,7 +546,7 @@ function componentScreen() {
|
||||
<section class="specimen"><h2>Chart</h2>${chart()}</section></div><p class="compact-note">${t("Таблицы, пагинация и фильтры — на экране «Пользователи»; вкладки — в настройках; форма входа — в авторизации.", "Tables, pagination and filters: Users. Tabs: Settings. Sign-in form: Authentication.")}</p></div>`;
|
||||
}
|
||||
function tokenScreen() {
|
||||
return `${heading(t("Дизайн-токены", "Design tokens"), `${concept.name} / ${theme} / ${density}`, `<button data-action="copy-json">${t("Копировать JSON", "Copy JSON")}</button><button class="primary" data-action="copy-css">${t("Копировать CSS", "Copy CSS")}</button>`)}<div class="page-body"><div class="tokens-list">${Object.entries(
|
||||
return `${heading(t("Дизайн-токены", "Design tokens"), `${concept.name} / ${theme} / ${density}`, `<button data-action="download-system">${t("Экспорт системы", "Export system")}</button><button data-action="copy-json">${t("Копировать JSON", "Copy JSON")}</button><button class="primary" data-action="copy-css">${t("Копировать CSS", "Copy CSS")}</button>`)}<div class="page-body"><div class="tokens-list">${Object.entries(
|
||||
tokens,
|
||||
)
|
||||
.map(
|
||||
@@ -517,7 +555,7 @@ function tokenScreen() {
|
||||
)
|
||||
.join(
|
||||
"",
|
||||
)}</div><pre class="code-block">:root {\n${cssVars(tokens)}\n}</pre><p class="compact-note">${t("Экспорт галереи включает обе темы, JSON и CSS. Акцент применяется к каждой концепции отдельно.", "Gallery export includes both themes, JSON and CSS. Each concept retains its own accent.")}</p></div>`;
|
||||
)}</div><pre class="code-block">:root {\n${cssVars(tokens)}\n}</pre><p class="compact-note">${t("Экспорт включает обе темы, JSON и CSS. Акцент применяется к каждой концепции отдельно.", "Export includes both themes, JSON and CSS. Each concept retains its own accent.")}</p></div>`;
|
||||
}
|
||||
let dialogInitiator = null;
|
||||
function openDialog(title, body, cls = "") {
|
||||
@@ -772,6 +810,24 @@ document.addEventListener("click", async (e) => {
|
||||
command,
|
||||
activity: () => $("#activity").scrollIntoView({ behavior: "smooth" }),
|
||||
profile: () => navigate("profile"),
|
||||
"download-system": async () => {
|
||||
button.disabled = true;
|
||||
try {
|
||||
await exportSystem(
|
||||
{ page, theme, density, locale, accent: rawAccent || undefined },
|
||||
toast,
|
||||
);
|
||||
} catch {
|
||||
toast(
|
||||
t(
|
||||
"Экспорт не удался. Повторите попытку.",
|
||||
"Export failed. Try again.",
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
},
|
||||
prev: () => {
|
||||
userPage--;
|
||||
refreshUsers();
|
||||
@@ -1074,8 +1130,7 @@ const accountUI = createAccountUI({
|
||||
document.documentElement.style.cssText = cssVars(tokens);
|
||||
document.body.dataset.theme = theme;
|
||||
render();
|
||||
if (parent !== window)
|
||||
parent.postMessage({ type: "anidev-theme", theme }, location.origin);
|
||||
savePreferences();
|
||||
},
|
||||
});
|
||||
if (identityStates.includes(params.get("identityState")))
|
||||
@@ -1086,4 +1141,17 @@ addEventListener("storage", (e) => {
|
||||
render();
|
||||
}
|
||||
});
|
||||
addEventListener("popstate", () => {
|
||||
const route = new URL(location.href);
|
||||
page = Object.keys(pageNames).includes(route.searchParams.get("page"))
|
||||
? route.searchParams.get("page")
|
||||
: "dashboard";
|
||||
theme = route.searchParams.get("theme") === "dark" ? "dark" : "light";
|
||||
tokens = tokensFor("dock", theme, rawAccent || undefined, density);
|
||||
document.documentElement.style.cssText = cssVars(tokens);
|
||||
document.body.dataset.theme = theme;
|
||||
initialRender = true;
|
||||
$("#dialog").close();
|
||||
render();
|
||||
});
|
||||
render();
|
||||
@@ -1,400 +0,0 @@
|
||||
:root {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
color: #e9e9e9;
|
||||
background: #151617;
|
||||
font-synthesis: none;
|
||||
}
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
button,
|
||||
select,
|
||||
input {
|
||||
font: inherit;
|
||||
}
|
||||
button,
|
||||
select,
|
||||
a,
|
||||
input[type="color"],
|
||||
input[type="checkbox"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
button,
|
||||
select {
|
||||
color: inherit;
|
||||
background: #232527;
|
||||
border: 1px solid #494c4f;
|
||||
border-radius: 5px;
|
||||
min-height: 36px;
|
||||
padding: 7px 11px;
|
||||
}
|
||||
button:hover,
|
||||
select:hover {
|
||||
background: #34373a;
|
||||
}
|
||||
button:focus-visible,
|
||||
select:focus-visible,
|
||||
input:focus-visible,
|
||||
a:focus-visible {
|
||||
outline: 3px solid #d7f3a3;
|
||||
outline-offset: 3px;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: wait;
|
||||
}
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
.mast {
|
||||
padding: 22px 3.5%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #353738;
|
||||
gap: 20px;
|
||||
}
|
||||
.brand {
|
||||
text-decoration: none;
|
||||
font-size: 23px;
|
||||
font-weight: bold;
|
||||
letter-spacing: -1px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.brand > span:last-child {
|
||||
font-size: 13px;
|
||||
font-weight: normal;
|
||||
color: #aaa;
|
||||
letter-spacing: 0;
|
||||
border-left: 1px solid #505354;
|
||||
padding-left: 15px;
|
||||
}
|
||||
.mark {
|
||||
color: #dcf8ad;
|
||||
font-size: 29px;
|
||||
}
|
||||
.mast-end {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.eyebrow {
|
||||
font:
|
||||
12px Consolas,
|
||||
monospace;
|
||||
letter-spacing: 1.6px;
|
||||
color: #a8b19f;
|
||||
}
|
||||
.export {
|
||||
background: #dcf8ad;
|
||||
color: #1b2414;
|
||||
border-color: #dcf8ad;
|
||||
}
|
||||
.export:hover {
|
||||
background: #c1e08c;
|
||||
}
|
||||
main {
|
||||
max-width: 1900px;
|
||||
margin: auto;
|
||||
padding: 0 3.5%;
|
||||
}
|
||||
.intro {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
padding: 40px 0 30px;
|
||||
gap: 20px;
|
||||
}
|
||||
.eyebrow {
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
h1 {
|
||||
font-size: clamp(29px, 3.2vw, 48px);
|
||||
letter-spacing: -1.8px;
|
||||
line-height: 1.06;
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
}
|
||||
h1 span {
|
||||
color: #a2a6a8;
|
||||
}
|
||||
.intro-copy {
|
||||
font-size: 14px;
|
||||
line-height: 1.7;
|
||||
color: #aeb2b5;
|
||||
margin: 0 0 3px;
|
||||
}
|
||||
.lab {
|
||||
border: 1px solid #414447;
|
||||
border-radius: 7px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.toolbar {
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
align-items: flex-end;
|
||||
flex-wrap: wrap;
|
||||
background: #1b1d1f;
|
||||
}
|
||||
.toolbar label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: #b6bbbe;
|
||||
}
|
||||
.toolbar label.compare {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: 36px;
|
||||
gap: 5px;
|
||||
}
|
||||
.toolbar select {
|
||||
font-size: 13px;
|
||||
max-width: 180px;
|
||||
}
|
||||
.toolbar input[type="color"] {
|
||||
padding: 3px;
|
||||
border: 1px solid #494c4f;
|
||||
height: 36px;
|
||||
width: 42px;
|
||||
border-radius: 5px;
|
||||
background: none;
|
||||
}
|
||||
.devices {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.devices legend {
|
||||
font-size: 12px;
|
||||
color: #b6bbbe;
|
||||
padding: 0 0 6px;
|
||||
}
|
||||
.devices button {
|
||||
font-size: 12px;
|
||||
border-radius: 0;
|
||||
}
|
||||
.devices button:first-of-type {
|
||||
border-radius: 5px 0 0 5px;
|
||||
}
|
||||
.devices button:last-of-type {
|
||||
border-radius: 0 5px 5px 0;
|
||||
}
|
||||
.devices button[aria-pressed="true"] {
|
||||
background: #e4e8e1;
|
||||
color: #181b16;
|
||||
}
|
||||
.stage-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 15px;
|
||||
background: #232527;
|
||||
padding: 12px 18px;
|
||||
font-size: 12px;
|
||||
color: #adb3b6;
|
||||
}
|
||||
.stage-meta > div {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
#current-name {
|
||||
color: #eef0ec;
|
||||
font-weight: bold;
|
||||
}
|
||||
#dimensions {
|
||||
font-family: Consolas, monospace;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.workspace {
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
padding: 22px;
|
||||
overflow: auto;
|
||||
background: #303335;
|
||||
min-height: 650px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.preview-pane {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.frame-viewport {
|
||||
overflow: auto;
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
background: #202224;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 8px 35px #0003;
|
||||
}
|
||||
iframe {
|
||||
display: block;
|
||||
border: 0;
|
||||
width: 100%;
|
||||
height: 900px;
|
||||
background: white;
|
||||
}
|
||||
.workspace[data-device="tablet"] .frame-viewport {
|
||||
max-width: 768px;
|
||||
}
|
||||
.workspace[data-device="mobile"] .frame-viewport {
|
||||
max-width: 390px;
|
||||
}
|
||||
.workspace[data-device="mobile"] iframe {
|
||||
height: 844px;
|
||||
}
|
||||
.stage-note {
|
||||
font-size: 12px;
|
||||
color: #afb4b7;
|
||||
margin: 0;
|
||||
padding: 13px 18px;
|
||||
background: #202224;
|
||||
}
|
||||
footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
padding: 24px 0;
|
||||
color: #92999e;
|
||||
font-size: 11px;
|
||||
}
|
||||
footer > span:first-child {
|
||||
font-family: Consolas, monospace;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
#notice {
|
||||
position: fixed;
|
||||
bottom: 25px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: #dcf8ad;
|
||||
color: #15210d;
|
||||
border-radius: 5px;
|
||||
padding: 14px 20px;
|
||||
display: none;
|
||||
font-size: 14px;
|
||||
}
|
||||
.skip {
|
||||
position: fixed;
|
||||
top: -100px;
|
||||
background: #dcf8ad;
|
||||
color: black;
|
||||
padding: 15px;
|
||||
z-index: 100;
|
||||
}
|
||||
.skip:focus {
|
||||
top: 5px;
|
||||
}
|
||||
@media (max-width: 1000px) {
|
||||
.intro-copy {
|
||||
max-width: 250px;
|
||||
}
|
||||
.toolbar {
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.mast {
|
||||
padding: 15px;
|
||||
}
|
||||
.brand {
|
||||
font-size: 20px;
|
||||
}
|
||||
.brand > span:last-child {
|
||||
display: none;
|
||||
}
|
||||
.mast-end {
|
||||
gap: 6px;
|
||||
}
|
||||
.mast-end button {
|
||||
font-size: 12px;
|
||||
}
|
||||
main {
|
||||
padding: 0 15px;
|
||||
}
|
||||
.intro {
|
||||
padding-top: 28px;
|
||||
display: block;
|
||||
}
|
||||
.intro-copy {
|
||||
margin-top: 20px;
|
||||
font-size: 13px;
|
||||
max-width: none;
|
||||
}
|
||||
.toolbar {
|
||||
padding: 12px;
|
||||
}
|
||||
.toolbar label {
|
||||
flex: 1;
|
||||
min-width: 75px;
|
||||
}
|
||||
.toolbar select {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.workspace {
|
||||
padding: 10px;
|
||||
}
|
||||
.stage-meta {
|
||||
padding: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
#current-desc {
|
||||
display: none;
|
||||
}
|
||||
footer {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.stage-note {
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
:root {
|
||||
--scroll-track: #202426;
|
||||
--scroll-thumb: #7a898e;
|
||||
scrollbar-gutter: stable;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--scroll-thumb) var(--scroll-track);
|
||||
}
|
||||
* {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--scroll-thumb) var(--scroll-track);
|
||||
}
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--scroll-track);
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--scroll-thumb);
|
||||
border: 2px solid var(--scroll-track);
|
||||
border-radius: 8px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #b4c6c3;
|
||||
}
|
||||
::-webkit-scrollbar-corner {
|
||||
background: var(--scroll-track);
|
||||
}
|
||||
.workspace {
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
.intro {
|
||||
padding: 28px 0 24px;
|
||||
}
|
||||
.intro-copy {
|
||||
max-width: 42ch;
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
import { concepts, tokensFor, cssVars } from "../concepts/registry.js";
|
||||
const $ = (s) => document.querySelector(s);
|
||||
const design = concepts[0];
|
||||
const defaults = {
|
||||
concept: "dock",
|
||||
page: "dashboard",
|
||||
theme: "light",
|
||||
density: "compact",
|
||||
size: "desktop",
|
||||
locale: "ru",
|
||||
accents: {},
|
||||
};
|
||||
let saved = {};
|
||||
try {
|
||||
saved = JSON.parse(localStorage.getItem("anidev.lab") || "{}") || {};
|
||||
} catch {}
|
||||
const state = {
|
||||
...defaults,
|
||||
...Object.fromEntries(
|
||||
["page", "theme", "density", "size", "locale"].map((k) => [
|
||||
k,
|
||||
saved[k] || defaults[k],
|
||||
]),
|
||||
),
|
||||
accents: {},
|
||||
};
|
||||
if (/^#[0-9a-f]{6}$/i.test(saved.accents?.dock || ""))
|
||||
state.accents.dock = saved.accents.dock;
|
||||
const requested = new URLSearchParams(location.search);
|
||||
const pages = [...$("#page").options].map((o) => o.value);
|
||||
if (pages.includes(requested.get("page"))) state.page = requested.get("page");
|
||||
if (!pages.includes(state.page)) state.page = "dashboard";
|
||||
if (["light", "dark"].includes(requested.get("theme")))
|
||||
state.theme = requested.get("theme");
|
||||
if (!["light", "dark"].includes(state.theme)) state.theme = "light";
|
||||
if (!["compact", "normal", "relaxed"].includes(state.density))
|
||||
state.density = "compact";
|
||||
if (!["desktop", "tablet", "mobile"].includes(state.size))
|
||||
state.size = "desktop";
|
||||
if (!["ru", "en"].includes(state.locale)) state.locale = "ru";
|
||||
const strings = {
|
||||
page: ["Экран", "Page"],
|
||||
theme: ["Тема", "Theme"],
|
||||
accent: ["Акцент", "Accent"],
|
||||
density: ["Плотность", "Density"],
|
||||
viewport: ["Размер", "Viewport"],
|
||||
note: [
|
||||
"Демонстрационные данные · Изменения сохраняются только в этом браузере · Ctrl/⌘ K — команды",
|
||||
"Demo data · Changes are stored in this browser only · Ctrl/⌘ K — commands",
|
||||
],
|
||||
research: ["Исследование и решения", "Research & decisions"],
|
||||
status: ["Dock · утверждённый дизайн", "Dock · approved design"],
|
||||
};
|
||||
function render() {
|
||||
const en = state.locale === "en";
|
||||
document.documentElement.lang = state.locale;
|
||||
for (const key of ["page", "theme", "density"])
|
||||
$("#" + key).value = state[key];
|
||||
$("#workspace").dataset.device = state.size;
|
||||
$("#accent").value =
|
||||
state.accents.dock ||
|
||||
(state.theme === "dark" ? design.darkAccent : design.accent);
|
||||
$("#current-name").textContent = design.name;
|
||||
$("#current-desc").textContent = en ? design.descEn : design.desc;
|
||||
$("#dimensions").textContent = {
|
||||
desktop: en ? "Desktop / fluid" : "Desktop / по ширине",
|
||||
tablet: "768 × 900",
|
||||
mobile: "390 × 844",
|
||||
}[state.size];
|
||||
document
|
||||
.querySelectorAll("[data-size]")
|
||||
.forEach((b) =>
|
||||
b.setAttribute("aria-pressed", b.dataset.size === state.size),
|
||||
);
|
||||
document
|
||||
.querySelectorAll("[data-i]")
|
||||
.forEach((e) => (e.textContent = strings[e.dataset.i][en ? 1 : 0]));
|
||||
$("#locale").textContent = en ? "RU" : "EN";
|
||||
$("#export").textContent = en ? "Export system" : "Экспорт системы";
|
||||
$("h1").textContent = "Dock";
|
||||
$(".intro-copy").textContent = en
|
||||
? "The Anidev interface system. Components, states and working patterns."
|
||||
: "Система интерфейсов Anidev. Компоненты, состояния и рабочие сценарии.";
|
||||
const labels = en
|
||||
? [
|
||||
"Dashboard",
|
||||
"Users",
|
||||
"Settings",
|
||||
"Authentication",
|
||||
"Components",
|
||||
"Tokens",
|
||||
"Account",
|
||||
"Security",
|
||||
"Devices and sessions",
|
||||
"Applications",
|
||||
"Appearance",
|
||||
"Sign-in states",
|
||||
]
|
||||
: [
|
||||
"Dashboard",
|
||||
"Пользователи",
|
||||
"Настройки",
|
||||
"Авторизация",
|
||||
"Компоненты",
|
||||
"Токены",
|
||||
"Аккаунт",
|
||||
"Безопасность",
|
||||
"Устройства и сеансы",
|
||||
"Приложения",
|
||||
"Оформление",
|
||||
"Состояния входа",
|
||||
];
|
||||
[...$("#page").options].forEach((o, i) => (o.text = labels[i]));
|
||||
[...$("#theme").options].forEach(
|
||||
(o, i) => (o.text = (en ? ["Light", "Dark"] : ["Светлая", "Тёмная"])[i]),
|
||||
);
|
||||
[...$("#density").options].forEach(
|
||||
(o, i) =>
|
||||
(o.text = (
|
||||
en
|
||||
? ["Normal", "Compact", "Relaxed"]
|
||||
: ["Обычная", "Компактная", "Свободная"]
|
||||
)[i]),
|
||||
);
|
||||
const params = new URLSearchParams({
|
||||
concept: "dock",
|
||||
page: state.page,
|
||||
theme: state.theme,
|
||||
density: state.density,
|
||||
locale: state.locale,
|
||||
});
|
||||
if (state.accents.dock) params.set("accent", state.accents.dock);
|
||||
const src = "frame.html?" + params;
|
||||
if ($("#preview-a").getAttribute("src") !== src) $("#preview-a").src = src;
|
||||
try {
|
||||
localStorage.setItem("anidev.lab", JSON.stringify(state));
|
||||
} catch {}
|
||||
}
|
||||
for (const key of ["page", "theme", "density"])
|
||||
$("#" + key).addEventListener("change", (e) => {
|
||||
state[key] = e.target.value;
|
||||
render();
|
||||
});
|
||||
$("#accent").addEventListener("change", (e) => {
|
||||
state.accents.dock = e.target.value;
|
||||
render();
|
||||
});
|
||||
document.querySelectorAll("[data-size]").forEach(
|
||||
(b) =>
|
||||
(b.onclick = () => {
|
||||
state.size = b.dataset.size;
|
||||
render();
|
||||
}),
|
||||
);
|
||||
$("#locale").onclick = () => {
|
||||
state.locale = state.locale === "ru" ? "en" : "ru";
|
||||
render();
|
||||
};
|
||||
|
||||
function notice(text) {
|
||||
$("#notice").textContent = text;
|
||||
$("#notice").style.display = "block";
|
||||
setTimeout(() => ($("#notice").style.display = "none"), 4500);
|
||||
}
|
||||
// Uncompressed ZIP, UTF-8 filenames, CRC32: no runtime or export dependency.
|
||||
function zip(files) {
|
||||
const enc = new TextEncoder();
|
||||
let offset = 0;
|
||||
const chunks = [],
|
||||
central = [];
|
||||
const u16 = (v, n) => {
|
||||
v.push(n & 255, (n >>> 8) & 255);
|
||||
},
|
||||
u32 = (v, n) => {
|
||||
u16(v, n);
|
||||
u16(v, n >>> 16);
|
||||
};
|
||||
for (const [name, content] of Object.entries(files)) {
|
||||
const bytes = enc.encode(content),
|
||||
nb = enc.encode(name);
|
||||
let crc = -1;
|
||||
for (const b of bytes) {
|
||||
crc ^= b;
|
||||
for (let k = 0; k < 8; k++)
|
||||
crc = (crc >>> 1) ^ (crc & 1 ? 0xedb88320 : 0);
|
||||
}
|
||||
crc = (crc ^ -1) >>> 0;
|
||||
const h = [];
|
||||
u32(h, 0x04034b50);
|
||||
u16(h, 20);
|
||||
u16(h, 0x800);
|
||||
u16(h, 0);
|
||||
u16(h, 0);
|
||||
u16(h, 0);
|
||||
u32(h, crc);
|
||||
u32(h, bytes.length);
|
||||
u32(h, bytes.length);
|
||||
u16(h, nb.length);
|
||||
u16(h, 0);
|
||||
h.push(...nb);
|
||||
chunks.push(new Uint8Array(h), bytes);
|
||||
const c = [];
|
||||
u32(c, 0x02014b50);
|
||||
u16(c, 20);
|
||||
u16(c, 20);
|
||||
u16(c, 0x800);
|
||||
u16(c, 0);
|
||||
u16(c, 0);
|
||||
u16(c, 0);
|
||||
u32(c, crc);
|
||||
u32(c, bytes.length);
|
||||
u32(c, bytes.length);
|
||||
u16(c, nb.length);
|
||||
u16(c, 0);
|
||||
u16(c, 0);
|
||||
u16(c, 0);
|
||||
u16(c, 0);
|
||||
u32(c, 0);
|
||||
u32(c, offset);
|
||||
c.push(...nb);
|
||||
central.push(new Uint8Array(c));
|
||||
offset += h.length + bytes.length;
|
||||
}
|
||||
const size = central.reduce((n, c) => n + c.length, 0),
|
||||
end = [];
|
||||
u32(end, 0x06054b50);
|
||||
u16(end, 0);
|
||||
u16(end, 0);
|
||||
u16(end, central.length);
|
||||
u16(end, central.length);
|
||||
u32(end, size);
|
||||
u32(end, offset);
|
||||
u16(end, 0);
|
||||
return new Blob([...chunks, ...central, new Uint8Array(end)], {
|
||||
type: "application/zip",
|
||||
});
|
||||
}
|
||||
$("#export").onclick = async () => {
|
||||
const button = $("#export");
|
||||
button.disabled = true;
|
||||
try {
|
||||
const c = concepts.find((c) => c.id === state.concept),
|
||||
accent =
|
||||
state.accents[c.id] ||
|
||||
(state.theme === "dark" ? c.darkAccent || c.accent : c.accent);
|
||||
const files = {};
|
||||
const paths = [
|
||||
"components/system.css",
|
||||
"components/account-pages.js",
|
||||
"patterns/demo-identity.js",
|
||||
"concepts/registry.js",
|
||||
"playground/frame.html",
|
||||
"playground/frame.js",
|
||||
"tokens/schema.json",
|
||||
"components/CONTRACT.md",
|
||||
"patterns/UX.md",
|
||||
"patterns/IDENTITY.md",
|
||||
"prompts/SSO.md",
|
||||
"prompts/README.md",
|
||||
"layouts/README.md",
|
||||
"DESIGN.md",
|
||||
"ANTI-SLOP.md",
|
||||
];
|
||||
const fetched = await Promise.all(
|
||||
paths.map(async (p) => {
|
||||
const r = await fetch("../" + p);
|
||||
if (!r.ok) throw Error(p);
|
||||
return [p, await r.text()];
|
||||
}),
|
||||
);
|
||||
for (const [p, t] of fetched) files[p] = t;
|
||||
for (const theme of ["light", "dark"]) {
|
||||
const tokens = tokensFor(
|
||||
c.id,
|
||||
theme,
|
||||
state.accents[c.id] || undefined,
|
||||
state.density,
|
||||
);
|
||||
files[`tokens/${theme}.json`] = JSON.stringify(tokens, null, 2);
|
||||
files[`tokens/${theme}.css`] = `:root {\n${cssVars(tokens)}\n}\n`;
|
||||
}
|
||||
files["selection.json"] = JSON.stringify(
|
||||
{
|
||||
version: "0.1.0",
|
||||
status: "approved-design",
|
||||
concept: c.id,
|
||||
page: state.page,
|
||||
accent,
|
||||
customAccent: state.accents[c.id] || null,
|
||||
density: state.density,
|
||||
theme: state.theme,
|
||||
locale: state.locale,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
);
|
||||
const exportParams = new URLSearchParams({
|
||||
concept: c.id,
|
||||
page: state.page,
|
||||
density: state.density,
|
||||
theme: state.theme,
|
||||
locale: state.locale,
|
||||
});
|
||||
if (state.accents[c.id]) exportParams.set("accent", state.accents[c.id]);
|
||||
files["index.html"] =
|
||||
`<!doctype html><meta charset="utf-8"><title>Anidev ${c.name}</title><script>location.replace('playground/frame.html?${exportParams}')<\/script>`;
|
||||
files["README.md"] =
|
||||
`# Anidev / ${c.name}\nApproved Dock design.\nServe this folder over HTTP (for example python -m http.server 8080).\nOpen index.html.\nUse tokens/light.css or tokens/dark.css and components/system.css in any framework.\nSemantic token JSON is the source of values.\nNo upstream implementation is bundled. Reusable Skill packaging is tracked separately.\n`;
|
||||
const url = URL.createObjectURL(zip(files)),
|
||||
a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `anidev-${c.id}.zip`;
|
||||
a.click();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 30000);
|
||||
notice(
|
||||
state.locale === "ru"
|
||||
? "Экспортирована дизайн-система: " + c.name
|
||||
: "Design system exported: " + c.name,
|
||||
);
|
||||
} catch (e) {
|
||||
notice("Export error: " + e.message);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
};
|
||||
render();
|
||||
|
||||
addEventListener("message", (event) => {
|
||||
if (
|
||||
event.origin === location.origin &&
|
||||
event.source === $("#preview-a").contentWindow &&
|
||||
event.data?.type === "anidev-theme" &&
|
||||
["light", "dark"].includes(event.data.theme)
|
||||
) {
|
||||
state.theme = event.data.theme;
|
||||
render();
|
||||
}
|
||||
});
|
||||
+6
-100
@@ -2,107 +2,13 @@
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Anidev — Design System</title>
|
||||
<link rel="stylesheet" href="gallery.css" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>Anidev</title>
|
||||
<script>
|
||||
location.replace("../" + location.search + location.hash);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a class="skip" href="#workspace">К предпросмотру</a>
|
||||
<header class="mast">
|
||||
<a class="brand" href="./"
|
||||
><span class="mark">a/</span> anidev <span>design system</span></a
|
||||
>
|
||||
<div class="mast-end">
|
||||
<button id="locale">EN</button
|
||||
><button id="export" class="export">Экспорт системы</button>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<section class="intro">
|
||||
<div>
|
||||
<p class="eyebrow">ANIDEV DESIGN SYSTEM</p>
|
||||
<h1>Dock</h1>
|
||||
</div>
|
||||
<p class="intro-copy">
|
||||
Система интерфейсов Anidev. Компоненты, состояния и рабочие сценарии.
|
||||
</p>
|
||||
</section>
|
||||
<section class="lab" aria-label="Дизайн-система Dock">
|
||||
<div class="toolbar">
|
||||
<label
|
||||
><span data-i="page">Экран</span
|
||||
><select id="page">
|
||||
<option value="dashboard">Dashboard</option>
|
||||
<option value="users">Пользователи</option>
|
||||
<option value="settings">Настройки</option>
|
||||
<option value="auth">Авторизация</option>
|
||||
<option value="components">Компоненты</option>
|
||||
<option value="tokens">Токены</option>
|
||||
<option value="profile">Аккаунт</option>
|
||||
<option value="security">Безопасность</option>
|
||||
<option value="sessions">Устройства и сеансы</option>
|
||||
<option value="applications">Приложения</option>
|
||||
<option value="appearance">Оформление</option>
|
||||
<option value="identity">Состояния входа</option>
|
||||
</select></label
|
||||
><label
|
||||
><span data-i="theme">Тема</span
|
||||
><select id="theme">
|
||||
<option value="light">Светлая</option>
|
||||
<option value="dark">Тёмная</option>
|
||||
</select></label
|
||||
><label
|
||||
><span data-i="accent">Акцент</span
|
||||
><input
|
||||
type="color"
|
||||
id="accent"
|
||||
aria-label="Акцентный цвет" /></label
|
||||
><label
|
||||
><span data-i="density">Плотность</span
|
||||
><select id="density">
|
||||
<option value="normal">Обычная</option>
|
||||
<option value="compact">Компактная</option>
|
||||
<option value="relaxed">Свободная</option>
|
||||
</select></label
|
||||
>
|
||||
<fieldset class="devices">
|
||||
<legend data-i="viewport">Размер</legend>
|
||||
<button data-size="desktop" aria-pressed="true">Desktop</button
|
||||
><button data-size="tablet" aria-pressed="false">Tablet</button
|
||||
><button data-size="mobile" aria-pressed="false">Mobile</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="stage-meta">
|
||||
<div>
|
||||
<span id="current-name">Dock</span><span id="current-desc"></span>
|
||||
</div>
|
||||
<span id="dimensions">1440 × 900</span>
|
||||
</div>
|
||||
<div class="workspace" id="workspace" tabindex="-1">
|
||||
<div class="preview-pane">
|
||||
<div class="frame-heading" id="heading-a"></div>
|
||||
<div class="frame-viewport">
|
||||
<iframe
|
||||
id="preview-a"
|
||||
title="Anidev Dock"
|
||||
src="frame.html?concept=dock"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="stage-note" data-i="note">
|
||||
Демонстрационные данные · Изменения сохраняются только в этом браузере
|
||||
· Ctrl/⌘ K — команды
|
||||
</p>
|
||||
</section>
|
||||
<footer>
|
||||
<span>ANIDEV / SYSTEMS WITH CHARACTER</span
|
||||
><a href="../references/RESEARCH.md" data-i="research"
|
||||
>Исследование и решения</a
|
||||
><span data-i="status">Dock · утверждённый дизайн</span>
|
||||
</footer>
|
||||
</main>
|
||||
<div id="notice" role="status"></div>
|
||||
<script type="module" src="gallery.js"></script>
|
||||
<a href="../">Открыть Anidev</a>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user