From f6fdcc18ed8fa265183f97d210588332abbbae66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 27 Nov 2026 18:39:05 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20design/ds.ts=20builds=20the?= =?UTF-8?q?=20design-system=20artifact=20folder=20from=20tokens.toml,=20pa?= =?UTF-8?q?rts.css,=20parts.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/design/ds.ts | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 crates/client/design/ds.ts diff --git a/crates/client/design/ds.ts b/crates/client/design/ds.ts new file mode 100644 index 0000000..0c68e4b --- /dev/null +++ b/crates/client/design/ds.ts @@ -0,0 +1,70 @@ +import tokens from "./tokens.toml"; +import { mkdirSync, copyFileSync } from "node:fs"; + +const out = process.argv[2] + "/project/"; +const put = (path: string, text: string) => Bun.write(out + path, text); +const px = (v: number) => `${v}px`; +const themes = Object.keys(tokens.theme); +const NOTES: Record = { + ground: "The ink everything sits on. Page and panels.", + raise: "Popovers and sheets lifted off the ground.", + hov: "Hover under a control.", + press: "Pressed or on control behind an icon.", + thread: "Lines that separate: rows, popover edge, empty track.", + off: "A quiet voice line: present, not speaking.", + faint: "Section labels, idle chevrons, off toggles.", + dim: "Secondary text and idle icons.", + paper: "Text and primary marks.", + bad: "A frayed line: loss, lag, danger. Only past a threshold.", +}; +const colors = Object.keys(NOTES).map(name => ({ name, value: Object.fromEntries(themes.map(t => [t, tokens.theme[t][name]])), usage: NOTES[name] })); +const hues = (tokens.hues as string[]).map((hue, i) => ({ name: `h-${hue}`, value: Object.fromEntries(themes.map(t => [t, tokens.theme[t].hue[i]])), usage: `A person's line and name when they pick ${hue}. Life, never chrome.` })); +const list = (scale: string, unit: (v: number) => string) => ({ tokens: Object.entries(tokens[scale]).map(([name, value]) => ({ name: `${scale}-${name}`, value: unit(value as number), usage: `tokens.toml [${scale}] ${name}` })) }); +const weights = [["Regular", 400], ["Medium", 500], ["SemiBold", 600], ["Bold", 700]] as const; +const styles = Object.entries(tokens.text).map(([name, size]) => ({ name: `t-${name}`, fontSize: px(size as number), lineHeight: tokens.leading.text, fontWeight: name === "title" || name === "display" ? 600 : 400 })); +const json = { + name: "yumuş", version: 1, + color: { themes: themes.map(id => ({ id, name: id === "gece" ? "Gece" : "Gün" })), tokens: [...colors, ...hues] }, + type: { + fonts: weights.map(([file, weight]) => ({ family: "Onest", file: `fonts/Onest-${file}.ttf`, weight: String(weight) })), + families: { sans: "Onest, sans-serif" }, + groups: [{ name: "Text", family: "sans", styles }], + }, + spacing: list("space", px), radius: list("radius", px), + stroke: list("stroke", px), text: list("text", px), size: list("size", px), leading: list("leading", String), +}; +await put("tokens.json", JSON.stringify(json, null, 2)); +await put("tokens.css", "/* yumuş — generated from tokens.json */\n" + await Bun.file(new URL("./tokens.css", import.meta.url)).text() + + weights.map(([file, weight]) => `@font-face{font-family:Onest;font-weight:${weight};src:url(fonts/Onest-${file}.ttf)}`).join("\n") + "\n"); +await put("components/bundle.css", await Bun.file(new URL("./parts.css", import.meta.url)).text()); +await put("components/bundle.js", `/* @ds-bundle: {"format":4,"namespace":"Yumush","components":[]} */\n` + await Bun.file(new URL("./parts.js", import.meta.url)).text()); +mkdirSync(out + "fonts", { recursive: true }); +for (const [file] of weights) copyFileSync(new URL(`../assets/fonts/Onest-${file}.ttf`, import.meta.url).pathname, out + `fonts/Onest-${file}.ttf`); + +const card = (group: string, height: number, subtitle: string, body: string) => + `\n
\n\n`; +const parts: [string, string, number, string, string, string][] = [ + ["Line", "Lines", 120, "live · quiet · frayed", "parts::voice_line(bands, Voice, t)", + "`
${caption('alice',line('voice',bands(1),'h-amber'))}${caption('bob',line('voice',null,'off'))}${caption('carol',line('frayed',bands(3),'bad'))}
`"], + ["Spark", "Lines", 90, "ping history", "parts::spark(values, slots, color)", + "`
${w('ping','caption-t dim')}
${line('spark',Array.from({length:40},(_,i)=>Math.sin(i*.5)*.3+.5),'paper')}
${w('24 ms','strong')}
`"], + ["Row", "Rows", 150, "label · trailing", "parts::row(label, trailing, t)", + "`
${row('Noise suppression',toggle(true))}${row('A label long enough to be cut before it pushes the control away',toggle(false))}
`"], + ["Toggle", "Rows", 70, "on · off", "parts::toggle(id, on, t, flip)", "`
${toggle(true)}${toggle(false)}
`"], + ["Options", "Rows", 70, "underlined choice", "parts::options(id, items, selected, t, pick)", "opts(['Voice activity','Push to talk'],'Voice activity')"], + ["Track", "Rows", 110, "part · own over total · bad", "parts::track(Fill, bad, t)", + "`
${track(.42)}${track(.09,.31)}${track(.7,null,true)}
`"], + ["Button", "Controls", 70, "plain · danger · primary", "parts::button(id, label, Press, t, click)", + "`
Change source
Stop
Share
`"], + ["IconButton", "Controls", 70, "idle · on · danger · split", "parts::icon_button(id, IconName, tip, Tone, t, click) + parts::chevron", + "`
${icon('mic')}${chev(false)}${icon('camera','on')}${chev(true)}${icon('off','danger')}
`"], + ["Index", "Controls", 130, "selected = brighter + medium", "parts::index_item(id, label, selected, t, click)", + "`
Profile
Voice
Camera & share
`"], + ["Popover", "Surfaces", 230, "raise · thread edge", "parts::popover(t)", + "`
Microphone
${w('Shure MV7')}${w('Laptop mic','dim')}
${line('voice',bands(1),'h-amber')}
${row('Noise suppression',toggle(true))}
`"], +]; +for (const [name, group, height, subtitle, rust, body] of parts) { + await put(`components/${name}/preview.html`, card(group, height, subtitle, body)); + await put(`components/${name}/README.md`, `${name}: \`${rust}\` in \`crates/client/src/gui/parts.rs\`, \`.${name.toLowerCase()}\`-family classes in \`design/parts.css\`. Values come only from tokens; the client gallery (\`YUMUSH_GALLERY=parts:\`) is screenshotted against this card.\n`); +} +await put("components/Cover/preview.html", `\n
\n\n`);