dsh-design-studio 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -1
- package/README.md +3 -1
- package/cordis.patch.yml +4 -0
- package/lib/annotations-row.js +14 -0
- package/lib/annotations.js +214 -0
- package/lib/client.js +320 -27
- package/lib/handoff.js +7 -3
- package/lib/index.js +81 -10
- package/lib/look.js +3 -1
- package/lib/photos.js +9 -0
- package/lib/picker.js +253 -0
- package/lib/serve.js +3 -2
- package/lib/styles.js +203 -0
- package/lib/tool.js +3 -2
- package/locale/annotations/en.json +6 -0
- package/locale/annotations/zh.json +6 -0
- package/package.json +4 -1
- package/skills/ui-design/SKILL.md +5 -3
- package/skills/ui-design/references/annotations.md +64 -0
package/lib/styles.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 风格卡的服务端一份:pick_style 工具用(模型自己定风格时,消费类题目总落回米色暖调)。
|
|
3
|
+
* 和右侧栏 client.js 里的 STYLES、autoStyle 是同一份内容:客户端是单文件、不能 import,
|
|
4
|
+
* 改了要两边一起改,test-client.mjs 会比对。
|
|
5
|
+
*/
|
|
6
|
+
import { contrast, parseColor } from './system.js'
|
|
7
|
+
|
|
8
|
+
const SANS = '"PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif'
|
|
9
|
+
const SERIF = '"Songti SC", "Noto Serif SC", "Source Han Serif SC", serif'
|
|
10
|
+
const ROUND = '"SF Pro Rounded", "PingFang SC", "HarmonyOS Sans SC", system-ui, sans-serif'
|
|
11
|
+
const MONO = '"JetBrains Mono", "SF Mono", Menlo, Consolas, monospace'
|
|
12
|
+
const GROTESK = '"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif'
|
|
13
|
+
export const STYLES = [
|
|
14
|
+
{ id: 'minimal', zh: '极简白', en: 'Minimal', dzh: '大留白、细线、黑白加一点蓝', den: 'Lots of space, hairlines, black and white with a touch of blue',
|
|
15
|
+
c: { bg: '#FAFAF9', surface: '#FFFFFF', text: '#18181B', muted: '#6B6B73', line: '#E4E4E7', primary: '#18181B', accent: '#2563EB', on: '#FFFFFF', link: '#2563EB' },
|
|
16
|
+
head: SANS, w: 600, radius: 10, shadow: '0 1px 2px rgba(24,24,27,.06)',
|
|
17
|
+
nzh: '靠字号和留白分层级,不靠色块;分隔用 1px 细线;蓝色只给链接和选中态;大标题字距收 -0.02em',
|
|
18
|
+
nen: 'Hierarchy from type size and whitespace, not color blocks; 1px hairlines; blue only for links and selection; tighten big headings to -0.02em' },
|
|
19
|
+
{ id: 'warm', zh: '温暖手作', en: 'Warm craft', dzh: '纸感底色、圆润、手绘感', den: 'Paper tones, soft and rounded, hand-made feel',
|
|
20
|
+
c: { bg: '#F6EFE6', surface: '#FFF9F2', text: '#2B1D14', muted: '#6E5A4B', line: '#E7D9C8', primary: '#A9542A', accent: '#5E7A4A', on: '#FFFFFF', link: '#52703F' },
|
|
21
|
+
head: SERIF, w: 600, radius: 16, shadow: '0 8px 24px rgba(120,72,30,.12)',
|
|
22
|
+
nzh: '标题用衬线字,正文无衬线;插画用手绘线条和色块;阴影带暖色;中性色都偏暖,不用纯灰',
|
|
23
|
+
nen: 'Serif headings, sans body; hand-drawn line illustrations and color blocks; warm-tinted shadows; warm neutrals, no pure gray' },
|
|
24
|
+
{ id: 'editorial', zh: '杂志编辑', en: 'Editorial', dzh: '大标题、黑线栅格、红色点题', den: 'Big headlines, black-rule grid, a red accent',
|
|
25
|
+
c: { bg: '#F4F1EA', surface: '#FFFFFF', text: '#111111', muted: '#555555', line: '#111111', primary: '#C8231B', accent: '#111111', on: '#FFFFFF', link: '#C8231B' },
|
|
26
|
+
head: SERIF, w: 700, radius: 2, shadow: 'none',
|
|
27
|
+
nzh: '标题很大、粗细对比强烈;用粗细两种黑线分栏;版式不对称、有留白;红色只在一两处;几乎没有圆角和阴影',
|
|
28
|
+
nen: 'Very large headlines with strong weight contrast; thick and thin black rules for columns; asymmetric layout; red in one or two places only; almost no radius or shadow' },
|
|
29
|
+
{ id: 'dark', zh: '深色高级', en: 'Dark luxe', dzh: '近黑底、香槟金点缀、大图', den: 'Near-black, champagne gold accents, big imagery',
|
|
30
|
+
c: { bg: '#0E0E10', surface: '#18181B', text: '#F2EFE9', muted: '#A19C93', line: '#2C2C30', primary: '#C9A86A', accent: '#E8E2D6', on: '#17140E', link: '#C9A86A' },
|
|
31
|
+
head: SERIF, w: 500, radius: 12, shadow: '0 12px 40px rgba(0,0,0,.45)',
|
|
32
|
+
nzh: '金色只点在关键按钮和细线上;层级靠表面色深浅,不靠阴影;标题细一点、字距放开;留白要多',
|
|
33
|
+
nen: 'Gold only on key buttons and fine lines; layers from surface shades, not shadows; lighter, tracked-out headings; generous space' },
|
|
34
|
+
{ id: 'playful', zh: '活泼年轻', en: 'Playful', dzh: '粗描边、硬阴影、贴纸感', den: 'Thick outlines, hard shadows, sticker feel',
|
|
35
|
+
c: { bg: '#FFF7E8', surface: '#FFFFFF', text: '#1D1B3A', muted: '#5D5A82', line: '#1D1B3A', primary: '#FF6A3D', accent: '#1F9E92', on: '#1D1B3A', link: '#137167' },
|
|
36
|
+
head: ROUND, w: 800, radius: 20, shadow: '4px 4px 0 #1D1B3A',
|
|
37
|
+
nzh: '卡片和按钮 2px 深色描边 + 不模糊的硬阴影;主色按钮上用深色字;元素可以略微倾斜、像贴纸;颜色最多三种',
|
|
38
|
+
nen: '2px dark outlines and hard, unblurred shadows on cards and buttons; dark text on the primary button; slightly tilted sticker-like bits; three colors max' },
|
|
39
|
+
{ id: 'fresh', zh: '清新自然', en: 'Fresh', dzh: '浅绿底、圆角卡片、轻插画', den: 'Pale green, rounded cards, light illustration',
|
|
40
|
+
c: { bg: '#F3F7F2', surface: '#FFFFFF', text: '#1F2A22', muted: '#56665A', line: '#DCE6DA', primary: '#2F7D4F', accent: '#C9962A', on: '#FFFFFF', link: '#2F7D4F' },
|
|
41
|
+
head: SANS, w: 600, radius: 14, shadow: '0 6px 18px rgba(47,125,79,.10)',
|
|
42
|
+
nzh: '大面积浅色、卡片白底;插画用叶子、阳光这类自然元素;黄色只做小点缀;整体轻、透气',
|
|
43
|
+
nen: 'Large light areas with white cards; nature motifs (leaves, sunlight) in illustrations; yellow only as a small accent; light and airy' },
|
|
44
|
+
{ id: 'tech', zh: '专业科技', en: 'Pro / tech', dzh: '冷灰蓝、信息密、数字清楚', den: 'Cool gray-blue, dense info, crisp numbers',
|
|
45
|
+
c: { bg: '#F5F7FB', surface: '#FFFFFF', text: '#0F172A', muted: '#55657D', line: '#E2E8F0', primary: '#2457F5', accent: '#0F8F8E', on: '#FFFFFF', link: '#2457F5' },
|
|
46
|
+
head: SANS, w: 600, radius: 8, shadow: '0 1px 3px rgba(15,23,42,.08)',
|
|
47
|
+
nzh: '信息密度高但对齐严格;数字用等宽(font-variant-numeric: tabular-nums);表格行高 44–48;状态用小色点和标签;主色只给主操作',
|
|
48
|
+
nen: 'Dense but strictly aligned; tabular numbers (font-variant-numeric: tabular-nums); 44–48px table rows; status as small dots and tags; primary color only for the main action' },
|
|
49
|
+
{ id: 'glass', zh: '玻璃质感', en: 'Glass', dzh: '柔光底、浮层毛玻璃', den: 'Soft glow background, frosted overlays',
|
|
50
|
+
c: { bg: '#EAF0F6', surface: '#F7F9FC', text: '#10151C', muted: '#4F5B69', line: '#D5DEE8', primary: '#CC4520', accent: '#2B6CB0', on: '#FFFFFF', link: '#2B6CB0' },
|
|
51
|
+
bgImage: 'radial-gradient(circle at 20% 15%, #FFD9C7 0, transparent 45%), radial-gradient(circle at 85% 70%, #C9E2FF 0, transparent 50%)',
|
|
52
|
+
head: SANS, w: 600, radius: 18, shadow: '0 10px 30px rgba(16,21,28,.10)',
|
|
53
|
+
nzh: '底色加两三团柔和的光斑(别用紫蓝渐变);只有浮层、卡片、标签栏用毛玻璃(半透明白 + backdrop-filter: blur(20px) + 1px 白色描边),正文区是实色;毛玻璃上的字照样要够深',
|
|
54
|
+
nen: 'Two or three soft light blobs on the background (not a purple-blue gradient); frosted glass only on overlays, cards and tab bars (translucent white + backdrop-filter: blur(20px) + 1px white border), solid elsewhere; text on glass stays dark enough' },
|
|
55
|
+
{ id: 'soft', zh: '柔和立体', en: 'Soft UI', dzh: '同色底、凸起凹陷的柔光阴影', den: 'Same-color surfaces with raised and pressed soft shadows',
|
|
56
|
+
c: { bg: '#E9EDF2', surface: '#E9EDF2', text: '#2D3440', muted: '#556072', line: '#D3D9E1', primary: '#3E5BD8', accent: '#22A06B', on: '#FFFFFF', link: '#3E5BD8' },
|
|
57
|
+
head: ROUND, w: 700, radius: 18, shadow: '6px 6px 14px #C8CED6, -6px -6px 14px #FFFFFF',
|
|
58
|
+
nzh: '卡片和底同色,靠一亮一暗两道阴影凸起,按下用内阴影;容易看不清,所以主按钮一定用主色实底、文字够深;别整屏都是凸起',
|
|
59
|
+
nen: 'Cards share the background color and rise with a light and a dark shadow; pressed states use inset shadows; it gets low-contrast fast, so the main button is solid primary with strong text; don\'t make everything raised' },
|
|
60
|
+
{ id: 'guochao', zh: '国潮', en: 'Guochao', dzh: '中国红配金、粗宋体、传统纹样', den: 'Chinese red and gold, bold Song type, traditional patterns',
|
|
61
|
+
c: { bg: '#FBF3E4', surface: '#FFFAF0', text: '#2A1410', muted: '#6F4A3A', line: '#E8D3B5', primary: '#B8202A', accent: '#C8952E', on: '#FFF7E6', link: '#A31D26' },
|
|
62
|
+
head: SERIF, w: 800, radius: 6, shadow: '0 6px 18px rgba(140,30,20,.12)',
|
|
63
|
+
nzh: '中国红的大色块配金色细线;标题用粗宋体,可以竖排;祥云、回纹、印章这类纹样用 SVG 画,只做点缀别铺满;底色是米黄纸色,不用纯白',
|
|
64
|
+
nen: 'Big Chinese-red blocks with fine gold lines; bold Song headings, vertical text allowed; clouds, fret borders and seal stamps drawn in SVG as accents only; rice-paper background, not pure white' },
|
|
65
|
+
{ id: 'ink', zh: '中式雅致', en: 'Ink & paper', dzh: '宣纸底、墨色字、朱砂点缀', den: 'Paper white, ink-black type, a touch of cinnabar',
|
|
66
|
+
c: { bg: '#F5F2EC', surface: '#FBF9F5', text: '#1E1E1C', muted: '#5F5B54', line: '#DAD4C8', primary: '#2F3B37', accent: '#8C2F2B', on: '#F5F2EC', link: '#8C2F2B' },
|
|
67
|
+
head: SERIF, w: 500, radius: 4, shadow: 'none',
|
|
68
|
+
nzh: '大量留白、细线分隔;标题细宋体、字距放开;朱砂红只像印章一样点一两处;插画用浅灰的水墨晕染(SVG 模糊色块),不用照片堆满',
|
|
69
|
+
nen: 'Lots of space and hairline dividers; light Song headings with open tracking; cinnabar red only in one or two seal-like spots; illustrations as pale ink washes (blurred SVG shapes), not photo walls' },
|
|
70
|
+
{ id: 'cyber', zh: '赛博朋克', en: 'Cyberpunk', dzh: '近黑底、品红青色霓虹、等宽字', den: 'Near-black, magenta and cyan neon, monospace',
|
|
71
|
+
c: { bg: '#0B0B16', surface: '#151528', text: '#E9E6FF', muted: '#A09CC8', line: '#2E2B52', primary: '#FF2E88', accent: '#22E1FF', on: '#0B0B16', link: '#22E1FF' },
|
|
72
|
+
head: MONO, w: 700, radius: 2, shadow: '0 0 0 1px #FF2E88, 0 0 18px rgba(255,46,136,.45)',
|
|
73
|
+
nzh: '标题用等宽字、全大写,可以加一点故障错位(两层彩色 text-shadow);边框是 1px 霓虹线加外发光,发光只给主按钮和关键数字;背景可以叠细网格线;正文照样要清楚',
|
|
74
|
+
nen: 'Monospace, all-caps headings with a slight glitch (two colored text-shadows); 1px neon borders with glow, glow only on the main button and key numbers; a fine grid on the background is fine; body text stays readable' },
|
|
75
|
+
{ id: 'cute', zh: '可爱卡通', en: 'Cute', dzh: '粉黄糖果色、大圆角、圆体字', den: 'Candy pink and yellow, big radii, rounded type',
|
|
76
|
+
c: { bg: '#FFF4F6', surface: '#FFFFFF', text: '#3A2540', muted: '#7A5E80', line: '#F3D3DD', primary: '#FF7AA8', accent: '#FFC93C', on: '#3A2540', link: '#C2366F' },
|
|
77
|
+
head: ROUND, w: 800, radius: 24, shadow: '0 6px 0 #F3C4D3',
|
|
78
|
+
nzh: '圆角很大、字胖胖的;按钮像糖果,底下一道同色系的厚阴影;配小动物或角色插画(SVG 简单几何画);粉色和黄色两种就够,主色按钮上用深色字',
|
|
79
|
+
nen: 'Very round corners and chubby type; candy-like buttons with a thick same-hue shadow underneath; small animal or mascot illustrations (simple SVG shapes); pink and yellow are enough; dark text on the primary button' },
|
|
80
|
+
{ id: 'retro', zh: '复古', en: 'Retro', dzh: '焦橙芥末黄墨绿、粗衬线、颗粒感', den: 'Burnt orange, mustard and teal, fat serif, grain',
|
|
81
|
+
c: { bg: '#F3E6CF', surface: '#FBF2E2', text: '#2E1F14', muted: '#6A5240', line: '#DDC7A4', primary: '#B5471D', accent: '#E0A526', on: '#FFF6E8', link: '#2F5D50' },
|
|
82
|
+
head: SERIF, w: 800, radius: 14, shadow: '0 4px 0 #2E1F14',
|
|
83
|
+
nzh: '焦橙、芥末黄、墨绿三色;粗衬线大标题;彩虹条纹、圆形徽章做装饰;底色叠一层很淡的颗粒噪点(SVG feTurbulence);图片调成褪色暖调',
|
|
84
|
+
nen: 'Burnt orange, mustard and teal; fat serif headlines; rainbow stripes and round badges as decoration; a very light grain over the background (SVG feTurbulence); faded warm photos' },
|
|
85
|
+
{ id: 'sale', zh: '电商促销', en: 'Sale', dzh: '红橙主色、大价格、优惠券', den: 'Red-orange, big prices, coupons',
|
|
86
|
+
c: { bg: '#FFF5F0', surface: '#FFFFFF', text: '#1F1A17', muted: '#6B5E57', line: '#F5DDD2', primary: '#CF2E0E', accent: '#FFB800', on: '#FFFFFF', link: '#C2290B' },
|
|
87
|
+
head: SANS, w: 800, radius: 12, shadow: '0 4px 12px rgba(207,46,14,.12)',
|
|
88
|
+
nzh: '价格用大号粗体数字(¥ 小一号),原价灰色划线;「限时」「包邮」这类小标签用色块;优惠券用金黄色、带锯齿边;倒计时醒目;信息多但分区清楚,主按钮通栏',
|
|
89
|
+
nen: 'Prices in big bold numerals (smaller currency sign), old price struck through in gray; small colored tags like "Limited" and "Free shipping"; gold coupons with notched edges; a prominent countdown; dense but clearly sectioned, full-width main button' },
|
|
90
|
+
{ id: 'japandi', zh: '日系原木', en: 'Japandi', dzh: '米色原木、低饱和、小字大留白', den: 'Oat and wood tones, muted, small type and lots of space',
|
|
91
|
+
c: { bg: '#F2EEE6', surface: '#FAF8F3', text: '#2F2B26', muted: '#6B645A', line: '#DDD5C8', primary: '#4F4234', accent: '#8C9A6E', on: '#FAF8F3', link: '#6B4F33' },
|
|
92
|
+
head: SANS, w: 500, radius: 6, shadow: '0 2px 8px rgba(79,66,52,.06)',
|
|
93
|
+
nzh: '像杂货店和家居品牌:字号偏小、字重不重,留白很多;颜色只有米、原木棕、灰绿,饱和度都低;照片柔光、自然材质(木、麻、陶);细线分隔,几乎不用阴影;主按钮深棕实底',
|
|
94
|
+
nen: 'Like a lifestyle or homeware brand: smallish, light type and lots of space; only oat, wood brown and sage, all low saturation; soft-light photos of natural materials (wood, linen, ceramic); hairline dividers, almost no shadow; solid dark-brown main button' },
|
|
95
|
+
{ id: 'swiss', zh: '瑞士网格', en: 'Swiss grid', dzh: '白底黑字红色块、严格网格', den: 'White, black type, red blocks, strict grid',
|
|
96
|
+
c: { bg: '#FFFFFF', surface: '#F1F1F1', text: '#0A0A0A', muted: '#545454', line: '#0A0A0A', primary: '#D9001B', accent: '#0A0A0A', on: '#FFFFFF', link: '#C2001A' },
|
|
97
|
+
head: GROTESK, w: 800, radius: 0, shadow: 'none',
|
|
98
|
+
nzh: '12 栏严格网格、全部左对齐(不居中);标题是超大粗无衬线、字距收紧(-0.03em);红色大色块只用一两处;用数字编号(01 02 03)和粗黑线分区;没有圆角、阴影和渐变',
|
|
99
|
+
nen: 'A strict 12-column grid, everything left-aligned (nothing centered); huge, bold, tightly tracked sans headings (-0.03em); one or two big red blocks; numbered sections (01 02 03) and heavy black rules; no radius, shadow or gradient' },
|
|
100
|
+
{ id: 'brutal', zh: '粗野主义', en: 'Brutalist', dzh: '亮黄底、黑粗框、硬阴影、等宽字', den: 'Bright yellow, thick black borders, hard shadows, monospace',
|
|
101
|
+
c: { bg: '#FFEF5C', surface: '#FFFFFF', text: '#000000', muted: '#3B3B3B', line: '#000000', primary: '#000000', accent: '#FF5C39', on: '#FFEF5C', link: '#1F3FD1' },
|
|
102
|
+
head: MONO, w: 800, radius: 0, shadow: '5px 5px 0 #000000',
|
|
103
|
+
nzh: '卡片和按钮 3px 黑粗边框 + 大偏移的硬阴影(不模糊);标题等宽字、很大;亮黄、白、橙红高饱和撞色;元素可以故意错位、叠放;不用渐变、圆角和柔和阴影;链接带下划线',
|
|
104
|
+
nen: '3px black borders and big unblurred offset shadows on cards and buttons; large monospace headings; loud yellow, white and red-orange blocks; deliberate offsets and overlaps are fine; no gradients, radius or soft shadows; underlined links' },
|
|
105
|
+
{ id: 'cream', zh: '奶油风', en: 'Cream', dzh: '奶白燕麦焦糖、大圆角、柔光', den: 'Milk, oat and caramel, big radii, soft light',
|
|
106
|
+
c: { bg: '#FAF5EE', surface: '#FFFDF9', text: '#3A2F28', muted: '#76675C', line: '#EEE3D5', primary: '#8C5E3C', accent: '#E7C9A6', on: '#FFFFFF', link: '#8A5A36' },
|
|
107
|
+
head: ROUND, w: 700, radius: 22, shadow: '0 10px 30px rgba(140,94,60,.10)',
|
|
108
|
+
nzh: '奶白、燕麦、焦糖三个色;圆角大,多用圆形和胶囊形;阴影又大又淡、带一点暖色;字是深咖啡色不用纯黑;照片和插画柔光、低对比;整体软、暖、安静',
|
|
109
|
+
nen: 'Milk, oat and caramel; big radii, lots of circles and pills; large, faint, warm-tinted shadows; dark coffee text, never pure black; soft, low-contrast photos and illustrations; soft, warm and calm overall' },
|
|
110
|
+
{ id: 'sport', zh: '运动能量', en: 'Sport', dzh: '黑底荧光绿、粗斜体、大数字', den: 'Black with volt green, heavy italics, big numbers',
|
|
111
|
+
c: { bg: '#0E0F11', surface: '#1A1C20', text: '#F4F5F6', muted: '#A1A5AD', line: '#2B2E35', primary: '#C8FF2E', accent: '#FF5A1F', on: '#0E0F11', link: '#C8FF2E' },
|
|
112
|
+
head: SANS, w: 900, radius: 6, shadow: 'none',
|
|
113
|
+
nzh: '标题超粗斜体、全大写、字距收紧;荧光绿只给主按钮、进度和关键数字;配速、心率、卡路里这类数字做得很大(等宽数字);可以用斜切的色块(transform: skewX(-8deg));照片高对比、有动感;橙色只做警示和次要强调',
|
|
114
|
+
nen: 'Heavy italic, all-caps, tightly tracked headings; volt green only on the main button, progress and key numbers; big tabular numbers for pace, heart rate and calories; slanted blocks (transform: skewX(-8deg)) are fine; high-contrast action photos; orange only for alerts and secondary emphasis' },
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
export const AUTO_STYLE = [
|
|
118
|
+
['sport', /跑步|健身|运动|赛事|马拉松|骑行|瑜伽|球馆|\b(runners?|running|fitness|gym|workouts?|sports?|marathons?|cycling|athletes?)\b/i],
|
|
119
|
+
['cyber', /电音|夜店|电竞|游戏|音乐节|livehouse|酒吧|\b(game|gaming|esports?|nightclub|club|rave|festival)\b/i],
|
|
120
|
+
['sale', /促销|大促|双十一|双11|618|秒杀|优惠|团购|外卖|\b(sale|deals?|coupons?|promo|black friday)\b/i],
|
|
121
|
+
['tech', /后台|管理系统|仪表盘|看板|数据|金融|理财|银行|证券|\b(saas|crm|erp|dashboard|admin|analytics|finance|fintech|bank|banking|crypto|b2b|devops|api)\b/i],
|
|
122
|
+
['dark', /奢|高端|珠宝|腕表|名表|红酒|威士忌|私人|黑卡|\b(luxury|premium|jewel|jewelry|jewellery|wristwatch(es)?|timepieces?|wine|whisky|concierge)\b/i],
|
|
123
|
+
['cute', /儿童|幼儿|宠物|猫|狗|萌|甜品|蛋糕|玩具|\b(kids?|children|pets?|cats?|dogs?|puppy|toys?|dessert|candy)\b/i],
|
|
124
|
+
['fresh', /健康|医疗|医院|诊所|户外|露营|母婴|植物|花店|有机|环保|民宿|旅行|旅游|度假|\b(health|medical|clinic|hospital|outdoor|camping|baby|plants?|florist|organic|eco|travel|trip|stays?|vacation|hotel|bnb)\b/i],
|
|
125
|
+
['playful', /奶茶|果茶|饮品|饮料|社交|交友|学生|校园|潮牌|\b(bubble tea|boba|drinks?|smoothie|social|dating|students?|campus|streetwear)\b/i],
|
|
126
|
+
['guochao', /春节|新年|中秋|端午|国潮|老字号|文创|庙会/],
|
|
127
|
+
['retro', /咖啡|黑胶|唱片|市集|古着|理发|面包|\b(vinyl|records?|vintage|barber|bakery|coffee)\b/i],
|
|
128
|
+
['glass', /音乐|播放器|天气|智能家居|\b(music|player|weather|smart home|podcast)\b/i],
|
|
129
|
+
['editorial', /新闻|杂志|博客|阅读|读书|书店|媒体|播客|\b(news|magazine|blog|reading|books?|media|newsletter)\b/i],
|
|
130
|
+
['swiss', /设计工作室|建筑|展览|美术馆|画廊|作品集|\b(agency|studio|architecture|exhibition|gallery|museum|portfolio)\b/i],
|
|
131
|
+
]
|
|
132
|
+
export const AUTO_BY_KIND = { slides: 'swiss', web: 'minimal', desktop: 'tech', email: 'minimal', poster: 'playful', tablet: 'minimal' }
|
|
133
|
+
export const AUTO_SPREAD = ['minimal', 'editorial', 'playful', 'fresh', 'tech', 'glass', 'dark', 'sport']
|
|
134
|
+
// 「北欧风」「清新风:首页…」「中国风的界面」算说了风格;先去掉「通风」「台风」「新风系统」「风控」「风景」这类不是风格的词
|
|
135
|
+
export const NOT_STYLE_FENG = /通风|台风|新风(系统|机|量)|风险|风控|风景|风扇|风味|风暴|风光|风速|风向|风筝|风铃|风车|吹风|防风|挡风|避风|屏风|旋风|狂风|微风|寒风|疾风|顺风|逆风|作风|中风|风湿|风水/g
|
|
136
|
+
export const SAID_STYLE = /风格|配色|色调|主色|色系|[红橙黄绿青蓝紫粉黑白灰棕金银米]色|蓝白|黑白|黑金|红白|绿白|深色|浅色|暗色|亮色|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel|dark|light)\b/i
|
|
137
|
+
export function autoStyle(text, kind) {
|
|
138
|
+
const s = String(text || '')
|
|
139
|
+
if (!s.trim()) return null
|
|
140
|
+
const said = s.replace(NOT_STYLE_FENG, ' ')
|
|
141
|
+
if (SAID_STYLE.test(said) || STYLES.some((x) => said.includes(x.zh) || new RegExp(`\\b${x.en}\\s+(style|look|theme|aesthetic|vibe)\\b`, 'i').test(said))) return null
|
|
142
|
+
return topicStyle(s, kind)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 只按题材和类型挑一张,不管用户说没说风格(说没说由调工具的模型判断) */
|
|
146
|
+
function topicStyle(s, kind) {
|
|
147
|
+
const by = (id) => STYLES.find((x) => x.id === id) || null
|
|
148
|
+
for (const [id, re] of AUTO_STYLE) if (re.test(s)) return by(id)
|
|
149
|
+
if (AUTO_BY_KIND[kind]) return by(AUTO_BY_KIND[kind])
|
|
150
|
+
let n = 0
|
|
151
|
+
for (const ch of s) n = (n * 31 + ch.codePointAt(0)) >>> 0
|
|
152
|
+
return by(AUTO_SPREAD[n % AUTO_SPREAD.length])
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const hexRatio = (a, b) => contrast(parseColor(a), parseColor(b))
|
|
156
|
+
|
|
157
|
+
function accentUse(c, en) {
|
|
158
|
+
if (Math.min(hexRatio(c.accent, c.bg), hexRatio(c.accent, c.surface)) >= 3) return en ? 'graphics and large text only' : '图形、大字'
|
|
159
|
+
if (hexRatio(c.text, c.accent) >= 4.5) return en ? `graphics and color blocks only, not for text; text on those blocks uses ${c.text}` : `只做图形和色块,别拿来写字;色块上的字用 ${c.text}`
|
|
160
|
+
return en ? 'graphics only, not for text' : '只做图形,别拿来写字'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** 一张卡写成给模型看的字(和点风格卡时放进输入框的内容一样全) */
|
|
164
|
+
function cardText(x, en) {
|
|
165
|
+
const c = x.c
|
|
166
|
+
const bgImage = x.bgImage ? (en ? `; on the background: ${x.bgImage}` : `;底色上叠 ${x.bgImage}`) : ''
|
|
167
|
+
return en
|
|
168
|
+
? `${x.en}: ${x.den}\nColors: background ${c.bg}, cards ${c.surface}, text ${c.text}, muted text ${c.muted}, lines ${c.line}, primary ${c.primary} (text on it ${c.on}), accent ${c.accent} (${accentUse(c, true)}), links and small emphasis ${c.link}${bgImage}\nFonts: headings ${x.head} · ${x.w}; body ${SANS}\nShape: radius ${x.radius}px; shadow ${x.shadow}\nNotes: ${x.nen}`
|
|
169
|
+
: `${x.zh}——${x.dzh}\n配色:底色 ${c.bg},卡片 ${c.surface},文字 ${c.text},次要文字 ${c.muted},分隔线 ${c.line},主色 ${c.primary}(上面的字 ${c.on}),点缀 ${c.accent}(${accentUse(c, false)}),链接和小字强调 ${c.link}${bgImage}\n字体:标题 ${x.head} · ${x.w};正文 ${SANS}\n形状:圆角 ${x.radius}px;阴影 ${x.shadow}\n要点:${x.nzh}`
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const hashOf = (s) => { let n = 0; for (const ch of s) n = (n * 31 + ch.codePointAt(0)) >>> 0; return n }
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 按题材挑卡。第一张和首页「风格:自动」挑的一样;要几个方向就往后从不是米色的几张里接着取。
|
|
176
|
+
* 用户定没定风格由模型判断:调了就给卡(自然语言猜不全,猜错了会把用户指定的配色换掉)
|
|
177
|
+
*/
|
|
178
|
+
export function pickStyles(subject, kind, count = 1) {
|
|
179
|
+
const first = topicStyle(String(subject), kind)
|
|
180
|
+
const n = Math.min(3, Math.max(1, Math.floor(Number(count)) || 1))
|
|
181
|
+
const out = [first]
|
|
182
|
+
const start = hashOf(String(subject))
|
|
183
|
+
for (let i = 0; out.length < n && i < AUTO_SPREAD.length; i++) {
|
|
184
|
+
const x = STYLES.find((s) => s.id === AUTO_SPREAD[(start + i) % AUTO_SPREAD.length])
|
|
185
|
+
if (x && !out.includes(x)) out.push(x)
|
|
186
|
+
}
|
|
187
|
+
return out
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** pick_style 工具的返回文字 */
|
|
191
|
+
export function pickStyleText(subject, kind, count = 1) {
|
|
192
|
+
const en = !/[一-鿿]/.test(String(subject))
|
|
193
|
+
const list = pickStyles(subject, kind, count)
|
|
194
|
+
const cards = list.map((x, i) => (list.length > 1 ? `${en ? 'Direction' : '方向'} ${'ABC'[i]}: ` : '') + cardText(x, en)).join('\n\n')
|
|
195
|
+
if (list.length > 1) {
|
|
196
|
+
return en
|
|
197
|
+
? `${cards}\n\nIf the user already chose a specific style or colors, follow them and do not use these cards. Otherwise: each direction keeps its own colors and fonts: write the variables inside that page's own <style>. Create the shared tokens.css only after the user has chosen. Do not swap them for a beige or cream look. Say briefly what style each direction is.`
|
|
198
|
+
: `${cards}\n\n用户已经定了具体风格或配色的话,照用户的来,不用这些卡。否则:每个方向用各自的配色和字体,变量写在各自页面的 <style> 里;用户挑定以后再建公共的 tokens.css。别换成米色、奶油底。用一两句话说清每个方向是什么风格。`
|
|
199
|
+
}
|
|
200
|
+
return en
|
|
201
|
+
? `${cards}\n\nIf the user already chose a specific style or colors, follow them and do not use this card. Otherwise: put these colors and fonts into tokens.css first and build the whole set with them. Do not swap them for a beige or cream look. In your first sentence, tell the user which style you are using; it is easy to change if they do not like it.`
|
|
202
|
+
: `${cards}\n\n用户已经定了具体风格或配色的话,照用户的来,不用这张卡。否则:先把这些配色和字体定进 tokens.css,整套照它做,别换成米色、奶油底。第一句话告诉用户用的是哪个风格,不喜欢可以换。`
|
|
203
|
+
}
|
package/lib/tool.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-design-studio/tool:把 preview_page、check_design、look_design、extract_design_system、handoff_design、compare_design、find_photos 挂给模型。
|
|
2
|
+
* dsh-design-studio/tool:把 preview_page、check_design、look_design、extract_design_system、handoff_design、compare_design、find_photos、pick_style 挂给模型。
|
|
3
3
|
* 放在 bundle 顶层 → 所有模式都能用;放进设计模式 → 只挂在那个模式里。工具本身见 index.js
|
|
4
4
|
*/
|
|
5
|
-
import { previewTool, checkTool, lookTool, systemTool, handoffTool, compareTool, photoTool } from './index.js'
|
|
5
|
+
import { previewTool, checkTool, lookTool, systemTool, handoffTool, compareTool, photoTool, styleTool } from './index.js'
|
|
6
6
|
|
|
7
7
|
export const name = 'dsh-design-studio-tool'
|
|
8
8
|
export const inject = ['tools']
|
|
@@ -16,4 +16,5 @@ export function apply(ctx) {
|
|
|
16
16
|
ctx.tools.register({ ...handoffTool, execute: (args, exec) => handoffTool.execute(args, exec, ctx) })
|
|
17
17
|
ctx.tools.register({ ...compareTool, execute: (args, exec) => compareTool.execute(args, exec, ctx) })
|
|
18
18
|
ctx.tools.register({ ...photoTool })
|
|
19
|
+
ctx.tools.register({ ...styleTool })
|
|
19
20
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Business annotations (experimental)",
|
|
4
|
+
"description": "When on, the model also writes annotations.json with the business rules, states and edge cases the UI does not show, which takes a little longer. The sidebar gains a Notes button: numbered markers on the page, cards on the right, each locating the other. The rules are included when you turn a design into code."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-design-studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1 test/*.mjs"
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"./offline": "./lib/offline.js",
|
|
29
29
|
"./offline/locale/*.json": "./locale/offline/*.json",
|
|
30
30
|
"./offline/icon": "./icon.svg",
|
|
31
|
+
"./annotations": "./lib/annotations-row.js",
|
|
32
|
+
"./annotations/locale/*.json": "./locale/annotations/*.json",
|
|
33
|
+
"./annotations/icon": "./icon.svg",
|
|
31
34
|
"./tool": "./lib/tool.js",
|
|
32
35
|
"./tool/locale/*.json": "./locale/tool/*.json",
|
|
33
36
|
"./tool/icon": "./icon.svg",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
细则只在做那一类时再读。
|
|
35
35
|
|
|
36
|
-
2.
|
|
36
|
+
2. **先写设计变量**:用户没定风格就先调 `pick_style`(见下面「风格卡」)。在设计目录建 `tokens.css`(起手模板 `tokens.css` 就在这个技能目录里,复制过去再按品牌改;有默认的品牌设计系统就复制它的 `tokens.css` 和 `components.css`),颜色、字体、字号阶梯、间距、圆角、阴影都从这里取。每屏都 `<link rel="stylesheet" href="tokens.css">`。之后要统一改风格,改这一个文件,所有屏一起变。
|
|
37
37
|
|
|
38
38
|
3. **一屏一个 HTML 文件,放同一个目录**。新做一套设计时先建这套设计自己的文件夹(英文短名,如 `murmur-landing/`;工作区里已有项目就放在 `design/` 下),`tokens.css`、每一屏都放进去。**不要把文件直接写在工作区最外层**——用户的项目里很可能已经有 `index.html`、`style.css`,会被覆盖。按用户会看的顺序一屏一屏写(画布按创建顺序排:登录 → 首页 → 详情 → …)。文件名用英文小写(`login.html`、`home.html`),`<title>` 写「屏名 · 产品名」,用界面的语言(如「首页 · 梅林练」「Home · Pedal」,每屏的产品名写成一样的):画布上只显示屏名,导出整套展示图时产品名做大标题。临时试验的页面用 `_` 开头(`_test.html`),不会上画布。每屏 `<head>` 里写:
|
|
39
39
|
|
|
@@ -157,11 +157,13 @@
|
|
|
157
157
|
- 没有内容的口号式文案(「赋能」「一站式」「极致体验」)。
|
|
158
158
|
- 什么都往米色 / 奶油底 + 衬线标题 + 砖红或墨绿上靠——这是现在最常撞的「AI 设计」样子。
|
|
159
159
|
|
|
160
|
-
要做的:先想清楚品牌性格(专业 / 温暖 / 活泼 / 高端),据此选**一个**主色 + 中性色 +
|
|
160
|
+
要做的:先想清楚品牌性格(专业 / 温暖 / 活泼 / 高端),据此选**一个**主色 + 中性色 + 一款有性格的标题字体或字重对比;用户没定风格时,调 `pick_style` 拿一张风格卡,照它的配色和字体做;排版要有节奏(大字和小字、密和疏的对比);至少一个记忆点(一个大胆的配色、一张有特色的插画、一个不寻常的版式)。
|
|
161
161
|
|
|
162
162
|
## 风格卡
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
用户没定具体风格时(消息里没有〔风格〕,也没说具体的风格或配色;只说「你定」「帮我推荐一个」「出几个风格挑」都算没定),**开工前先调 `pick_style`**:`subject` 写用户的原话,`kind` 写类型;要先出三个方向时 `count` 填 3,每个方向一张,变量写在各自页面里,用户挑定后才建 tokens.css;只做一套就照返回的配色和字体定进 tokens.css。开工第一句点名(「风格:运动能量」)。别跳过它自己定,自己定基本都会落回米色。
|
|
165
|
+
|
|
166
|
+
下面这张表是换卡用的:用户说不喜欢,就按题材另挑一张。**换卡也先按题材往下挑,别先想米色**:米色暖调的四张(温暖手作、奶油风、日系原木、中式雅致)只在用户点名,或题材离不开(手作、烘焙、茶馆、书店)时才用;民宿、餐饮、电商、SaaS、金融、运动、活动这些题材都有更合适的卡。
|
|
165
167
|
|
|
166
168
|
| 卡 | 样子 | 适合 |
|
|
167
169
|
| --- | --- | --- |
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# 业务标注(annotations.json)
|
|
2
|
+
|
|
3
|
+
只有技能里出现「业务标注」那一节时才写这个文件。内容用用户的语言。
|
|
4
|
+
|
|
5
|
+
## 放哪、什么格式
|
|
6
|
+
|
|
7
|
+
设计目录里的 `annotations.json`,和 `tokens.css` 并排。整个文件是一个对象,也可以直接是数组:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"annotations": [
|
|
12
|
+
{
|
|
13
|
+
"id": "room-03",
|
|
14
|
+
"page": "room.html",
|
|
15
|
+
"type": "rule",
|
|
16
|
+
"title": "价格含双人早餐",
|
|
17
|
+
"detail": "底栏价格是含早价;退订规则见确认订单页。",
|
|
18
|
+
"selector": ".ab-price",
|
|
19
|
+
"anchorLabel": "底栏价格",
|
|
20
|
+
"fallbackText": "含双人早餐",
|
|
21
|
+
"source": "PRD 2.6",
|
|
22
|
+
"tags": ["价格"],
|
|
23
|
+
"related": ["booking-02"],
|
|
24
|
+
"status": "open"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| 字段 | 必填 | 怎么写 |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `id` | 是 | 整份文件不重复,稳定不变。用 `屏名-序号`,比如 `room-03`。中间插一条也别给后面的改号 |
|
|
33
|
+
| `page` | 是 | 这一屏的文件名,比如 `room.html` |
|
|
34
|
+
| `title` | 是 | 一句话说清这条规则 |
|
|
35
|
+
| `type` | 否 | `rule` 业务规则、`state` 状态边界、`logic` 逻辑、`flow` 流程、`metric` 口径 |
|
|
36
|
+
| `detail` | 否 | 正文。可以用换行、`**加粗**`、`` `行内代码` ``、`- ` 列表,别的不认 |
|
|
37
|
+
| `selector` | 否 | 这条对应页面上哪个元素,CSS 选择器 |
|
|
38
|
+
| `anchorLabel` | 否 | 这个区域叫什么,给人看的,比如「底栏价格」 |
|
|
39
|
+
| `fallbackText` | 否 | 这个元素上看得见的字。选择器失效时按它找 |
|
|
40
|
+
| `source` | 否 | 出处,只写真有的,比如 `PRD 2.6` |
|
|
41
|
+
| `tags` | 否 | 字符串数组 |
|
|
42
|
+
| `related` | 否 | 相关标注的 `id` |
|
|
43
|
+
| `status` | 否 | 拿不准、或和需求文档冲突:写 `open`,表示待确认 |
|
|
44
|
+
|
|
45
|
+
`selector` 和 `fallbackText` 都不写,就是这一屏整体的说明。
|
|
46
|
+
|
|
47
|
+
## 写什么
|
|
48
|
+
|
|
49
|
+
- 写界面上看不出来的东西:计算规则、状态怎么变、边界情况、出错和空状态、权限、数据口径。
|
|
50
|
+
- 每屏 3–8 条,挑开发最容易做错的。不复述页面上的字,不写「点击按钮提交订单」这种。
|
|
51
|
+
- 用户给了 PRD 或需求文件:先读,照它写,`source` 记到章节或编号。
|
|
52
|
+
- 没给需求文档:可以按设计里定下的规则写,`source` 留空,别编编号。
|
|
53
|
+
|
|
54
|
+
## 选择器
|
|
55
|
+
|
|
56
|
+
- 用你自己写的语义类名或 id,比如 `.ab-price`、`#agree-btn`。给要标的元素加上类名就行。
|
|
57
|
+
- 别用 `div > div:nth-child(3)` 这种,改版就失效。
|
|
58
|
+
- 要能只匹配到一个元素。列表里的就写第一项,比如 `.room-card:first-child .price`。
|
|
59
|
+
- 写法不合法、找不到,`check_design` 的结果末尾会列出来,顺手改。
|
|
60
|
+
|
|
61
|
+
## 改的时候
|
|
62
|
+
|
|
63
|
+
- 改了设计,同步改对应的标注:元素删了就删这条,类名改了就改 `selector`,规则变了就改 `title` 和 `detail`。
|
|
64
|
+
- 用户说「room-03 改成…」,只改 `id` 对得上的那条。
|