iter(g243): 文档站与演示页外壳配色改为从令牌派生,消除暗色强调色漂移
This commit is contained in:
+6
-2
@@ -6,6 +6,7 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { createRequire } from 'node:module';
|
||||
import { shellPalette } from '../../packages/tools/cli/lib/shell-palette.mjs'; // 外壳配色与文档站同源:从 tokens.json 派生
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.resolve(__dirname, '..', '..'); // apps/demo 上两级 = 仓库根
|
||||
@@ -34,6 +35,9 @@ const result = await esbuild.build({
|
||||
|
||||
const js = result.outputFiles[0].text.replace(/<\/script>/gi, '<\\/script>'); // 防提前闭合
|
||||
const css = [read('packages/design/tokens/tokens.css'), read('packages/skin/ui/ui.css')].join('\n');
|
||||
// 外壳 chrome 配色从 tokens.json 派生:手写值时改暗色 accent 会让页面外壳与组件各显示一种蓝
|
||||
const tokensPath = path.join(root, 'packages/design/tokens/tokens.json');
|
||||
const shell = shellPalette(fs.existsSync(tokensPath) ? JSON.parse(fs.readFileSync(tokensPath, 'utf8')) : null);
|
||||
|
||||
const html = `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
@@ -43,8 +47,8 @@ const html = `<!DOCTYPE html>
|
||||
<title>@ui-arch 组件库 · 现场演示</title>
|
||||
<style>
|
||||
${css}
|
||||
:root{--page-bg:#ffffff;--page-text:#1c1e21;--page-muted:#6b7280;--page-border:rgba(0,0,0,.14)}
|
||||
:root[data-theme=dark]{--page-bg:#101216;--page-text:#e7e9ec;--page-muted:#888780;--page-border:rgba(255,255,255,.15)}@media (prefers-color-scheme:dark){:root:not([data-theme]){--page-bg:#101216;--page-text:#e7e9ec;--page-muted:#888780;--page-border:rgba(255,255,255,.15)}}
|
||||
:root{--page-bg:${shell.bg};--page-text:${shell.text};--page-muted:${shell.muted};--page-border:${shell.border}}
|
||||
:root[data-theme=dark]{--page-bg:${shell.darkBg};--page-text:${shell.darkText};--page-muted:${shell.darkMuted};--page-border:${shell.darkBorder}}@media (prefers-color-scheme:dark){:root:not([data-theme]){--page-bg:${shell.darkBg};--page-text:${shell.darkText};--page-muted:${shell.darkMuted};--page-border:${shell.darkBorder}}}
|
||||
*{box-sizing:border-box}
|
||||
body{margin:0;background:var(--page-bg);color:var(--page-text);font:14px/1.7 -apple-system,"Segoe UI","Microsoft YaHei",sans-serif}
|
||||
.shell{max-width:1160px;margin:0 auto;padding:36px 20px 80px;display:grid;grid-template-columns:190px minmax(0,1fr);gap:36px}
|
||||
|
||||
Reference in New Issue
Block a user