fix(cms): align profile, site navigation and surfaces with design system
DC CMS qualification / qualify (push) Successful in 1m52s

This commit is contained in:
DCCONSTRUCTIONS
2026-11-05 12:34:43 +03:00
parent 8a17013579
commit 73bf4639a2
15 changed files with 225 additions and 150 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+88 -88
View File
File diff suppressed because one or more lines are too long
+2 -1
View File
File diff suppressed because one or more lines are too long
+19
View File
@@ -70,3 +70,22 @@ remain in forms, preserving IDs, names, validation and model serialization.
site settings, switches, SEO selection/save, knowledge editor, file browser,
shared dropdowns, nested dialog Escape, and responsive panel navigation.
- Production acceptance is recorded separately after Git deployment.
## Visual corrections — 2026-11-05
CMS opts into shared `edges: flat`, with a white accent by default. The header
uses UserProfileMenu with the name/avatar from the existing `/api/me` session
and an adjacent settings action. FeatureSettingsWindow contains the shared
Select and ColorField; validated preferences persist in browser-local storage
under `dc-cms.ui-preferences.v1`, independently of either site's content.
The site selector uses shared split/pill presentation and short display labels;
its separate toggle, preview and settings remain independent controls. The
existing Add Block node moves beside Static after each domain navigation render.
All drag listeners stay on their original nodes; only the shared DragHandle SVG
is adopted. Local content surfaces have no decorative outlines. React-owned
color-picker controls are excluded from the legacy DOM adapter.
Verified: dark/light, accent change and reload persistence, reset to white,
nested palette Escape, 390px modal, plus/template picker, pointer drag/reorder
(discarded), switching independent sites, and the shared component/type checks.
+9 -10
View File
@@ -5,7 +5,7 @@ import { readFile, writeFile } from "node:fs/promises";
import { createHash } from "node:crypto";
import { fileURLToPath } from "node:url";
import { build } from "esbuild";
import { AppHeader, HeaderNavigation, HeaderProfile, HeaderAvatar, ApplicationShell, ApplicationPanel, AdminNavigationPanel, Button, IconButton, Icon, StatusBadge, FieldFrame, TextField, Switch, SettingsCard, MediaSourceField } from "@nodedc/ui-react";
import { AppHeader, HeaderNavigation, HeaderProfile, HeaderAvatar, ApplicationShell, ApplicationPanel, AdminNavigationPanel, Button, IconButton, Icon, StatusBadge, FieldFrame, TextField, Switch, SettingsCard, MediaSourceField, DragHandle } from "@nodedc/ui-react";
const h = React.createElement, noop = () => {
}, root = fileURLToPath(new URL("../", import.meta.url));
const read = (p) => readFile(new URL(p, import.meta.url), "utf8");
@@ -21,23 +21,22 @@ const header = h(AppHeader, {
brandMonochrome: true,
left: ib("toggle-navigation", "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0440\u0430\u0437\u0434\u0435\u043B\u044B", "panel"),
center: h(HeaderNavigation, { label: "\u0420\u0430\u0437\u0434\u0435\u043B\u044B CMS", value: "content", onChange: noop, items: [["content", "\u041A\u043E\u043D\u0442\u0435\u043D\u0442"], ["seo", "SEO"], ["knowledge", "\u0411\u0430\u0437\u0430 \u0437\u043D\u0430\u043D\u0438\u0439"]].map(([value, label]) => ({ value, label: h("span", { "data-cms-mode": value }, label) })) }),
right: h(HeaderProfile, null, h("span", null, "CMS"), h(HeaderAvatar, { label: "DC" }))
right: h("span", { id: "cms-profile", className: "cms-ui-island" })
});
const siteContext = h(
"div",
{ className: "cms-site-context" },
h(FieldFrame, { label: "\u0422\u0435\u043A\u0443\u0449\u0438\u0439 \u0441\u0430\u0439\u0442", htmlFor: "site-selector" }, h("select", { id: "site-selector", "aria-label": "\u0422\u0435\u043A\u0443\u0449\u0438\u0439 \u0441\u0430\u0439\u0442" })),
h("div", { className: "cms-site-actions" }, h("a", { id: "site-preview", target: "_blank", rel: "noopener" }, "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0430\u0439\u0442 ", icon("external")), ib("project-settings", "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0441\u0430\u0439\u0442\u0430", "settings")),
const siteContext = h("div", { className: "cms-site-context" },
h("select", { id: "site-selector", "aria-label": "Выбрать сайт" }),
h("a", { id: "site-preview", className: "nodedc-icon-button", "aria-label": "Открыть сайт", title: "Открыть сайт", target: "_blank", rel: "noopener" }, icon("external")),
ib("project-settings", "Настройки сайта", "settings"),
h("span", { id: "workspace-name", hidden: true }, "NODE.DC"),
h("span", { id: "workspace-role", hidden: true }, "\u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0441\u0430\u0439\u0442\u0430"),
h(Button, { id: "add-block", width: "full", icon: icon("plus") }, "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0431\u043B\u043E\u043A")
h("span", { id: "workspace-role", hidden: true }, "Администратор сайта"),
h("span", { id: "cms-add-block-parking", hidden: true }, ib("add-block", "Добавить блок", "plus"))
);
const nav = h(AdminNavigationPanel, { eyebrow: "NODE.DC / CMS", title: h("span", { id: "sidebar-title" }, "\u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435"), headerActions: ib("add-project", "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0430\u0439\u0442", "plus"), contextSlot: siteContext, items: [], onClose: noop, onItemChange: noop });
const actions = h("div", { className: "cms-editor-actions" }, h(StatusBadge, { id: "dirty-state", "data-dirty": "false" }, "\u0421\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u043E"), ib("reload", "\u041F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435", "refresh"), btn("save", "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u043C\u043E\u0434\u0435\u043B\u044C", "primary"), btn("render", "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0441\u0430\u0439\u0442"), h(Button, { id: "publish", className: "hidden", tone: "neutral" }, "\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u0442\u044C"));
const content = h(ApplicationPanel, { eyebrow: h("span", { id: "editor-heading" }, "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0441\u0430\u0439\u0442\u0430"), title: "\u041A\u043E\u043D\u0442\u0435\u043D\u0442", description: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043B", headerTools: actions, expanded: true, onClose: noop }, h("div", { className: "cms-editor", dangerouslySetInnerHTML: { __html: await read("editor.html") } }));
const shell = html(h(ApplicationShell, { id: "cms-shell", header, stage: h("div", { className: "cms-stage" }, h("p", null, "\u0423\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u0430\u0439\u0442\u0430\u043C\u0438 NODE.DC"), btn("open-navigation", "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0440\u0430\u0437\u0434\u0435\u043B\u044B")), navigation: nav, content, navigationOpen: true, contentOpen: true, contentExpanded: true }));
const icons = ["close", "plus", "chevron-up", "chevron-down", "copy", "clipboard", "trash", "eye", "eye-off", "layers", "panel", "file", "settings", "folder", "image", "video", "refresh", "move", "edit"];
const templates = Object.entries({ button: h(Button, null, "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435"), iconButton: h(IconButton, { label: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435" }, icon("plus")), field: h(FieldFrame, { label: "\u041F\u043E\u043B\u0435" }, h("span", { "data-slot": "control" })), text: h(TextField, { id: "template-field", label: "\u041F\u043E\u043B\u0435" }), card: h(SettingsCard, { eyebrow: "\u0420\u0430\u0437\u0434\u0435\u043B", title: "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435", description: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435" }, h("div", { "data-slot": "body" })), media: h(MediaSourceField, { label: "\u041C\u0435\u0434\u0438\u0430", source: "file", url: "", onSourceChange: noop, onUrlChange: noop, onFileChange: noop }), ...Object.fromEntries(icons.map((name) => ["icon-" + name, icon(name)])) }).map(([name, node]) => `<template id="ds-${name}">${html(node)}</template>`).join("\n");
const templates = Object.entries({ dragHandle: h(DragHandle, {label:"Перетащить блок"}), button: h(Button, null, "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435"), iconButton: h(IconButton, { label: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435" }, icon("plus")), field: h(FieldFrame, { label: "\u041F\u043E\u043B\u0435" }, h("span", { "data-slot": "control" })), text: h(TextField, { id: "template-field", label: "\u041F\u043E\u043B\u0435" }), card: h(SettingsCard, { eyebrow: "\u0420\u0430\u0437\u0434\u0435\u043B", title: "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435", description: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435" }, h("div", { "data-slot": "body" })), media: h(MediaSourceField, { label: "\u041C\u0435\u0434\u0438\u0430", source: "file", url: "", onSourceChange: noop, onUrlChange: noop, onFileChange: noop }), ...Object.fromEntries(icons.map((name) => ["icon-" + name, icon(name)])) }).map(([name, node]) => `<template id="ds-${name}">${html(node)}</template>`).join("\n");
const page = `<!doctype html>
<html lang="ru" data-nodedc-ui="true" data-nodedc-theme="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="design-system-commit" content="${lock.sourceCommit}"><title>NODE.DC \u2014 CMS</title><link rel="stylesheet" href="./admin.css"></head><body>${shell}
${await read("modals.html")}
+3 -3
View File
@@ -1,11 +1,11 @@
{
"repository": "https://git.dcserve.ru/SILVER/NODEDC_DESIGN_GUIDELINE.git",
"sourceCommit": "be929f9d8e58f4b99ca14b8bd3794bc2d0bd2be1",
"sourceCommit": "8addef187b316c98751a7d080a7fc37927f9e001",
"distribution": "immutable npm pack artifacts; no copied component sources",
"packages": {
"nodedc-tokens-0.6.0.tgz": "3cfbcec8a10d367688eb1d6e93b774cf2c06b360f465cef6f9866719e5db4616",
"nodedc-ui-react-0.7.0.tgz": "25d41ed3ab27cd6aa958f2b3c564e6491dc8994192570ebccf2cf8834f7312ce",
"nodedc-ui-dom-0.7.0.tgz": "9a5b01a9e2ee42d52ed94184db0297c047c19783fccd44618cc0dc7ac5f9d6df",
"nodedc-ui-core-0.7.0.tgz": "2a1d2392bc023f1b50c7960295d8e80c963834e25ab4c7cb0670b184f37fb7ae"
"nodedc-ui-core-0.7.0-flat.2.tgz": "28942cdc7d5b5adaf45985c96fdddebed7b1cbd57b88b3e0b7cda4328a5f2eaf",
"nodedc-ui-react-0.7.0-flat.2.tgz": "8e6e3e577054954265df3c076b173a343e9db39ae704d8266e6a9a0e55b11829"
}
}
+6 -6
View File
@@ -7,9 +7,9 @@
"name": "dc-cms-ui-build",
"dependencies": {
"@nodedc/tokens": "file:vendor/nodedc-tokens-0.6.0.tgz",
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0.tgz",
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0-flat.2.tgz",
"@nodedc/ui-dom": "file:vendor/nodedc-ui-dom-0.7.0.tgz",
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0.tgz",
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0-flat.2.tgz",
"esbuild": "0.28.1",
"react": "19.2.7",
"react-dom": "19.2.7"
@@ -491,8 +491,8 @@
},
"node_modules/@nodedc/ui-core": {
"version": "0.7.0",
"resolved": "file:vendor/nodedc-ui-core-0.7.0.tgz",
"integrity": "sha512-gL8Za4PKyF+dJQvHHJoo2Mxd26ykNKNsZUoxXY/IGREuDauCRMkR3P9ZSLA0lkDz61LZW6mQixnRykjuCkbRBg==",
"resolved": "file:vendor/nodedc-ui-core-0.7.0-flat.2.tgz",
"integrity": "sha512-/6D9zgu7tBLplf/kwpLtR8fuXWTPr9BnkVIiM/YSic12A0FzVENL3tExGgFWpmgv0E51L8nBXV93/ZjFJVpcrQ==",
"dependencies": {
"@nodedc/tokens": "0.6.0"
}
@@ -507,8 +507,8 @@
},
"node_modules/@nodedc/ui-react": {
"version": "0.7.0",
"resolved": "file:vendor/nodedc-ui-react-0.7.0.tgz",
"integrity": "sha512-mb795gOs0+fQ6mdf7LUNuWMg+VnbN9fNYe/2T1QJSxWEmzEJvOPoPn/yEF/M/2gVAkRX5+O8puYOjc78haw2Dw==",
"resolved": "file:vendor/nodedc-ui-react-0.7.0-flat.2.tgz",
"integrity": "sha512-EsbhCy6VAlSs80TlCow+t7tyHPSME+rd7TZGmtGIBiqSh9t+xKJ5aBwmESsolyP4VyrlhsOsyq2fULhcfXpA2w==",
"dependencies": {
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
+2 -2
View File
@@ -8,9 +8,9 @@
},
"dependencies": {
"@nodedc/tokens": "file:vendor/nodedc-tokens-0.6.0.tgz",
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0.tgz",
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0-flat.2.tgz",
"@nodedc/ui-dom": "file:vendor/nodedc-ui-dom-0.7.0.tgz",
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0.tgz",
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0-flat.2.tgz",
"react": "19.2.7",
"react-dom": "19.2.7",
"esbuild": "0.28.1"
+19 -24
View File
@@ -39,24 +39,18 @@ p {
}
.cms-site-context {
display: grid;
gap: var(--nodedc-space-3);
}
.cms-site-actions {
display: flex;
grid-template-columns: minmax(0, 1fr) auto auto;
align-items: center;
justify-content: space-between;
gap: var(--nodedc-space-2);
gap: var(--nodedc-space-1);
}
.cms-site-actions > a {
display: inline-flex;
align-items: center;
gap: var(--nodedc-space-2);
font-size: var(--nodedc-font-size-sm);
text-decoration: none;
color: var(--nodedc-text-secondary);
}
.cms-site-actions > a:hover {
color: var(--nodedc-text-primary);
.cms-site-context > a { text-decoration: none; }
.cms-static-row { display: flex; align-items: center; gap: var(--nodedc-space-1); }
.cms-static-row > .block-btn { flex: 1; min-width: 0; }
.cms-preference-controls { width: 14rem; max-width: 100%; }
.cms-preferences-fields { display: grid; gap: var(--nodedc-space-4); }
@media (max-width: 760px) {
.cms-preferences-fields .nodedc-settings-card__head { flex-direction: column; }
.cms-preference-controls { width: 100%; }
}
.cms-ui-island {
display: block;
@@ -223,7 +217,8 @@ p {
opacity: .35;
}
.sortable-placeholder {
border: 1px dashed var(--nodedc-text-muted);
border: 0;
background: var(--nodedc-panel-item-active-bg);
border-radius: var(--nodedc-radius-card);
}
.sortable-ghost {
@@ -233,7 +228,7 @@ p {
opacity: .85;
}
.drag-over {
outline: 1px solid rgb(var(--nodedc-accent-rgb));
background: var(--nodedc-panel-item-active-bg);
}
.block-btn.has-drag-handle {
user-select: none;
@@ -261,7 +256,7 @@ p {
}
.collection-item-card,
.json-details {
border: 1px solid var(--nodedc-glass-outline);
border: 0;
border-radius: var(--nodedc-radius-card);
padding: var(--nodedc-space-4);
background: var(--nodedc-panel-item-bg);
@@ -470,7 +465,7 @@ dialog.site-dialog p {
display: flex;
overflow: auto;
min-height: 18rem;
border: 1px solid var(--nodedc-glass-outline);
border: 0;
border-radius: var(--nodedc-radius-card);
}
.media-column {
@@ -480,7 +475,7 @@ dialog.site-dialog p {
overflow: auto;
}
.media-column + .media-column {
border-left: 1px solid var(--nodedc-glass-outline);
border-left: 0;
}
.media-column-head {
display: flex;
@@ -599,7 +594,7 @@ dialog.site-dialog p {
text-align: left;
}
.media-drop-zone.drag-over {
outline: 2px dashed rgb(var(--nodedc-accent-rgb));
background: var(--nodedc-panel-item-active-bg);
}
.admin-file-picker-input {
display: none;
@@ -640,11 +635,11 @@ dialog.site-dialog p {
background: var(--nodedc-field-bg);
color: var(--nodedc-text-primary);
line-height: 1.65;
outline: 1px solid var(--nodedc-glass-outline);
outline: 0;
overflow-wrap: anywhere;
}
.knowledge-rich-editor:focus {
outline-color: var(--nodedc-text-muted);
background: var(--nodedc-panel-item-active-bg);
}
.knowledge-rich-editor img {
max-width: 100%;
+18 -15
View File
@@ -3,7 +3,8 @@ import React from "react";
import { createRoot } from "react-dom/client";
import { flushSync } from "react-dom";
import { Select, Switch, RangeControl, ProgressBar, Dropdown, IconButton, Icon, StatusBadge } from "@nodedc/ui-react";
import { applyNodedcTheme, createApplicationWorkspaceController, createModalController } from "@nodedc/ui-dom";
import { installPreferences } from "./preferences.mjs";
import { createApplicationWorkspaceController, createModalController } from "@nodedc/ui-dom";
const h = React.createElement, $ = (s, r = document) => r.querySelector(s), all = (s, r = document) => [...r.querySelectorAll(s)];
const clone = (name) => $(`#ds-${name}`).content.firstElementChild.cloneNode(true);
function addClass(node, name) {
@@ -11,7 +12,7 @@ function addClass(node, name) {
}
const islands = /* @__PURE__ */ new Map();
const modalBindings = [];
let queued = false, observer, fieldNumber = 0;
let queued = false, observer, fieldNumber = 0, addBlockButton;
function schedule() {
if (!queued) {
queued = true;
@@ -37,12 +38,12 @@ function island(control) {
}
function selects() {
for (const control of all("select")) {
const item = island(control), options = [...control.options].map((o) => ({ value: o.value, label: o.textContent, disabled: o.disabled }));
const item = island(control), options = [...control.options].map((o) => ({ value: o.value, label: control.id === "site-selector" ? o.textContent.replace(/^NODE\.?DC\s*[—–-]\s*/i, "") : o.textContent, disabled: o.disabled }));
const label = control.getAttribute("aria-label") || control.closest("label")?.querySelector(".nodedc-field__label")?.textContent || "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435";
const signature = JSON.stringify([control.value, options, control.disabled, label]);
if (signature === item.signature) continue;
item.signature = signature;
flushSync(() => item.root.render(h(Select, { value: control.value, options, label, disabled: control.disabled, onChange: (value) => {
flushSync(() => item.root.render(h(Select, { variant: control.id === "site-selector" ? "split" : "integrated", shape: control.id === "site-selector" ? "pill" : "default", value: control.value, options, label, disabled: control.disabled, onChange: (value) => {
control.value = value;
control.dispatchEvent(new Event("input", { bubbles: true }));
control.dispatchEvent(new Event("change", { bubbles: true }));
@@ -84,7 +85,7 @@ function switches() {
}
function ranges() {
for (const input of all("input[type=range]")) {
if (input.closest(".cms-ui-island")) continue;
if (input.closest(".cms-ui-island,.nodedc-color-palette-surface")) continue;
const item = island(input), field = input.closest(".range-field"), output = field?.querySelector(".range-value");
if (output) output.hidden = true;
const label = field?.querySelector(".field-label-text")?.textContent || "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435";
@@ -181,7 +182,7 @@ function cards() {
const iconById = { "move-up": "chevron-up", "move-down": "chevron-down", duplicate: "copy", copy: "copy", "paste-after": "clipboard", "delete-block": "trash", "template-modal-close": "close", "media-modal-close": "close", "media-trash-toggle": "trash", "media-delete": "trash" };
function buttons() {
for (const button of all("button")) {
if (button.closest(".cms-ui-island") || button.className.includes("nodedc-") || button.matches(".media-entry,.knowledge-tree-select,.service-media-source-button,.service-media-file-button,.media-breadcrumb-button,.template-card")) continue;
if (button.closest(".cms-ui-island,.nodedc-color-palette-surface") || button.className.includes("nodedc-") || button.matches(".media-entry,.knowledge-tree-select,.service-media-source-button,.service-media-file-button,.media-breadcrumb-button,.template-card")) continue;
const iconLike = button.matches(".icon-action-btn,.collection-icon-btn,.knowledge-tree-action,.secret-toggle-button,.collection-drag-handle,.modal-close-button,.media-header-action");
const model = clone(iconLike ? "iconButton" : "button");
addClass(button, model.className);
@@ -189,8 +190,8 @@ function buttons() {
const title = button.getAttribute("aria-label") || button.title || button.textContent;
button.setAttribute("aria-label", title);
button.title = title;
const icon = iconById[button.id] || (button.classList.contains("secret-toggle-button") ? "eye" : /удал/i.test(title) ? "trash" : /добав/i.test(title) ? "plus" : /выше|вверх/i.test(title) ? "chevron-up" : /ниже|вниз/i.test(title) ? "chevron-down" : /коп/i.test(title) ? "copy" : "move");
button.replaceChildren(clone("icon-" + icon));
const icon = iconById[button.id] || (button.classList.contains("secret-toggle-button") ? "eye" : /удал/i.test(title) ? "trash" : /добав/i.test(title) ? "plus" : /выше|вверх|поднять/i.test(title) ? "chevron-up" : /ниже|вниз|опустить/i.test(title) ? "chevron-down" : /коп|дублир/i.test(title) ? "copy" : "move");
button.replaceChildren(button.matches(".collection-drag-handle") ? clone("dragHandle").firstElementChild : clone("icon-" + icon));
} else {
button.dataset.variant = button.matches(".primary-btn,[type=submit]") ? "primary" : button.matches(".danger-btn") ? "danger" : "secondary";
button.dataset.tone = "neutral";
@@ -217,7 +218,7 @@ function navItems() {
addClass(handle, "nodedc-drag-handle");
if (!handle.dataset.dsIcon) {
handle.dataset.dsIcon = "true";
handle.replaceChildren(clone("icon-move"));
handle.replaceChildren(clone("dragHandle").firstElementChild);
}
}
}
@@ -376,11 +377,12 @@ function refresh() {
for (const binding of modalBindings) binding.dialog.inert = Boolean(topModal && binding.overlay !== topModal);
if ($('#delete-modal-body').textContent === 'Вы действительно подтвердить удаление элемента?') $('#delete-modal-body').textContent = 'Удалить выбранный элемент?';
if ($('#delete-modal-confirm').textContent.trim() === 'Да') $('#delete-modal-confirm').textContent = 'Удалить';
const add = $("#add-block"), caption = add?.querySelector(".nodedc-button__content");
if (caption) {
const text = $("#admin-mode-knowledge").dataset.active === "true" ? "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0440\u0430\u0437\u0434\u0435\u043B" : "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0431\u043B\u043E\u043A";
if (caption.lastChild.textContent.trim() !== text) caption.lastChild.textContent = text;
}
const staticItem = $("#regions > section:first-child .block-btn");
if (staticItem) {
let row = staticItem.closest(".cms-static-row");
if (!row) { row = document.createElement("div"); row.className = "cms-static-row"; staticItem.before(row); row.append(staticItem); }
row.append(addBlockButton);
} else if (addBlockButton) $("#cms-add-block-parking").append(addBlockButton);
const dirty = $("#dirty-state");
dirty.dataset.tone = dirty.dataset.dirty === "true" ? "warning" : "neutral";
for (const button of all(".nodedc-header__nav-item")) {
@@ -392,7 +394,8 @@ function refresh() {
}
}
function installDesignSystem() {
applyNodedcTheme(document.documentElement, { theme: "dark" });
installPreferences();
addBlockButton = $("#add-block");
for (const marker of all("[data-cms-mode]")) marker.closest("button").id = "admin-mode-" + marker.dataset.cmsMode;
$(".nodedc-header-navigation").classList.add("nodedc-expanded-nav-group");
$(".nodedc-admin-panel__nav").id = "regions";
+58
View File
@@ -0,0 +1,58 @@
import React, { useEffect, useState } from "react";
import { createRoot } from "react-dom/client";
import { flushSync } from "react-dom";
import { applyNodedcTheme } from "@nodedc/ui-dom";
import { HeaderProfile, UserProfileMenu, IconButton, Icon, FeatureSettingsWindow, SettingsCard, Select, ColorField, Button } from "@nodedc/ui-react";
const h = React.createElement;
const storageKey = "dc-cms.ui-preferences.v1";
const defaults = { theme: "dark", accent: "#ffffff" };
function normalize(value) {
return { theme: value?.theme === "light" ? "light" : "dark", accent: /^#[\da-f]{6}$/i.test(value?.accent || "") ? value.accent.toLowerCase() : defaults.accent };
}
function read() {
try { return normalize(JSON.parse(localStorage.getItem(storageKey))); } catch { return { ...defaults }; }
}
function apply(preferences) {
const accent = preferences.accent.match(/[\da-f]{2}/gi).map(v => parseInt(v, 16));
applyNodedcTheme(document.documentElement, { theme: preferences.theme, accent, edges: "flat" });
}
function Preferences({ initial }) {
const [preferences, setPreferences] = useState(initial);
const [open, setOpen] = useState(false);
const [session, setSession] = useState(null);
const [storageError, setStorageError] = useState(false);
useEffect(() => {
const controller = new AbortController();
fetch("/api/me", { credentials: "same-origin", signal: controller.signal }).then(r => r.ok ? r.json() : null).then(setSession).catch(() => {});
const sync = event => { if (event.key === storageKey || event.key === null) { const value = read(); apply(value); setPreferences(value); } };
window.addEventListener("storage", sync);
return () => { controller.abort(); window.removeEventListener("storage", sync); };
}, []);
function update(patch) {
const value = normalize({ ...preferences, ...patch });
apply(value);
setPreferences(value);
try { localStorage.setItem(storageKey, JSON.stringify(value)); setStorageError(false); } catch { setStorageError(true); }
}
const user = session?.user;
const name = user?.name || user?.username || "Профиль";
const actions = [{ id: "appearance", label: "Настройки интерфейса", icon: "settings", onSelect: () => setOpen(true) }];
if (session?.authEnabled) actions.push({ id: "logout", label: "Выйти", icon: "external", href: "/auth/logout" });
return h(React.Fragment, null,
h(HeaderProfile, null,
h(UserProfileMenu, { displayName: name, subtitle: user?.email || undefined, avatarUrl: user?.picture || undefined, triggerLabel: "Профиль", triggerIcon: "inbox", actions }),
h(IconButton, { label: "Настройки интерфейса", onClick: () => setOpen(true) }, h(Icon, { name: "settings" }))
),
h(FeatureSettingsWindow, { open, title: "Настройки", subtitle: "Интерфейс CMS", identity: { title: name, subtitle: "NODE.DC CMS", avatarLabel: name, avatarUrl: user?.picture || undefined }, sections: [{ id: "appearance", label: "Оформление", icon: "settings", group: "Общие" }], activeSection: "appearance", onSectionChange: () => {}, onClose: () => setOpen(false),
footer: h(Button, { onClick: () => update(defaults), tone: "neutral" }, "Сбросить оформление") },
h("div", {className:"cms-preferences-fields"}, h(SettingsCard, { title: "Тема", description: "Светлый или тёмный интерфейс", actions: h("div", { className: "cms-preference-controls" }, h(Select, { label: "Тема интерфейса", value: preferences.theme, options: [{ value: "dark", label: "Тёмная" }, { value: "light", label: "Светлая" }], onChange: theme => update({ theme }) })) }),
h(SettingsCard, { title: "Акцентный цвет", description: "Цвет активных элементов", actions: h("div", { className: "cms-preference-controls" }, h(ColorField, { label: "Акцентный цвет", value: preferences.accent, onChange: accent => update({ accent }) })) })),
h("p", { className: "nodedc-description", role: "status" }, storageError ? "Настройки действуют в этой вкладке. Браузер не разрешил сохранить их для следующего входа." : "Изменения сохраняются автоматически в этом браузере.")
)
);
}
export function installPreferences() {
const preferences = read();
apply(preferences);
flushSync(() => createRoot(document.querySelector("#cms-profile")).render(h(Preferences, { initial: preferences })));
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.