Use the shared Mission Core theme foundation in CMS
DC CMS qualification / qualify (push) Successful in 1m48s
DC CMS qualification / qualify (push) Successful in 1m48s
This commit is contained in:
+2
-2
@@ -324,7 +324,7 @@ input[type=range] {
|
||||
font-size: var(--nodedc-font-size-sm);
|
||||
}
|
||||
.service-media-preview.is-solid-dark {
|
||||
background: #080808;
|
||||
background: var(--nodedc-stage);
|
||||
}
|
||||
.media-upload-error:empty,
|
||||
.media-upload-hint:empty {
|
||||
@@ -581,7 +581,7 @@ dialog.site-dialog p {
|
||||
padding: var(--nodedc-space-2);
|
||||
border-radius: var(--nodedc-radius-card);
|
||||
background: var(--nodedc-canvas);
|
||||
box-shadow: 0 8px 32px #0006;
|
||||
box-shadow: var(--nodedc-glass-dropdown-shadow);
|
||||
}
|
||||
.media-context-menu button {
|
||||
text-align: left;
|
||||
|
||||
+10
-6
@@ -1,20 +1,24 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { flushSync } from "react-dom";
|
||||
import { applyNodedcTheme } from "@nodedc/ui-dom";
|
||||
import { applyNodedcTheme, missionDarkTheme, missionLightTheme, clearNodedcAccent } from "@nodedc/ui-dom";
|
||||
import { UserProfileMenu, 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" };
|
||||
const defaults = { theme: "dark", accent: null };
|
||||
function normalize(value) {
|
||||
return { theme: value?.theme === "light" ? "light" : "dark", accent: /^#[\da-f]{6}$/i.test(value?.accent || "") ? value.accent.toLowerCase() : defaults.accent };
|
||||
return { theme: value?.theme === "light" ? "light" : "dark", accent: /^#[\da-f]{6}$/i.test(value?.accent || "") ? value.accent.toLowerCase() : null };
|
||||
}
|
||||
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" });
|
||||
const accent = preferences.accent?.match(/[\da-f]{2}/gi).map(v => parseInt(v, 16));
|
||||
clearNodedcAccent(document.documentElement);
|
||||
applyNodedcTheme(document.documentElement, { ...(preferences.theme === "light" ? missionLightTheme : missionDarkTheme), accent });
|
||||
}
|
||||
function themeAccent() {
|
||||
return "#" + getComputedStyle(document.documentElement).getPropertyValue("--nodedc-accent-rgb").trim().split(/\s+/).map(v => Number(v).toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
function Preferences({ initial }) {
|
||||
const [preferences, setPreferences] = useState(initial);
|
||||
@@ -43,7 +47,7 @@ function Preferences({ initial }) {
|
||||
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(SettingsCard, { title: "Акцентный цвет", description: "Цвет активных элементов", actions: h("div", { className: "cms-preference-controls" }, h(ColorField, { label: "Акцентный цвет", value: preferences.accent || themeAccent(), onChange: accent => update({ accent }) })) })),
|
||||
h("p", { className: "nodedc-description", role: "status" }, storageError ? "Настройки действуют в этой вкладке. Браузер не разрешил сохранить их для следующего входа." : "Изменения сохраняются автоматически в этом браузере.")
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user