Files
zkxw/docs/mobile-green-palette-demo.html
T
2026-08-12 10:02:31 +08:00

841 lines
28 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>移动端主题绿 · 色板挑选</title>
<style>
:root {
--page-bg: #f4f6f5;
--card: #fff;
--ink: #1a2420;
--muted: #5c6b64;
--line: #e2e8e5;
--current: #0a9f6d;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
background:
radial-gradient(1200px 600px at 10% -10%, #d8f5e8 0%, transparent 55%),
radial-gradient(900px 500px at 100% 0%, #e8f0ff 0%, transparent 50%),
var(--page-bg);
color: var(--ink);
line-height: 1.45;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
header { margin-bottom: 28px; }
header h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.02em; }
header p { margin: 0; color: var(--muted); font-size: 14px; max-width: 720px; }
.toolbar {
display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
margin: 20px 0 8px; padding: 12px 14px; background: rgba(255,255,255,.75);
border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(8px);
}
.toolbar label { font-size: 13px; color: var(--muted); }
.toolbar select, .toolbar input[type="search"] {
height: 36px; border: 1px solid var(--line); border-radius: 8px;
padding: 0 10px; background: #fff; font: inherit; color: var(--ink);
}
.toolbar input[type="search"] { min-width: 200px; }
.chip {
display: inline-flex; align-items: center; gap: 6px;
padding: 4px 10px; border-radius: 999px; font-size: 12px;
background: #ecfdf5; color: #087f57; border: 1px solid #a7f3d0;
}
.chip .sw { width: 12px; height: 12px; border-radius: 3px; background: var(--current); }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 16px;
margin-top: 18px;
}
.card {
background: var(--card);
border: 1px solid var(--line);
border-radius: 16px;
overflow: hidden;
box-shadow: 0 8px 24px rgba(20, 40, 30, .04);
transition: border-color .15s, box-shadow .15s, transform .15s;
cursor: pointer;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(20,40,30,.08); }
.card.is-current { border-color: #94a3b8; outline: 2px dashed #94a3b8; outline-offset: -2px; }
.card.is-selected {
border-color: var(--p, #0a9f6d);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--p) 28%, transparent);
}
.card-top {
display: grid;
grid-template-columns: 1.2fr .8fr .7fr;
height: 72px;
}
.swatch { display: flex; align-items: flex-end; padding: 8px; color: #fff; font-size: 11px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.swatch.soft { color: #1f2a26; text-shadow: none; }
.body { padding: 14px 14px 16px; }
.title-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.title { font-size: 16px; font-weight: 650; margin: 0; }
.tag {
font-size: 11px; padding: 2px 8px; border-radius: 999px;
background: #f1f5f4; color: var(--muted); white-space: nowrap;
}
.tag.hot { background: #fff7ed; color: #c2410c; }
.tag.cool { background: #eff6ff; color: #1d4ed8; }
.tag.fresh { background: #ecfdf5; color: #047857; }
.desc { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); min-height: 36px; }
.tokens { display: grid; gap: 6px; margin-bottom: 12px; }
.token {
display: flex; align-items: center; justify-content: space-between; gap: 8px;
font-size: 12px; padding: 6px 8px; border-radius: 8px; background: #f8faf9;
border: 1px solid #edf2ef;
}
.token code {
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 12px; letter-spacing: .02em;
}
.token button {
border: 0; background: transparent; color: var(--muted); cursor: pointer;
font-size: 11px; padding: 2px 6px; border-radius: 4px;
}
.token button:hover { background: #e8eee9; color: var(--ink); }
.preview {
border: 1px solid var(--line);
border-radius: 12px;
overflow: hidden;
background: #f7faf8;
}
.nav {
height: 40px; display: flex; align-items: center; justify-content: center;
color: #fff; font-size: 13px; font-weight: 600;
background: linear-gradient(135deg, var(--p), var(--d));
}
.preview-body { padding: 12px; display: grid; gap: 8px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
font-size: 11px; padding: 4px 8px; border-radius: 999px;
background: var(--s); color: var(--d); border: 1px solid color-mix(in srgb, var(--p) 25%, white);
}
.btn {
height: 36px; border: 0; border-radius: 999px; color: #fff;
background: var(--p); font-size: 13px; font-weight: 600;
display: flex; align-items: center; justify-content: center;
}
.btn.outline {
background: transparent; color: var(--p);
border: 1.5px solid var(--p);
}
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.soft-block {
padding: 10px; border-radius: 10px; background: var(--s);
color: var(--d); font-size: 12px;
}
.footer-bar {
position: sticky; bottom: 12px; margin-top: 24px;
background: rgba(255,255,255,.92); border: 1px solid var(--line);
border-radius: 14px; padding: 12px 14px;
display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
backdrop-filter: blur(10px);
box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.picked { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.picked .big {
width: 36px; height: 36px; border-radius: 10px;
border: 1px solid rgba(0,0,0,.08);
background: linear-gradient(135deg, var(--fp, #0a9f6d), var(--fd, #087f57));
}
.picked strong { display: block; font-size: 14px; }
.picked span { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button {
height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
background: #fff; cursor: pointer; font: inherit; font-size: 13px;
}
.actions button.primary {
background: var(--fp, #0a9f6d); border-color: transparent; color: #fff; font-weight: 600;
}
.toast {
position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(12px);
background: #1f2a26; color: #fff; padding: 8px 14px; border-radius: 999px;
font-size: 13px; opacity: 0; pointer-events: none; transition: .2s;
z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.section-title {
margin: 28px 0 10px; font-size: 14px; color: var(--muted);
display: flex; align-items: center; gap: 8px;
}
.section-title::after {
content: ""; flex: 1; height: 1px; background: var(--line);
}
@media (max-width: 480px) {
.card-top { height: 56px; }
.toolbar input[type="search"] { min-width: 0; width: 100%; }
}
</style>
</head>
<body>
<div class="wrap">
<header>
<h1>移动端主题绿 · 色板挑选</h1>
<p>
当前工程(mobile-h5 / mobile-oa-h5)主色为三墙绿
<span class="chip"><i class="sw"></i>#0a9f6d / #087f57</span>。
下方每组含主色 / 深绿 / 浅绿底,并有导航、按钮、标签预览。点击卡片选中,点色值可复制。
</p>
<div class="toolbar">
<label>筛选</label>
<select id="filter">
<option value="all">全部</option>
<option value="current">当前</option>
<option value="teal">青绿 / Teal</option>
<option value="jade">翠绿 / Jade</option>
<option value="forest">森绿 / Forest</option>
<option value="mint">薄荷绿 / Mint</option>
<option value="olive">橄榄 / Olive</option>
<option value="deep">更深更沉</option>
<option value="bright">更亮更鲜</option>
</select>
<input id="q" type="search" placeholder="搜名称或色值,如 jade / 0d9488" />
<span class="hint">建议:企业 OA 偏稳重选「森绿 / 青绿」;偏年轻活力选「翠绿 / 亮绿」。</span>
</div>
</header>
<div id="sections"></div>
<div class="footer-bar" id="footer">
<div class="picked">
<div class="big" id="pickedSwatch"></div>
<div>
<strong id="pickedName">未选择</strong>
<span id="pickedHex">点击上方色卡挑选</span>
</div>
</div>
<div class="actions">
<button type="button" id="copyCss">复制 CSS Token</button>
<button type="button" class="primary" id="copyAll">复制主色三件套</button>
</div>
</div>
</div>
<div class="toast" id="toast">已复制</div>
<script>
/**
* 每组:id, name, group, vibe(tag), desc, primary, dark, soft, tags[]
* soft 为浅底;dark 用于渐变末端与强调字色
*/
const PALETTES = [
{
id: 'current',
name: '当前 · 三墙绿',
group: 'current',
vibe: '当前',
tagClass: '',
desc: '现网 mobile-h5 / mobile-oa-h5 主题。稳、偏深,和三墙小程序一致。',
primary: '#0a9f6d',
dark: '#087f57',
soft: '#e9f9f2',
tags: ['current', 'jade', 'deep']
},
{
id: 'admin-mint',
name: '管理端 · Fresh Mint',
group: 'mint',
vibe: '对照',
tagClass: 'cool',
desc: 'web-admin 主色,偏亮薄荷绿。移动端规范一般不混用,仅作对照。',
primary: '#10b981',
dark: '#059669',
soft: '#ecfdf5',
tags: ['mint', 'bright']
},
// —— 青绿 Teal ——
{
id: 'teal-01',
name: '海湾青绿',
group: 'teal',
vibe: '青绿',
tagClass: 'cool',
desc: '偏蓝的青绿,科技感强,适合工具型 OA,和「蔬菜绿」拉开距离。',
primary: '#0d9488',
dark: '#0f766e',
soft: '#f0fdfa',
tags: ['teal', 'cool']
},
{
id: 'teal-02',
name: '深海青',
group: 'teal',
vibe: '青绿',
tagClass: 'cool',
desc: '更深更沉的 teal,导航栏会更稳重,按钮对比度高。',
primary: '#0f766e',
dark: '#115e59',
soft: '#ccfbf1',
tags: ['teal', 'deep']
},
{
id: 'teal-03',
name: '青瓷',
group: 'teal',
vibe: '青绿',
tagClass: 'cool',
desc: '略灰的青瓷感,不抢眼,适合长时间办公阅读。',
primary: '#14b8a6',
dark: '#0d9488',
soft: '#f0fdfa',
tags: ['teal', 'bright']
},
{
id: 'teal-04',
name: '蓝绿松',
group: 'teal',
vibe: '青绿',
tagClass: 'cool',
desc: '略偏蓝,接近 Notion/Linear 一类产品的冷静绿。',
primary: '#2dd4bf',
dark: '#14b8a6',
soft: '#f0fdfa',
tags: ['teal', 'bright']
},
// —— 翠绿 Jade ——
{
id: 'jade-01',
name: '玉翠',
group: 'jade',
vibe: '翠绿',
tagClass: 'fresh',
desc: '比当前色更亮一点,仍是「正绿」,亲和力更好。',
primary: '#059669',
dark: '#047857',
soft: '#ecfdf5',
tags: ['jade', 'bright']
},
{
id: 'jade-02',
name: '翡冷翠',
group: 'jade',
vibe: '翠绿',
tagClass: 'fresh',
desc: '经典 emerald,比 #0a9f6d 略深、更「正」。',
primary: '#047857',
dark: '#065f46',
soft: '#d1fae5',
tags: ['jade', 'deep']
},
{
id: 'jade-03',
name: '青葱',
group: 'jade',
vibe: '翠绿',
tagClass: 'fresh',
desc: '偏黄的鲜绿,更有「新鲜」感,适合生鲜/农业场景。',
primary: '#16a34a',
dark: '#15803d',
soft: '#f0fdf4',
tags: ['jade', 'bright']
},
{
id: 'jade-04',
name: '竹青',
group: 'jade',
vibe: '翠绿',
tagClass: 'fresh',
desc: '中等饱和竹青,介于当前色与亮绿之间。',
primary: '#22c55e',
dark: '#16a34a',
soft: '#f0fdf4',
tags: ['jade', 'bright']
},
{
id: 'jade-05',
name: '叶绿',
group: 'jade',
vibe: '翠绿',
tagClass: 'fresh',
desc: '略偏黄绿,自然、户外感,和「医疗青绿」不同。',
primary: '#4ade80',
dark: '#22c55e',
soft: '#f0fdf4',
tags: ['jade', 'bright']
},
{
id: 'jade-06',
name: '苔藓亮',
group: 'jade',
vibe: '翠绿',
tagClass: 'fresh',
desc: '饱和度高,主按钮很跳;慎用于大面积顶栏。',
primary: '#12b76a',
dark: '#039855',
soft: '#e8faf0',
tags: ['jade', 'bright']
},
// —— 森绿 Forest ——
{
id: 'forest-01',
name: '松针',
group: 'forest',
vibe: '森绿',
tagClass: 'hot',
desc: '深森绿,企业感强,顶栏很稳;浅底用浅绿提亮。',
primary: '#166534',
dark: '#14532d',
soft: '#dcfce7',
tags: ['forest', 'deep']
},
{
id: 'forest-02',
name: '杉木',
group: 'forest',
vibe: '森绿',
tagClass: '',
desc: '比松针稍亮,仍属「深绿色」一档,适合严肃审批流。',
primary: '#15803d',
dark: '#166534',
soft: '#dcfce7',
tags: ['forest', 'deep']
},
{
id: 'forest-03',
name: '墨绿',
group: 'forest',
vibe: '森绿',
tagClass: '',
desc: '偏黑的墨绿,极稳重;移动端大面积使用需注意对比度。',
primary: '#14532d',
dark: '#052e16',
soft: '#bbf7d0',
tags: ['forest', 'deep']
},
{
id: 'forest-04',
name: '柏绿',
group: 'forest',
vibe: '森绿',
tagClass: '',
desc: '略灰的森绿,不那么「鲜」,更像线下物料印刷绿。',
primary: '#3f6212',
dark: '#365314',
soft: '#ecfccb',
tags: ['forest', 'olive', 'deep']
},
// —— 薄荷绿 Mint ——
{
id: 'mint-01',
name: '霜薄荷',
group: 'mint',
vibe: '薄荷',
tagClass: 'fresh',
desc: '浅亮薄荷,年轻清爽;顶栏偏浅时需配深色字。',
primary: '#34d399',
dark: '#10b981',
soft: '#ecfdf5',
tags: ['mint', 'bright']
},
{
id: 'mint-02',
name: '汽水绿',
group: 'mint',
vibe: '薄荷',
tagClass: 'fresh',
desc: '高亮偏青,偏消费级 App;B 端审批可能略跳。',
primary: '#2dd4bf',
dark: '#14b8a6',
soft: '#ccfbf1',
tags: ['mint', 'teal', 'bright']
},
{
id: 'mint-03',
name: '春芽',
group: 'mint',
vibe: '薄荷',
tagClass: 'fresh',
desc: '黄调薄荷,春天感强,和深色字搭配时注意对比。',
primary: '#4ade80',
dark: '#22c55e',
soft: '#f0fdf4',
tags: ['mint', 'bright']
},
{
id: 'mint-04',
name: '淡青',
group: 'mint',
vibe: '薄荷',
tagClass: 'cool',
desc: '低饱和淡青,偏「健康医疗」气质。',
primary: '#5eead4',
dark: '#2dd4bf',
soft: '#f0fdfa',
tags: ['mint', 'teal', 'bright']
},
// —— 橄榄 Olive ——
{
id: 'olive-01',
name: '橄榄绿',
group: 'olive',
vibe: '橄榄',
tagClass: 'hot',
desc: '军绿感克制,独特且不俗;和常见「翠绿」明显区分。',
primary: '#65a30d',
dark: '#4d7c0f',
soft: '#f7fee7',
tags: ['olive', 'bright']
},
{
id: 'olive-02',
name: '苔绿',
group: 'olive',
vibe: '橄榄',
tagClass: 'hot',
desc: '偏黄灰的苔藓绿,自然、沉静。',
primary: '#4d7c0f',
dark: '#3f6212',
soft: '#ecfccb',
tags: ['olive', 'deep']
},
{
id: 'olive-03',
name: '卡其绿',
group: 'olive',
vibe: '橄榄',
tagClass: '',
desc: '低饱和卡其绿,极克制;主按钮可再略提饱和。',
primary: '#84cc16',
dark: '#65a30d',
soft: '#f7fee7',
tags: ['olive', 'bright']
},
{
id: 'olive-04',
name: '茶绿',
group: 'olive',
vibe: '橄榄',
tagClass: '',
desc: '略灰茶绿,偏传统国风,适合政务/传统企业审美。',
primary: '#6b8e23',
dark: '#556b2f',
soft: '#f2f7e8',
tags: ['olive', 'deep']
},
// —— 更多变体 / 品牌向 ——
{
id: 'brand-01',
name: '微信绿邻域',
group: 'jade',
vibe: '对照',
tagClass: 'hot',
desc: '接近微信绿 #07c160,用户熟悉;品牌辨识度一般。',
primary: '#07c160',
dark: '#06ad56',
soft: '#e8faf0',
tags: ['jade', 'bright']
},
{
id: 'brand-02',
name: '钉钉青邻域',
group: 'teal',
vibe: '对照',
tagClass: 'cool',
desc: '偏钉钉青蓝,协作工具感;和生鲜绿差异大。',
primary: '#0089ff',
dark: '#0066cc',
soft: '#e8f3ff',
tags: ['teal', 'bright']
},
{
id: 'brand-03',
name: '飞书绿邻域',
group: 'teal',
vibe: '对照',
tagClass: 'cool',
desc: '偏青绿协作风,冷静专业。',
primary: '#00d6b9',
dark: '#00b5a0',
soft: '#e6fffa',
tags: ['teal', 'mint', 'bright']
},
{
id: 'brand-04',
name: '深翡翠',
group: 'jade',
vibe: '推荐',
tagClass: 'fresh',
desc: '比当前略深、略正,仍是绿系;换主题时改动感适中。',
primary: '#0f9f6e',
dark: '#0b7f57',
soft: '#e6f7f0',
tags: ['jade', 'deep']
},
{
id: 'brand-05',
name: '青玉',
group: 'teal',
vibe: '推荐',
tagClass: 'cool',
desc: '主色略偏青,和当前绿有区分又不跳戏。',
primary: '#0b9e8a',
dark: '#087f6f',
soft: '#e6f8f5',
tags: ['teal']
},
{
id: 'brand-06',
name: '森氧',
group: 'forest',
vibe: '推荐',
tagClass: 'fresh',
desc: '更深一档的品牌绿,顶栏更「重」,按钮仍够绿。',
primary: '#1b7a4e',
dark: '#145c3b',
soft: '#e4f4ec',
tags: ['forest', 'deep']
},
{
id: 'brand-07',
name: '晴绿',
group: 'jade',
vibe: '推荐',
tagClass: 'fresh',
desc: '比当前更亮更干净,适合想「提亮一档」但不换色相。',
primary: '#12a875',
dark: '#0d8a5f',
soft: '#e8f8f1',
tags: ['jade', 'bright']
},
{
id: 'brand-08',
name: '雾绿',
group: 'olive',
vibe: '克制',
tagClass: '',
desc: '降饱和雾绿,高级感;大按钮可再加点饱和。',
primary: '#5b8a72',
dark: '#476e5a',
soft: '#eef4f0',
tags: ['olive', 'deep']
},
{
id: 'brand-09',
name: '孔雀石',
group: 'teal',
vibe: '个性',
tagClass: 'cool',
desc: '偏蓝绿宝石感,辨识度高,适合想和「菜市场绿」拉开。',
primary: '#0e9f8c',
dark: '#0b7d6e',
soft: '#e5f7f4',
tags: ['teal']
},
{
id: 'brand-10',
name: '荧光绿(慎用)',
group: 'mint',
vibe: '个性',
tagClass: 'hot',
desc: '极亮,仅适合强调态;不建议做整站主色。',
primary: '#39ff14',
dark: '#22c55e',
soft: '#f0ffe8',
tags: ['mint', 'bright']
},
{
id: 'brand-11',
name: '北欧松',
group: 'forest',
vibe: '克制',
tagClass: '',
desc: '灰调森绿,北欧家具感,B 端偏设计感。',
primary: '#2f6b4f',
dark: '#24543e',
soft: '#e8f1ec',
tags: ['forest', 'deep']
},
{
id: 'brand-12',
name: '青柠',
group: 'olive',
vibe: '活力',
tagClass: 'hot',
desc: '黄绿偏青柠,活泼;审批严肃页可能略轻松。',
primary: '#84cc16',
dark: '#4d7c0f',
soft: '#f7fee7',
tags: ['olive', 'bright']
}
];
const GROUP_LABEL = {
current: '当前与对照',
teal: '青绿 / Teal',
jade: '翠绿 / Jade',
forest: '森绿 / Forest',
mint: '薄荷绿 / Mint',
olive: '橄榄 / Olive'
};
let selected = null;
function toast(msg) {
const el = document.getElementById('toast');
el.textContent = msg;
el.classList.add('show');
clearTimeout(toast._t);
toast._t = setTimeout(() => el.classList.remove('show'), 1400);
}
async function copyText(text) {
try {
await navigator.clipboard.writeText(text);
toast('已复制:' + text);
} catch {
const ta = document.createElement('textarea');
ta.value = text;
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
toast('已复制:' + text);
}
}
function matchesFilter(p, filter, q) {
if (filter !== 'all') {
if (filter === 'current') {
if (p.id !== 'current' && p.id !== 'admin-mint') return false;
} else if (!p.tags.includes(filter) && p.group !== filter) {
return false;
}
}
if (!q) return true;
const hay = (p.name + p.desc + p.primary + p.dark + p.soft + p.id + p.vibe).toLowerCase();
return hay.includes(q);
}
function render() {
const filter = document.getElementById('filter').value;
const q = document.getElementById('q').value.trim().toLowerCase();
const root = document.getElementById('sections');
root.innerHTML = '';
const list = PALETTES.filter(p => matchesFilter(p, filter, q));
const byGroup = {};
for (const p of list) {
(byGroup[p.group] ||= []).push(p);
}
const order = ['current', 'jade', 'teal', 'forest', 'mint', 'olive'];
for (const g of order) {
const items = byGroup[g];
if (!items || !items.length) continue;
const title = document.createElement('div');
title.className = 'section-title';
title.textContent = GROUP_LABEL[g] || g;
root.appendChild(title);
const grid = document.createElement('div');
grid.className = 'grid';
for (const p of items) {
const card = document.createElement('article');
card.className = 'card' + (p.id === 'current' ? ' is-current' : '') + (selected?.id === p.id ? ' is-selected' : '');
card.style.setProperty('--p', p.primary);
card.style.setProperty('--d', p.dark);
card.style.setProperty('--s', p.soft);
card.innerHTML = `
<div class="card-top">
<div class="swatch" style="background:${p.primary}">主色</div>
<div class="swatch" style="background:${p.dark}">深绿</div>
<div class="swatch soft" style="background:${p.soft}">浅绿底</div>
</div>
<div class="body">
<div class="title-row">
<h3 class="title">${p.name}</h3>
<span class="tag ${p.tagClass || ''}">${p.vibe}</span>
</div>
<p class="desc">${p.desc}</p>
<div class="tokens">
<div class="token"><span>primary</span><span><code data-hex="${p.primary}">${p.primary}</code> <button type="button" data-copy="${p.primary}">复制</button></span></div>
<div class="token"><span>dark</span><span><code data-hex="${p.dark}">${p.dark}</code> <button type="button" data-copy="${p.dark}">复制</button></span></div>
<div class="token"><span>soft</span><span><code data-hex="${p.soft}">${p.soft}</code> <button type="button" data-copy="${p.soft}">复制</button></span></div>
</div>
<div class="preview">
<div class="nav">发起审批</div>
<div class="preview-body">
<div class="pill-row">
<span class="pill">进行中</span>
<span class="pill">已通过</span>
</div>
<div class="soft-block">浅绿底提示条 · 待办 3 项</div>
<div class="btn-row">
<div class="btn">提交</div>
<div class="btn outline">取消</div>
</div>
</div>
</div>
</div>
`;
card.addEventListener('click', (e) => {
if (e.target.closest('[data-copy]')) return;
selectPalette(p);
render();
});
card.querySelectorAll('[data-copy]').forEach(btn => {
btn.addEventListener('click', (e) => {
e.stopPropagation();
copyText(btn.getAttribute('data-copy'));
});
});
grid.appendChild(card);
}
root.appendChild(grid);
}
if (!list.length) {
root.innerHTML = '<p class="hint">没有匹配的色板,试试换个关键词。</p>';
}
}
function selectPalette(p) {
selected = p;
document.getElementById('pickedName').textContent = p.name;
document.getElementById('pickedHex').textContent =
`${p.primary} / ${p.dark} / ${p.soft}`;
const bar = document.getElementById('footer');
bar.style.setProperty('--fp', p.primary);
bar.style.setProperty('--fd', p.dark);
document.getElementById('pickedSwatch').style.background =
`linear-gradient(135deg, ${p.primary}, ${p.dark})`;
}
document.getElementById('filter').addEventListener('change', render);
document.getElementById('q').addEventListener('input', render);
document.getElementById('copyAll').addEventListener('click', () => {
if (!selected) { toast('请先点选一张色卡'); return; }
copyText(`${selected.primary}, ${selected.dark}, ${selected.soft}`);
});
document.getElementById('copyCss').addEventListener('click', () => {
if (!selected) { toast('请先点选一张色卡'); return; }
const css = `/* ${selected.name} */
--brand-green: ${selected.primary};
--brand-green-dark: ${selected.dark};
--brand-green-soft: ${selected.soft};
--van-primary-color: ${selected.primary};`;
copyText(css);
});
// 默认选中当前
selectPalette(PALETTES[0]);
render();
</script>
</body>
</html>