uisandbox-mcp 0.5.3 → 0.5.5
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.md +7 -2
- package/dist/app/assets/AboutDialog-Br3jPf_r.js +1 -0
- package/dist/app/assets/ExportDialog-CaBWAmSz.js +343 -0
- package/dist/app/assets/index-Ct5e-ani.css +1 -0
- package/dist/app/assets/index-r8w3zdT3.js +454 -0
- package/dist/app/how-it-works-poster.png +0 -0
- package/dist/app/how-it-works.mp4 +0 -0
- package/dist/app/index.html +8 -2
- package/dist/app/kits/antd.zip +0 -0
- package/dist/app/kits/bootstrap.zip +0 -0
- package/dist/app/kits/daisyui.zip +0 -0
- package/dist/app/kits/mantine.zip +0 -0
- package/dist/app/kits/material.zip +0 -0
- package/dist/app/kits/radix.zip +0 -0
- package/dist/app/kits/shadcn.zip +0 -0
- package/dist/app/kits/tailwind.zip +0 -0
- package/dist/server.mjs +410 -78
- package/package.json +1 -1
- package/dist/app/assets/index-CGVVXhFX.css +0 -1
- package/dist/app/assets/index-DIphMm3C.js +0 -796
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ npx tsx mcp/smoke.ts fixtures/x.zip # load → set → export → verify
|
|
|
18
18
|
|
|
19
19
|
| tool | input | returns |
|
|
20
20
|
|---|---|---|
|
|
21
|
+
| `try_designs` | `url?`, `carry?` | **the one call for "let me try some designs"**: finds the user's app (the dev server running on this machine, read from package.json or found on the usual ports; else the build in this folder), opens the sandbox with it live, and returns the id for `wait_for_send`; lists the apps when more than one runs |
|
|
21
22
|
| `load` | `devUrl`, or `zipUrl` / `zipPath` | `devUrl` (e.g. `http://localhost:5173`): a RUNNING dev server, in live mode, no build needed, hot reload passed through; a zip: project id, screens, values, the baseline (brand, fonts, families, palette, canvas, dark mode), or a refusal with the reason |
|
|
22
23
|
| `open` | `id`, `screen?` | **the sandbox itself** in the user's browser: the web app ships in the package and is served from 127.0.0.1 by this process with the archive; what the user turns flows back (`state`) |
|
|
23
24
|
| `state` | `id` | the knobs now, including what was turned by hand in an opened sandbox |
|
|
@@ -30,15 +31,19 @@ npx tsx mcp/smoke.ts fixtures/x.zip # load → set → export → verify
|
|
|
30
31
|
|
|
31
32
|
`load`/`set`/`export`/`state` are pure Node. `open` serves the bundled app on 127.0.0.1 and opens the browser; nothing leaves the machine. `verify`/`screenshot` drive the app in headless Chromium (the bundled one on 127.0.0.1; `UISANDBOX_URL` to point elsewhere) with the archive served from a route inside the browser, so the number an agent gets is the number a visitor gets.
|
|
32
33
|
|
|
33
|
-
The conversation this is built for: *"
|
|
34
|
+
The conversation this is built for: *"Let me try some designs on this"* → the agent calls `try_designs`, which finds your running app and opens it; you pick one of six looks or turn the knobs and press **Send to your agent**; the agent gets what you turned and the patch, shows it to you, and applies it when you say yes. (Or come back and say *"export what I did"* → `state` → `export`.) Opened from the terminal with `npx uisandbox-mcp open`, the button is **Send to the terminal** and prints the same there.
|
|
34
35
|
|
|
35
36
|
## Without an agent
|
|
36
37
|
|
|
37
38
|
```bash
|
|
39
|
+
npx uisandbox-mcp start # the helper: on uisandbox.org, "Connect a running app" lists your running apps; one click opens one live
|
|
38
40
|
npx uisandbox-mcp open http://localhost:3000 # your RUNNING dev server, live: knobs on the app as you develop it, hot reload included
|
|
39
|
-
npx uisandbox-mcp open
|
|
41
|
+
npx uisandbox-mcp open # inside your project: finds the build, opens the sandbox (a folder or zip as argument works too)
|
|
42
|
+
npx uisandbox-mcp open http://localhost:3000 --detach # opens it and returns at once (for an agent without MCP); `stop` ends it
|
|
40
43
|
```
|
|
41
44
|
|
|
45
|
+
**The helper.** A page on uisandbox.org cannot read your localhost; the server can. It listens on `127.0.0.1:47319` (inside the MCP server whenever your client runs it, or with `start`) and answers uisandbox.org and localhost pages only: which dev servers run (`GET /apps`) and open one (`POST /open`), served from this process. Chrome asks once whether uisandbox.org may reach your local network. It looks on the usual dev ports and the runs around them (3000–3010, 4000–4010, 4200–4210, 4300–4330, 5000–5010, 5170–5180, 8000–8010, 8080–8090 and a few more) and the one your package.json names; `UISANDBOX_PORTS=4400,9000` adds your own.
|
|
46
|
+
|
|
42
47
|
## Slash commands
|
|
43
48
|
|
|
44
49
|
Where the client shows MCP prompts (Claude Desktop, Claude Code): `/uisandbox:open` (build the current repo, load, open the sandbox) and `/uisandbox:try <change>` (apply, verify 1:1, screenshot, patch). The server also sends `instructions` to the client, so the model knows when to offer the sandbox on its own.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,G as t,R as n,v as r,y as i,z as a}from"./index-r8w3zdT3.js";var o=t(),s=e();function c({section:e,onClose:t}){let c=(0,o.useRef)(null),[l]=(0,o.useState)(()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches),[u,d]=(0,o.useState)(!!e);return(0,o.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,o.useEffect)(()=>{let t=e?c.current?.querySelector(`#${CSS.escape(e)}`):null;t?t.scrollIntoView({block:`start`}):c.current?.focus()},[e]),(0,s.jsx)(`div`,{className:`privacy about-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`How UISandbox works`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,s.jsxs)(`div`,{className:`card about-dialog__card`,ref:c,tabIndex:-1,children:[(0,s.jsxs)(`div`,{className:`about-dialog__head`,children:[(0,s.jsx)(`span`,{className:`about-dialog__mark`,"aria-hidden":!0,children:(0,s.jsx)(i,{size:32})}),(0,s.jsx)(`button`,{type:`button`,className:`btn btn--ghost btn--icon about-dialog__close`,onClick:t,"aria-label":`Close`,children:(0,s.jsx)(n,{size:16})})]}),(0,s.jsxs)(`div`,{className:`landing`,children:[(0,s.jsxs)(`section`,{className:`landing__sec`,children:[(0,s.jsx)(`h2`,{children:`How it works`}),(0,s.jsxs)(`ol`,{className:`steps4`,children:[(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Bring your app.`}),` Run one line next to your dev server: `,(0,s.jsx)(`code`,{children:`npx uisandbox-mcp open`}),`.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Pick a look.`}),` See your screen six ways and pick the one that fits.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Tune it.`}),` Colour, Type, Shape and Space. Hold Space to see your original.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Take it home.`}),` Copy it for your AI, or send it to your agent.`]})]}),(0,s.jsxs)(`p`,{className:`steps4__note`,children:[(0,s.jsx)(a,{size:13,strokeWidth:2,"aria-hidden":!0}),` Your files never leave this tab`]})]}),(0,s.jsxs)(`details`,{className:`about__more`,open:u,onToggle:e=>d(e.currentTarget.open),children:[(0,s.jsx)(`summary`,{children:`More about how it works`}),(0,s.jsxs)(`div`,{className:`about__body`,children:[(0,s.jsxs)(`section`,{className:`landing__sec`,children:[(0,s.jsx)(`p`,{className:`landing__lead`,children:`What would your app look like in another brand colour, a bigger type scale, or dark mode? Find out on the real app in about a minute. Keep what you see as code, or close the tab and nothing happened.`}),(0,s.jsxs)(`ol`,{className:`steps4 steps4--long`,children:[(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Bring your app.`}),` The editor opens on a kit, shadcn/ui as it ships with seven more one pick away, so there is something to turn before you bring anything. Then `,(0,s.jsx)(`em`,{children:`Try it on your own app`}),`: run `,(0,s.jsx)(`code`,{children:`npx uisandbox-mcp open http://localhost:3000`}),` in your project, or tell your agent to open it, and your running app opens live, every screen, hot reload included. No terminal? Click the bookmark on any screen your browser shows, or bring a zip, a folder or a public repo. What you turned on the kit comes along if you want it to.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Pick a look.`}),` 6 over the screen shows it six ways, side by side: Classic, Compact, Soft, Sharp, Airy and Bold. They differ in corners, spacing, depth and type, never in colour, so you compare the style and not the paint. Open one full size, then `,(0,s.jsx)(`em`,{children:`Pick this one`}),`. The same six are the Preset list on the left.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Tune it.`}),` One knob moves every place a value is used: a colour used 144 times moves once. Colour, Type, Shape and Space come first, the rest is under More, and every dial has `,(0,s.jsx)(`em`,{children:`×1 = as in your code`}),` at its centre. It is your actual app and not a preview of one. Every CSS literal becomes a variable with the same value, and `,(0,s.jsx)(`em`,{children:`Check 1:1`}),` proves the page renders as it was. Hold Space to see it.`]}),(0,s.jsxs)(`li`,{children:[(0,s.jsx)(`b`,{children:`Take it home.`}),` `,(0,s.jsx)(`em`,{children:`Copy for your AI`}),` puts the design system and how to apply it in one paste. On a kit, the zip keeps the design system and a `,(0,s.jsx)(`code`,{children:`SKILL.md`}),` in your repo, in the kit's own names; on your own app, you get your files patched in place, or tokens for CSS, Tailwind, shadcn, Swift and Android. `,(0,s.jsx)(`em`,{children:`Copy link`}),` shares the same build with the same knobs. Or close the tab, and nothing happened.`]})]}),(0,s.jsxs)(`div`,{className:`cross`,"aria-label":`What crosses between your machine and this tab`,children:[(0,s.jsxs)(`div`,{className:`cross__side`,children:[(0,s.jsx)(`b`,{children:`Your folder`}),(0,s.jsx)(`span`,{children:`Where your build lives. It is read once, and never written to. UISandbox cannot change a file on your machine.`})]}),(0,s.jsxs)(`div`,{className:`cross__mid`,"aria-hidden":!0,children:[(0,s.jsxs)(`span`,{className:`cross__arrow`,children:[(0,s.jsx)(`span`,{className:`cross__label`,children:`a copy of your build`}),(0,s.jsx)(`svg`,{viewBox:`0 0 64 8`,preserveAspectRatio:`none`,children:(0,s.jsx)(`path`,{d:`M0 4h56M52 1l4 3-4 3`})})]}),(0,s.jsx)(`span`,{className:`cross__rule`,children:`nothing crosses on its own`}),(0,s.jsxs)(`span`,{className:`cross__arrow cross__arrow--back`,children:[(0,s.jsx)(`svg`,{viewBox:`0 0 64 8`,preserveAspectRatio:`none`,children:(0,s.jsx)(`path`,{d:`M64 4H8M12 1L8 4l4 3`})}),(0,s.jsx)(`span`,{className:`cross__label`,children:`only when you press Export`})]})]}),(0,s.jsxs)(`div`,{className:`cross__side`,children:[(0,s.jsx)(`b`,{children:`This browser tab`}),(0,s.jsx)(`span`,{children:`Where the copy is read, rendered and turned. Close the tab and it is gone: nothing is stored, nothing is sent to a server.`})]})]})]}),(0,s.jsxs)(`figure`,{className:`clip`,children:[(0,s.jsx)(`video`,{className:`clip__vid`,src:`/how-it-works.mp4`,poster:`/how-it-works-poster.png`,width:1280,height:720,autoPlay:!l,controls:l,muted:!0,loop:!0,playsInline:!0,preload:`metadata`,"aria-label":`The four steps on the real app: shadcn/ui's Dashboard, the same screen six ways, Soft picked, the colour turned through five and the dark mode switched, then SB Admin 2 brought in with those knobs, checked 1:1, and Take it home`}),(0,s.jsx)(`figcaption`,{children:`The four steps on a kit and on SB Admin 2, a real build from a public repo. Nothing staged.`})]}),(0,s.jsxs)(`section`,{className:`landing__sec`,children:[(0,s.jsx)(`h2`,{children:`Isn't this just Inspect?`}),(0,s.jsxs)(`p`,{children:[`Same instinct, different scale. DevTools changes one declaration on one element, and forgets it when you reload. Here every literal becomes a variable first, so a colour moves everywhere it is used, and what you turn comes out as code. `,(0,s.jsx)(`b`,{children:`What Inspect does better:`}),` it is already open, and it changes the live page, scripts and all. Here you work on a copy: a build, or a snapshot of a screen.`]})]}),(0,s.jsxs)(`section`,{className:`landing__sec`,children:[(0,s.jsx)(`h2`,{children:`How to check it yourself`}),(0,s.jsxs)(`p`,{children:[(0,s.jsx)(`b`,{children:`"1:1" is measured.`}),` `,(0,s.jsx)(`em`,{children:`Check 1:1`}),` renders the untouched and the tokenised page side by side and compares the computed styles of every element, shadow roots and nested frames included. Zero differences, or it names what differs. `,(0,s.jsx)(`b`,{children:`The reach meter`}),` says how much of what you see the knobs touch, and what lies outside: images, canvas, video. `,(0,s.jsx)(`b`,{children:`And it says so when it can't help:`}),` native projects, WordPress themes and source without a build get a clear message at the door.`]})]}),(0,s.jsxs)(`section`,{className:`landing__sec`,children:[(0,s.jsx)(`h2`,{id:`privacy`,children:`Your files never leave your browser`}),(0,s.jsxs)(`p`,{children:[`There is no server behind the sandbox, no account, no cookies and no analytics. Your files are read in this tab and served to the frame by a service worker; exports are made here too. Check it: watch the network tab while you drop and export, or go offline and drop a zip. The one exception is a public repo URL, which goes through uisandbox.org to fetch its zip, because GitHub and GitLab do not let a browser fetch it directly. Nothing is stored. `,(0,s.jsx)(`a`,{href:`https://github.com/Ideelab/uisandbox/blob/main/notes/security.md`,target:`_blank`,rel:`noopener`,children:`The full security note.`})]})]}),(0,s.jsxs)(`section`,{className:`landing__sec`,children:[(0,s.jsx)(`h2`,{id:`agents`,children:`From your terminal, or from your agent`}),(0,s.jsxs)(`p`,{children:[`The same engine runs as an MCP server and as a `,(0,s.jsx)(`b`,{children:`Claude Code skill`}),`, `,(0,s.jsx)(`code`,{children:`/uisandbox`}),`. Say `,(0,s.jsx)(`em`,{children:`"open this app in UISandbox"`}),` and it opens the real sandbox in your browser; `,(0,s.jsx)(`em`,{children:`Send to your agent`}),` hands what you turned back. Any MCP client (Cursor, Claude Desktop, Codex) gets the server and its `,(0,s.jsx)(`code`,{children:`/uisandbox:open`}),` prompt. Or run `,(0,s.jsx)(`code`,{children:`npx uisandbox-mcp open`}),` in your project, without an agent.`]}),(0,s.jsx)(r,{}),(0,s.jsxs)(`p`,{className:`landing__more`,children:[(0,s.jsx)(`b`,{children:`Or a link.`}),` `,(0,s.jsx)(`code`,{children:`uisandbox.org/?load=`}),` followed by a public GitHub or GitLab repo, or a `,(0,s.jsx)(`code`,{children:`.zip`}),` that allows CORS, opens straight into the sandbox: `,(0,s.jsx)(`a`,{href:`https://uisandbox.org/?load=https://github.com/edwardtufte/tufte-css`,target:`_blank`,rel:`noopener`,children:`uisandbox.org/?load=https://github.com/edwardtufte/tufte-css`}),`.`]})]}),(0,s.jsxs)(`section`,{className:`landing__sec landing__sec--quiet`,children:[(0,s.jsx)(`h2`,{children:`Who made this`}),(0,s.jsxs)(`p`,{children:[`I'm `,(0,s.jsx)(`a`,{href:`https://github.com/AlexanderKaan`,target:`_blank`,rel:`noopener`,children:`Alexander Kaan`}),`, and I build open-source tooling for user interfaces. UISandbox grew out of the design system generator I made before it: I could hand somebody a finished kit, but I could not show them their own app in it. Every decision, including the ones I had to undo, is in the repo's `,(0,s.jsx)(`a`,{href:`https://github.com/Ideelab/uisandbox/blob/main/notes/decisions.md`,target:`_blank`,rel:`noopener`,children:`notes`}),`. It's `,(0,s.jsx)(`a`,{href:`https://github.com/Ideelab/uisandbox`,target:`_blank`,rel:`noopener`,children:`MIT`}),`, and issues and pull requests are welcome.`]})]})]})]})]})]})})}export{c as AboutDialog};
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,L as l,M as u,O as d,P as f,R as p,S as m,T as h,U as ee,V as te,W as g,_ as ne,a as re,b as ie,c as ae,d as oe,f as se,g as _,h as ce,i as le,j as v,k as y,l as ue,m as de,n as fe,o as pe,p as b,r as me,s as he,t as ge,u as _e,w as x,x as S}from"./index-r8w3zdT3.js";var ve=g(`apple`,[[`path`,{d:`M12 6.528V3a1 1 0 0 1 1-1h0`,key:`11qiee`}],[`path`,{d:`M18.237 21A15 15 0 0 0 22 11a6 6 0 0 0-10-4.472A6 6 0 0 0 2 11a15.1 15.1 0 0 0 3.763 10 3 3 0 0 0 3.648.648 5.5 5.5 0 0 1 5.178 0A3 3 0 0 0 18.237 21`,key:`110c12`}]]),ye=g(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),be=g(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),xe=g(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Se=g(`diff`,[[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 10h14`,key:`elsbfy`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Ce=g(`file-braces-corner`,[[`path`,{d:`M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6`,key:`14cnrg`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1`,key:`sr0ebq`}],[`path`,{d:`M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1`,key:`w793db`}]]),we=g(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),Te=g(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Ee=g(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),De=g(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),Oe=g(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),ke=g(`swatch-book`,[[`path`,{d:`M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z`,key:`1ldrpk`}],[`path`,{d:`M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7`,key:`11i5po`}],[`path`,{d:`M 7 17h.01`,key:`1euzgo`}],[`path`,{d:`m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8`,key:`o2gii7`}]]),Ae=g(`wind`,[[`path`,{d:`M12.8 19.6A2 2 0 1 0 14 16H2`,key:`148xed`}],[`path`,{d:`M17.5 8a2.5 2.5 0 1 1 2 4H2`,key:`1u4tom`}],[`path`,{d:`M9.8 4.4A2 2 0 1 1 11 8H2`,key:`75valh`}]]),C=o();function w(t){if(!t)return`#000000`;if(t.startsWith(`#`))return t;if(t.startsWith(`oklch`))return e(t);let n=t.match(/hsl\(\s*([\d.]+)\s+([\d.]+)%\s+([\d.]+)%\s*\)/);if(n){let e=parseFloat(n[1]),t=parseFloat(n[2]),r=parseFloat(n[3]);return d(e,t,r)}if(/(^|[\s,])(radial|linear|conic)-gradient\(/.test(t)){let e=0,n=``,r=``;for(let i of t)i===`(`&&e++,i===`)`&&e--,i===`,`&&e===0?(r.trim()&&(n=r.trim()),r=``):r+=i;let i=(r.trim()||n).trim();if(i&&!/gradient\(/.test(i))return w(i)}let r=t.match(/color-mix\(\s*in\s+srgb\s*,\s*(.+?)\s+([\d.]+)%\s*,\s*(.+?)\s*\)\s*$/);if(r){let e=w(r[1]),t=w(r[3]),n=parseFloat(r[2])/100,i=(e,t)=>parseInt(e.slice(1+t*2,3+t*2),16);return`#${[0,1,2].map(r=>Math.round(i(e,r)*n+i(t,r)*(1-n))).map(e=>Math.max(0,Math.min(255,e)).toString(16).padStart(2,`0`)).join(``)}`}return typeof console<`u`&&console.warn(`[uicockpit] contrast audit cannot parse: ${t}`),`#ff00ff`}var T={base:0,dropdown:50,sticky:100,fixed:200,drawer:300,modal:1e3,popover:1100,toast:1200,tooltip:1300},je={compact:`600px`,medium:`840px`,expanded:`1200px`,large:`1600px`},E={fixed:`360px`,"fixed-xl":`412px`,spacer:`24px`,"margin-compact":`16px`,margin:`24px`},D={sm:`640px`,md:`768px`,lg:`1024px`,xl:`1280px`,"2xl":`1536px`},O={narrow:`640px`,regular:`1024px`,wide:`1280px`,max:`1536px`};function k(e){let t=S(e).vars,n=e=>t[e]??``,r={};for(let e=1;e<=6;e++)r[`accent-${e}`]=n(`--k-accent-${e}`),r[`accent-${e}-ink`]=n(`--k-accent-${e}-ink`),r[`accent-${e}-soft`]=n(`--k-accent-${e}-soft`),r[`accent-${e}-soft-fg`]=n(`--k-accent-${e}-soft-fg`),r[`grad-${e}`]=n(`--k-grad-${e}`),r[`chart-${e}`]=n(`--k-chart-${e}`);return r}function A(e){let t=S(e).vars,n=e=>parseFloat(t[e]??`0`),r=e=>`${Math.round(e*1e3)/1e3}rem`,i=n(`--k-type-h3`),a=n(`--k-type-body`);return{h4:r((i+a)/2),h5:r(a*1.05)}}var j=[2,4,6,8,10,12,14,16,20,24,28,32];function M(){let e={"s-0":`0`};for(let t of j)e[`s-${t}`]=`${+(t/16).toFixed(4)}rem`;return e}function Me(e){return M()}var N={"Body text on background":`Try Background: Crisp, or pick a darker neutral ramp.`,"Body text on surface":`Try Background: Crisp, or pick a darker neutral.`,"Body text on raised surface":`Try Background: Crisp — raised surfaces tint lighter than base.`,"Body text on overlay":`Try Background: Crisp — overlay surfaces tint lighter than base.`,"Muted text on background":`Try Background: Crisp — muted text is intentionally low-contrast.`,"Muted text on surface-2":`Try Background: Crisp — muted text is intentionally low-contrast.`,"Button text on primary":`Pick a darker primary, or switch to Mono.`,"Button text on primary hover":`Pick a darker primary — the hover state derives from it.`,"Secondary button text":`Pick a darker secondary-soft, or a lighter secondary-soft-fg.`,"Success text on success-soft":`Try Background: Crisp — system colors widen their gap on Crisp.`,"Warning text on warning-soft":`Try Background: Crisp — system colors widen their gap on Crisp.`,"Danger text on danger-soft":`Try Background: Crisp — system colors widen their gap on Crisp.`,"Info text on info-soft":`Try Background: Crisp — system colors widen their gap on Crisp.`,"Primary against background":`Primary as a SURFACE is fine here; for colored TEXT, use primary-soft tints.`,"Input border against background":`Common in modern UIs (Apple, Stripe both subtle here). Set Borders: Strong if you need strict WCAG, otherwise rely on labels + placeholders for affordance.`,"Input border against its fill":`The border is floored at 3:1 against the field fill at every Borders setting; if this fails, the fill token was changed by hand.`,"Focus ring against background":`Pick a higher-saturation primary, or set Background: Crisp.`};function P(e){let t=e.vars;return[[`Body text on background`,`--k-fg`,`--k-bg`,4.5],[`Body text on surface`,`--k-fg`,`--k-surface`,4.5],[`Body text on raised surface`,`--k-fg`,`--k-surface-raised`,4.5],[`Body text on overlay`,`--k-fg`,`--k-surface-overlay`,4.5],[`Muted text on background`,`--k-fg-muted`,`--k-bg`,4.5],[`Muted text on surface-2`,`--k-fg-muted`,`--k-surface-2`,4.5],[`Button text on primary`,`--k-primary-fg`,`--k-primary`,4.5],[`Button text on primary hover`,`--k-primary-fg`,`--k-primary-hover`,4.5],[`Secondary button text`,`--k-secondary-soft-fg`,`--k-secondary-soft`,4.5],[`Success text on success-soft`,`--k-success-soft-fg`,`--k-success-soft`,4.5],[`Warning text on warning-soft`,`--k-warning-soft-fg`,`--k-warning-soft`,4.5],[`Danger text on danger-soft`,`--k-danger-soft-fg`,`--k-danger-soft`,4.5],[`Info text on info-soft`,`--k-info-soft-fg`,`--k-info-soft`,4.5],[`Danger text on surface`,`--k-danger-text`,`--k-surface`,4.5],[`Link text on surface`,`--k-primary-text`,`--k-surface`,4.5],[`Link hover on surface`,`--k-primary-text-hover`,`--k-surface`,4.5],[t[`--k-primary-edge`]&&t[`--k-primary-edge`]!==`transparent`?`Primary boundary against background`:`Primary against background`,t[`--k-primary-edge`]&&t[`--k-primary-edge`]!==`transparent`?`--k-primary-edge`:`--k-primary`,`--k-bg`,3],[`Input border against background`,`--k-input-border`,`--k-bg`,3],[`Input border against its fill`,`--k-input-border`,`--k-input-bg`,3],[`Focus ring against background`,`--k-ring`,`--k-bg`,3]].map(([e,n,i,a])=>{let o=t[n],s=t[i],c=o&&s?r(w(o),w(s)):0,l=c>=a;return{label:e,fg:o||``,bg:s||``,ratio:Math.round(c*100)/100,required:a,passes:l,remedy:l?null:N[e]??null}})}function Ne(e){let t=S({...e,mode:`light`}).vars,n=S({...e,mode:`dark`}).vars,r=e=>Object.entries(e).map(([e,t])=>` ${e}: ${t};`).join(`
|
|
2
|
+
`),i=A(e),a=[`
|
|
3
|
+
/* --- Z-index stack --- */`,...Object.entries(T).map(([e,t])=>` --k-z-${e}: ${t};`),`
|
|
4
|
+
/* --- Breakpoints --- */`,...Object.entries(D).map(([e,t])=>` --k-bp-${e}: ${t};`),`
|
|
5
|
+
/* --- Container widths --- */`,...Object.entries(O).map(([e,t])=>` --k-container-${e}: ${t};`),`
|
|
6
|
+
/* --- Window classes (shell thresholds) + pane constants --- */`,...Object.entries(je).map(([e,t])=>` --k-win-${e}: ${t};`),...Object.entries(E).map(([e,t])=>` --k-pane-${e}: ${t};`),`
|
|
7
|
+
/* --- Extended type scale: h4/h5 in-between steps (the rest ship in :root above) --- */`,...Object.entries(i).map(([e,t])=>` --k-type-${e}: ${t};`)].join(`
|
|
8
|
+
`),o=[[`primary`,`--k-primary`],[`on-primary`,`--k-primary-fg`],[`primary-container`,`--k-primary-soft`],[`on-primary-container`,`--k-primary-soft-fg`],[`secondary`,`--k-secondary`],[`on-secondary`,`--k-secondary-fg`],[`secondary-container`,`--k-secondary-soft`],[`on-secondary-container`,`--k-secondary-soft-fg`],[`tertiary`,`--k-accent`],[`on-tertiary`,`--k-accent-fg`],[`tertiary-container`,`--k-accent-soft`],[`on-tertiary-container`,`--k-accent-soft-fg`],[`error`,`--k-danger`],[`on-error`,`--k-danger-fg`],[`error-container`,`--k-danger-soft`],[`on-error-container`,`--k-danger-soft-fg`],[`surface`,`--k-bg`],[`on-surface`,`--k-fg`],[`on-surface-variant`,`--k-fg-muted`],[`surface-dim`,`--k-surface-sunken`],[`surface-bright`,`--k-surface-raised`],[`surface-container-lowest`,`--k-surface-container-lowest`],[`surface-container-low`,`--k-surface-container-low`],[`surface-container`,`--k-surface-container`],[`surface-container-high`,`--k-surface-container-high`],[`surface-container-highest`,`--k-surface-container-highest`],[`outline`,`--k-input-border`],[`outline-variant`,`--k-border`],[`inverse-surface`,`--k-inverse-surface`],[`inverse-on-surface`,`--k-inverse-fg`],[`inverse-primary`,`--k-inverse-primary`],[`scrim`,`--k-scrim`]].map(([e,t])=>` --md-sys-color-${e}: var(${t});`).join(`
|
|
9
|
+
`);return`/* tokens.css: UISandbox tokens
|
|
10
|
+
*
|
|
11
|
+
* Drop-in usage:
|
|
12
|
+
* <link rel="stylesheet" href="tokens.css"> (or @import in your CSS)
|
|
13
|
+
*
|
|
14
|
+
* Dark mode:
|
|
15
|
+
* <html class="dark"> or any ancestor element: the .dark block
|
|
16
|
+
* re-resolves every --k-* token.
|
|
17
|
+
*
|
|
18
|
+
* Fonts are pulled from Google Fonts. To self-host, remove the @import
|
|
19
|
+
* and add your own @font-face declarations.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
${c(e.fontDisplay,e.fontBody)}
|
|
23
|
+
${[e.fontDisplay,e.fontBody].filter((e,t,n)=>l(e)&&n.indexOf(e)===t).map(f).join(`
|
|
24
|
+
|
|
25
|
+
`)}
|
|
26
|
+
|
|
27
|
+
:root {
|
|
28
|
+
${r(t)}
|
|
29
|
+
${a}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.dark {
|
|
33
|
+
${r(n)}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* --- Material 3 compatibility aliases (optional bridge) ---
|
|
37
|
+
* For codebases/agents written against the M3 sys-color vocabulary:
|
|
38
|
+
* every --md-sys-color-* resolves to its --k-* counterpart. The
|
|
39
|
+
* aliases are var() references, so they follow light/dark automatically.
|
|
40
|
+
* Safe to delete if you don't need them. */
|
|
41
|
+
:root {
|
|
42
|
+
${o}
|
|
43
|
+
}
|
|
44
|
+
`}var F={hairline:{label:`Iconoir (1.5px stroke, rounded joins)`,pkg:`iconoir-react`,install:`npm install iconoir-react`,importExample:`import { Bell } from 'iconoir-react'
|
|
45
|
+
<Bell width={20} height={20} strokeWidth={1.5} />`,sw:1.5,fill:!1},line:{label:`Lucide (1.75px stroke, balanced)`,pkg:`lucide-react`,install:`npm install lucide-react`,importExample:`import { Bell } from 'lucide-react'
|
|
46
|
+
<Bell size={20} strokeWidth={1.75} />`,sw:1.75,fill:!1},rounded:{label:`Phosphor regular (rounded terminals)`,pkg:`@phosphor-icons/react`,install:`npm install @phosphor-icons/react`,importExample:`import { Bell } from '@phosphor-icons/react'
|
|
47
|
+
<Bell size={20} weight="regular" />`,sw:1.5,fill:!1},bold:{label:`Phosphor bold (heavy weight)`,pkg:`@phosphor-icons/react`,install:`npm install @phosphor-icons/react`,importExample:`import { Bell } from '@phosphor-icons/react'
|
|
48
|
+
<Bell size={20} weight="bold" />`,sw:2,fill:!1},solid:{label:`Heroicons solid (filled)`,pkg:`@heroicons/react`,install:`npm install @heroicons/react`,importExample:`import { BellIcon } from '@heroicons/react/24/solid'
|
|
49
|
+
<BellIcon className="w-5 h-5" />`,sw:0,fill:!0}};function Pe(e){let t=S(e),n=S({...e,mode:`dark`}).vars,r=t.vars,i=e=>({value:r[e]}),a=Object.fromEntries(t.sysList.map(e=>[e.k,{value:r[`--k-`+e.k],foreground:r[`--k-`+e.k+`-fg`],soft:r[`--k-`+e.k+`-soft`],"soft-foreground":r[`--k-`+e.k+`-soft-fg`]}])),o={format:`uisandbox-kit/1`,name:`cockpit-ui-kit`,meta:{generator:`Cockpit`,interchange:`For the W3C Design Tokens format, export design.tokens.json instead.`},decisions:e,tokens:{color:{background:i(`--k-bg`),foreground:i(`--k-fg`),"foreground-muted":i(`--k-fg-muted`),"foreground-faint":i(`--k-fg-faint`),surface:i(`--k-surface`),"surface-sunken":i(`--k-surface-sunken`),"surface-2":i(`--k-surface-2`),"surface-raised":i(`--k-surface-raised`),"surface-overlay":i(`--k-surface-overlay`),primary:{value:r[`--k-primary`],name:y(t.primaryHex)},"primary-hover":i(`--k-primary-hover`),"primary-foreground":i(`--k-primary-fg`),"primary-soft":i(`--k-primary-soft`),secondary:{value:r[`--k-secondary`],name:y(t.secHex)},"secondary-foreground":i(`--k-secondary-fg`),"secondary-soft":i(`--k-secondary-soft`),accent:{value:r[`--k-accent`],name:y(t.accentHex)},"accent-foreground":i(`--k-accent-fg`),fill:{value:r[`--k-fill`]},border:i(`--k-border`),"input-border":i(`--k-input-border`),ring:i(`--k-ring`),"ring-soft":i(`--k-ring-soft`),"secondary-soft-foreground":i(`--k-secondary-soft-fg`),selection:i(`--k-selection`)},system:a,state:{"disabled-bg":i(`--k-disabled-bg`),"disabled-foreground":i(`--k-disabled-fg`),"disabled-opacity":i(`--k-disabled-opacity`),"focus-ring-width":i(`--k-focus-ring-width`),"focus-ring-offset":i(`--k-focus-ring-offset`),"input-error-border":i(`--k-input-error-border`),"input-success-border":i(`--k-input-success-border`),"input-warning-border":i(`--k-input-warning-border`)},radius:{md:i(`--k-radius-md`),lg:i(`--k-radius-lg`),pill:i(`--k-radius-pill`),button:i(`--k-radius-button`)},shadow:{sm:i(`--k-shadow-sm`),md:i(`--k-shadow-md`),lg:i(`--k-shadow-lg`)},spacing:{base:i(`--k-space`)},border:{width:i(`--k-bw`)},typography:{"font-display":i(`--k-font-display`),"font-body":i(`--k-font-body`),"font-mono":i(`--k-font-mono`),"size-h1":i(`--k-type-h1`),"size-h2":i(`--k-type-h2`),"size-h3":i(`--k-type-h3`),"size-body":i(`--k-type-body`),"size-small":i(`--k-type-small`),"size-eyebrow":i(`--k-type-eyebrow`),"ui-weight":i(`--k-ui-weight`)},motion:{"duration-fast":i(`--k-dur-fast`),duration:i(`--k-dur`),"duration-slow":i(`--k-dur-slow`),easing:i(`--k-ease`),"easing-out":i(`--k-ease-out`),"easing-in":i(`--k-ease-in`),animations:{"fade-in":i(`--k-anim-fade-in`),"fade-out":i(`--k-anim-fade-out`),"slide-up":i(`--k-anim-slide-up`),"slide-down":i(`--k-anim-slide-down`),"scale-in":i(`--k-anim-scale-in`),"scale-out":i(`--k-anim-scale-out`),spin:i(`--k-anim-spin`)},"state-hover":i(`--k-state-hover`)},icon:{style:{value:e.iconSet},library:{value:F[e.iconSet].label},package:{value:F[e.iconSet].pkg},install:{value:F[e.iconSet].install},"stroke-width":{value:F[e.iconSet].fill?`filled`:F[e.iconSet].sw}},"z-index":Object.fromEntries(Object.entries(T).map(([e,t])=>[e,{value:t}])),breakpoint:Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{value:t}])),container:Object.fromEntries(Object.entries(O).map(([e,t])=>[e,{value:t}])),palette:Object.fromEntries(Object.entries(k(e)).map(([e,t])=>[e,{value:t}])),"type-scale-extended":Object.fromEntries(Object.entries(A(e)).map(([e,t])=>[e,{value:t}])),"spacing-scale":Object.fromEntries(Object.entries(Me(e)).map(([e,t])=>[e,{value:t}]))},accessibility:{pairs:P(t).map(e=>({label:e.label,ratio:e.ratio,required:e.required,passes:e.passes}))},dark:Object.fromEntries(Object.keys(n).filter(e=>n[e]!==r[e]).map(e=>[e,n[e]]))};return JSON.stringify(o,null,2)}function Fe(e){let t=S({...e,mode:`light`}),n=S({...e,mode:`dark`}).vars,r=t.vars,i=[[`background`,`--k-bg`],[`foreground`,`--k-fg`],[`muted`,`--k-fg-muted`],[`faint`,`--k-fg-faint`],[`surface`,`--k-surface`],[`surface-sunken`,`--k-surface-sunken`],[`surface-2`,`--k-surface-2`],[`surface-raised`,`--k-surface-raised`],[`surface-overlay`,`--k-surface-overlay`],[`primary`,`--k-primary`],[`primary-hover`,`--k-primary-hover`],[`primary-foreground`,`--k-primary-fg`],[`primary-soft`,`--k-primary-soft`],[`secondary`,`--k-secondary`],[`secondary-foreground`,`--k-secondary-fg`],[`secondary-soft`,`--k-secondary-soft`],[`accent`,`--k-accent`],[`accent-foreground`,`--k-accent-fg`],[`fill`,`--k-fill`],[`border`,`--k-border`],[`input-border`,`--k-input-border`],[`ring`,`--k-ring`],[`ring-soft`,`--k-ring-soft`],[`secondary-soft-foreground`,`--k-secondary-soft-fg`],[`selection`,`--k-selection`],[`disabled-bg`,`--k-disabled-bg`],[`disabled-foreground`,`--k-disabled-fg`],[`input-error-border`,`--k-input-error-border`],[`input-success-border`,`--k-input-success-border`],[`input-warning-border`,`--k-input-warning-border`]];t.sysList.forEach(e=>{i.push([e.k,`--k-`+e.k],[e.k+`-foreground`,`--k-`+e.k+`-fg`],[e.k+`-soft`,`--k-`+e.k+`-soft`])});let a=i.map(([e,t])=>` --color-${e}: ${r[t]};`).join(`
|
|
50
|
+
`),o=` --radius-sm: calc(${r[`--k-radius-md`]} * 0.6);
|
|
51
|
+
--radius-md: ${r[`--k-radius-md`]};
|
|
52
|
+
--radius-lg: ${r[`--k-radius-lg`]};
|
|
53
|
+
--radius-pill: ${r[`--k-radius-pill`]};
|
|
54
|
+
--radius-button: ${r[`--k-radius-button`]};
|
|
55
|
+
--shadow-sm: ${r[`--k-shadow-sm`]};
|
|
56
|
+
--shadow-md: ${r[`--k-shadow-md`]};
|
|
57
|
+
--shadow-lg: ${r[`--k-shadow-lg`]};
|
|
58
|
+
--spacing-base: ${r[`--k-space`]};
|
|
59
|
+
--font-display: ${r[`--k-font-display`]};
|
|
60
|
+
--font-sans: ${r[`--k-font-body`]};
|
|
61
|
+
--font-mono: ${r[`--k-font-mono`]};
|
|
62
|
+
--text-h1: ${r[`--k-type-h1`]};
|
|
63
|
+
--text-h2: ${r[`--k-type-h2`]};
|
|
64
|
+
--text-h3: ${r[`--k-type-h3`]};
|
|
65
|
+
--text-body: ${r[`--k-type-body`]};
|
|
66
|
+
--text-small: ${r[`--k-type-small`]};
|
|
67
|
+
--text-eyebrow: ${r[`--k-type-eyebrow`]};
|
|
68
|
+
/* Motion: three-tier durations + direction-aware easings.
|
|
69
|
+
Use duration-fast / duration / duration-slow for transition-duration utils,
|
|
70
|
+
ease-out for enter animations, ease-in for exit. */
|
|
71
|
+
--default-transition-duration: ${r[`--k-dur`]};
|
|
72
|
+
--default-transition-timing-function: ${r[`--k-ease`]};
|
|
73
|
+
--duration-fast: ${r[`--k-dur-fast`]};
|
|
74
|
+
--duration: ${r[`--k-dur`]};
|
|
75
|
+
--duration-slow: ${r[`--k-dur-slow`]};
|
|
76
|
+
--ease: ${r[`--k-ease`]};
|
|
77
|
+
--ease-out: ${r[`--k-ease-out`]};
|
|
78
|
+
--ease-in: ${r[`--k-ease-in`]};
|
|
79
|
+
/* Named animation shorthands, to use with: animate-[var(--animate-fade-in)] */
|
|
80
|
+
--animate-fade-in: ${r[`--k-anim-fade-in`]};
|
|
81
|
+
--animate-fade-out: ${r[`--k-anim-fade-out`]};
|
|
82
|
+
--animate-slide-up: ${r[`--k-anim-slide-up`]};
|
|
83
|
+
--animate-slide-down: ${r[`--k-anim-slide-down`]};
|
|
84
|
+
--animate-scale-in: ${r[`--k-anim-scale-in`]};
|
|
85
|
+
--animate-scale-out: ${r[`--k-anim-scale-out`]};
|
|
86
|
+
--animate-spin-default: ${r[`--k-anim-spin`]};
|
|
87
|
+
/* Menu "roll-down" signature: panel + staggered items (see tokens.css keyframes) */
|
|
88
|
+
--animate-menu: ${r[`--k-anim-menu`]};
|
|
89
|
+
--animate-menu-item: ${r[`--k-anim-menu-item`]};
|
|
90
|
+
--menu-stagger: ${r[`--k-menu-stagger`]};
|
|
91
|
+
/* UI text: applies to buttons, badges, tabs, nav rows, form labels.
|
|
92
|
+
Sentence case at the 14px body floor; uppercase only via the eyebrow role. */
|
|
93
|
+
--ui-font-weight: ${r[`--k-ui-weight`]};
|
|
94
|
+
/* State + focus ring + disabled opacity */
|
|
95
|
+
--opacity-disabled: ${r[`--k-disabled-opacity`]};
|
|
96
|
+
--width-focus-ring: ${r[`--k-focus-ring-width`]};
|
|
97
|
+
--offset-focus-ring: ${r[`--k-focus-ring-offset`]};
|
|
98
|
+
/* Z-index stack (Tailwind utilities: z-dropdown, z-modal, etc.) */
|
|
99
|
+
${Object.entries(T).map(([e,t])=>` --z-${e}: ${t};`).join(`
|
|
100
|
+
`)}
|
|
101
|
+
/* Breakpoints (mobile-first, Tailwind defaults) */
|
|
102
|
+
${Object.entries(D).map(([e,t])=>` --breakpoint-${e}: ${t};`).join(`
|
|
103
|
+
`)}
|
|
104
|
+
/* Container widths */
|
|
105
|
+
${Object.entries(O).map(([e,t])=>` --container-${e}: ${t};`).join(`
|
|
106
|
+
`)}
|
|
107
|
+
/* Decorative + chart palette: accent-1..6 (avatars/tiles/labels) and
|
|
108
|
+
chart-1..6 (same colours). Gradient pairs ship in tokens.css as
|
|
109
|
+
--k-grad-1..6. */
|
|
110
|
+
${Object.entries(k(e)).filter(([e])=>!e.startsWith(`grad-`)&&!e.endsWith(`-ink`)).map(([e,t])=>` --color-${e}: ${t};`).join(`
|
|
111
|
+
`)}
|
|
112
|
+
/* Extended type scale: h3/h4/h5/caption/eyebrow + display */
|
|
113
|
+
${Object.entries(A(e)).map(([e,t])=>` --text-${e}: ${t};`).join(`
|
|
114
|
+
`)}
|
|
115
|
+
/* Spacing scale: s-0 through s-12 (multiples of --k-space) */
|
|
116
|
+
${Object.entries(Me(e)).map(([e,t])=>` --spacing-${e.replace(`s-`,``)}: ${t};`).join(`
|
|
117
|
+
`)}`,s=i.filter(([,e])=>n[e]!==r[e]).map(([e,t])=>` --color-${e}: ${n[t]};`).join(`
|
|
118
|
+
`),u=F[e.iconSet];return`/* globals.css: UISandbox design system, Tailwind v4
|
|
119
|
+
*
|
|
120
|
+
* Standalone: imports Tailwind v4 and registers the Cockpit theme.
|
|
121
|
+
* Place in src/app/globals.css (Next) or src/styles/globals.css (Vite),
|
|
122
|
+
* then import once from your root layout.
|
|
123
|
+
*
|
|
124
|
+
* Dark mode: add the class .dark to a parent element. Tailwind v4 reads
|
|
125
|
+
* the @theme block at build time, so every utility (bg-primary, text-muted,
|
|
126
|
+
* shadow-md, font-display, …) resolves to the current values.
|
|
127
|
+
*
|
|
128
|
+
* Icons (this kit uses ${u.label}):
|
|
129
|
+
* ${u.install}
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
@import "tailwindcss";
|
|
133
|
+
|
|
134
|
+
${c(e.fontDisplay,e.fontBody)}
|
|
135
|
+
${[e.fontDisplay,e.fontBody].filter((e,t,n)=>l(e)&&n.indexOf(e)===t).map(f).join(`
|
|
136
|
+
|
|
137
|
+
`)}
|
|
138
|
+
|
|
139
|
+
@custom-variant dark (&:is(.dark *));
|
|
140
|
+
|
|
141
|
+
@theme {
|
|
142
|
+
${a}
|
|
143
|
+
${o}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Dark mode: apply class="dark" to <html> or any parent element */
|
|
147
|
+
.dark {
|
|
148
|
+
${s}
|
|
149
|
+
}
|
|
150
|
+
`}var Ie=[{shadcn:`background`,cockpit:`--k-bg`},{shadcn:`foreground`,cockpit:`--k-fg`},{shadcn:`card`,cockpit:`--k-surface`},{shadcn:`card-foreground`,cockpit:`--k-fg`},{shadcn:`popover`,cockpit:`--k-surface-overlay`},{shadcn:`popover-foreground`,cockpit:`--k-fg`},{shadcn:`primary`,cockpit:`--k-primary`},{shadcn:`primary-foreground`,cockpit:`--k-primary-fg`},{shadcn:`secondary`,cockpit:`--k-secondary-soft`},{shadcn:`secondary-foreground`,cockpit:`--k-secondary-soft-fg`},{shadcn:`muted`,cockpit:`--k-surface-2`},{shadcn:`muted-foreground`,cockpit:`--k-fg-muted`},{shadcn:`accent`,cockpit:`--k-accent`},{shadcn:`accent-foreground`,cockpit:`--k-accent-fg`},{shadcn:`destructive`,cockpit:`--k-danger`},{shadcn:`destructive-foreground`,cockpit:`--k-danger-fg`},{shadcn:`border`,cockpit:`--k-border`},{shadcn:`input`,cockpit:`--k-input-border`},{shadcn:`ring`,cockpit:`--k-ring`},{shadcn:`chart-1`,cockpit:`--k-chart-1`},{shadcn:`chart-2`,cockpit:`--k-chart-2`},{shadcn:`chart-3`,cockpit:`--k-chart-3`},{shadcn:`chart-4`,cockpit:`--k-chart-4`},{shadcn:`chart-5`,cockpit:`--k-chart-5`},{shadcn:`sidebar`,cockpit:`--k-surface-sunken`},{shadcn:`sidebar-foreground`,cockpit:`--k-fg`},{shadcn:`sidebar-primary`,cockpit:`--k-primary`},{shadcn:`sidebar-primary-foreground`,cockpit:`--k-primary-fg`},{shadcn:`sidebar-accent`,cockpit:`--k-primary-soft`},{shadcn:`sidebar-accent-foreground`,cockpit:`--k-primary`},{shadcn:`sidebar-border`,cockpit:`--k-border`},{shadcn:`sidebar-ring`,cockpit:`--k-ring`}];function I(e){let t=Ie.filter(({cockpit:t})=>e[t]!==void 0).map(({shadcn:t,cockpit:n})=>` --${t}: ${e[n]};`),n=e[`--k-radius-md`];return n&&t.push(` --radius: ${n};`),t.join(`
|
|
151
|
+
`)}function L(){return`${Ie.map(({shadcn:e})=>` --color-${e}: var(--${e});`).join(`
|
|
152
|
+
`)}
|
|
153
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
154
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
155
|
+
--radius-lg: var(--radius);
|
|
156
|
+
--radius-xl: calc(var(--radius) + 4px);`}function Le(e){let t=S({...e,mode:`light`}).vars,n=S({...e,mode:`dark`}).vars,r=F[e.iconSet];return`/* globals.css: UISandbox theme for shadcn/ui (Tailwind v4)
|
|
157
|
+
*
|
|
158
|
+
* Standalone: replaces the globals.css that \`npx shadcn@latest init\`
|
|
159
|
+
* generates. Drop into src/app/globals.css (Next.js) or your equivalent,
|
|
160
|
+
* then \`npx shadcn@latest add button card …\` and every component will
|
|
161
|
+
* theme itself from this file without further config.
|
|
162
|
+
*
|
|
163
|
+
* Dark mode: add class="dark" to <html> or a parent.
|
|
164
|
+
*
|
|
165
|
+
* Icons (this kit uses ${r.label}):
|
|
166
|
+
* ${r.install}${r.pkg===`lucide-react`?`
|
|
167
|
+
* (shadcn defaults to lucide-react; no overrides needed)`:`
|
|
168
|
+
*
|
|
169
|
+
* shadcn defaults to lucide-react. Override icon imports in shadcn
|
|
170
|
+
* components by search & replacing "lucide-react" → "`+r.pkg+`".`}
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
@import "tailwindcss";
|
|
174
|
+
@plugin "tailwindcss-animate";
|
|
175
|
+
|
|
176
|
+
${c(e.fontDisplay,e.fontBody)}
|
|
177
|
+
${[e.fontDisplay,e.fontBody].filter((e,t,n)=>l(e)&&n.indexOf(e)===t).map(f).join(`
|
|
178
|
+
|
|
179
|
+
`)}
|
|
180
|
+
|
|
181
|
+
@custom-variant dark (&:is(.dark *));
|
|
182
|
+
|
|
183
|
+
@theme inline {
|
|
184
|
+
${L()}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
:root {
|
|
188
|
+
${I(t)}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.dark {
|
|
192
|
+
${I(n)}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@layer base {
|
|
196
|
+
* {
|
|
197
|
+
@apply border-border outline-ring/50;
|
|
198
|
+
}
|
|
199
|
+
body {
|
|
200
|
+
@apply bg-background text-foreground;
|
|
201
|
+
font-family: ${t[`--k-font-body`]};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
`}var R=[[`primary`,`--k-primary`],[`primaryHover`,`--k-primary-hover`],[`primaryForeground`,`--k-primary-fg`],[`primarySoft`,`--k-primary-soft`],[`secondary`,`--k-secondary`],[`accent`,`--k-accent`],[`background`,`--k-bg`],[`surface`,`--k-surface`],[`surfaceSunken`,`--k-surface-sunken`],[`surfaceRaised`,`--k-surface-raised`],[`foreground`,`--k-fg`],[`foregroundMuted`,`--k-fg-muted`],[`foregroundFaint`,`--k-fg-faint`],[`border`,`--k-border`],[`inputBorder`,`--k-input-border`],[`ring`,`--k-ring`],[`success`,`--k-success`],[`warning`,`--k-warning`],[`danger`,`--k-danger`],[`info`,`--k-info`]],z=[[`radiusSmall`,`--k-radius-sm`],[`radiusMedium`,`--k-radius-md`],[`radiusLarge`,`--k-radius-lg`],[`space`,`--k-space`],[`pad`,`--k-pad`],[`gap`,`--k-gap`],[`spacing2`,`--k-s-2`],[`spacing4`,`--k-s-4`],[`spacing8`,`--k-s-8`],[`spacing12`,`--k-s-12`],[`spacing16`,`--k-s-16`],[`spacing24`,`--k-s-24`],[`spacing32`,`--k-s-32`],[`controlHeight`,`--k-in-h-default`],[`buttonHeight`,`--k-btn-h-default`]],B=[[`display`,`--k-type-display`],[`h1`,`--k-type-h1`],[`h2`,`--k-type-h2`],[`h3`,`--k-type-h3`],[`body`,`--k-type-body`],[`small`,`--k-type-small`],[`caption`,`--k-type-caption`]];function V(t){if(t===void 0)return null;let n=String(t).trim();if(/^#[0-9a-f]{6}$/i.test(n))return n.toLowerCase();if(/^oklch\(/i.test(n))try{return e(n)}catch{return null}return null}var H=e=>{let t=String(e??``).trim().match(/^(-?\d*\.?\d+)(px|rem)$/);if(!t)return null;let n=parseFloat(t[1]);return Math.round((t[2]===`rem`?n*16:n)*100)/100},Re=e=>{let t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,r=parseInt(e.slice(5,7),16)/255;return`Color(red: ${t.toFixed(4)}, green: ${n.toFixed(4)}, blue: ${r.toFixed(4)})`};function ze(e){let t=S({...e,mode:`light`}).vars,n=S({...e,mode:`dark`}).vars,r=R.map(([e,r])=>{let i=V(t[r]),a=V(n[r]);return i?` static let ${e} = Color(light: ${Re(i)}, dark: ${Re(a??i)}) // ${i} / ${a??i}`:` // ${e}: ${t[r]} (not a flat colour, see tokens.css)`}),i=z.map(([e,n])=>{let r=H(t[n]);return r===null?` // ${e}: ${t[n]}`:` static let ${e}: CGFloat = ${r}`}),o=B.map(([e,n])=>{let r=H(t[n]);return r===null?` // ${e}: ${t[n]}`:` static let ${e}: CGFloat = ${r}`}),s=e=>e===`System`?null:a(e),c=s(e.fontDisplay),l=s(e.fontBody);return`// DesignTokens.swift: generated by UISandbox from the values in the sandbox.
|
|
205
|
+
// Drop into your Xcode project. Custom fonts must be added to the bundle + Info.plist.
|
|
206
|
+
import SwiftUI
|
|
207
|
+
|
|
208
|
+
extension Color {
|
|
209
|
+
/// A colour that follows the system appearance.
|
|
210
|
+
init(light: Color, dark: Color) {
|
|
211
|
+
self.init(uiColor: UIColor { trait in
|
|
212
|
+
trait.userInterfaceStyle == .dark ? UIColor(dark) : UIColor(light)
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
enum DesignTokens {
|
|
218
|
+
enum Colors {
|
|
219
|
+
${r.join(`
|
|
220
|
+
`)}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
enum Metrics {
|
|
224
|
+
${i.join(`
|
|
225
|
+
`)}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
enum TypeSize {
|
|
229
|
+
${o.join(`
|
|
230
|
+
`)}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
enum Fonts {
|
|
234
|
+
static let displayFamily: String? = ${c?`"${c}"`:`nil // system`}
|
|
235
|
+
static let bodyFamily: String? = ${l?`"${l}"`:`nil // system`}
|
|
236
|
+
static func display(_ size: CGFloat, weight: Font.Weight = .semibold) -> Font {
|
|
237
|
+
displayFamily.map { Font.custom($0, size: size).weight(weight) } ?? .system(size: size, weight: weight, design: .default)
|
|
238
|
+
}
|
|
239
|
+
static func body(_ size: CGFloat = TypeSize.body, weight: Font.Weight = .regular) -> Font {
|
|
240
|
+
bodyFamily.map { Font.custom($0, size: size).weight(weight) } ?? .system(size: size, weight: weight, design: .default)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`}function Be(e){let t=S({...e,mode:`light`}).vars,n=S({...e,mode:`dark`}).vars,r=[{path:`DesignTokens.xcassets/Contents.json`,content:JSON.stringify({info:{author:`uisandbox`,version:1}},null,2)+`
|
|
245
|
+
`}],i=e=>({"color-space":`srgb`,components:{red:`0x${e.slice(1,3).toUpperCase()}`,green:`0x${e.slice(3,5).toUpperCase()}`,blue:`0x${e.slice(5,7).toUpperCase()}`,alpha:`1.000`}});for(let[e,a]of R){let o=V(t[a]),s=V(n[a]);if(!o)continue;let c={info:{author:`uisandbox`,version:1},colors:[{idiom:`universal`,color:i(o)},{idiom:`universal`,appearances:[{appearance:`luminosity`,value:`dark`}],color:i(s??o)}]},l=e.charAt(0).toUpperCase()+e.slice(1);r.push({path:`DesignTokens.xcassets/${l}.colorset/Contents.json`,content:JSON.stringify(c,null,2)+`
|
|
246
|
+
`})}return r}var U=[[`primary`,`--k-primary`],[`primary_hover`,`--k-primary-hover`],[`on_primary`,`--k-primary-fg`],[`primary_container`,`--k-primary-soft`],[`secondary`,`--k-secondary`],[`tertiary`,`--k-accent`],[`background`,`--k-bg`],[`surface`,`--k-surface`],[`surface_variant`,`--k-surface-sunken`],[`on_surface`,`--k-fg`],[`on_surface_muted`,`--k-fg-muted`],[`outline`,`--k-input-border`],[`outline_variant`,`--k-border`],[`success`,`--k-success`],[`warning`,`--k-warning`],[`error`,`--k-danger`],[`info`,`--k-info`]],W=e=>`#FF`+e.slice(1).toUpperCase(),G=e=>e.split(`_`).map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join(``);function Ve(e,t=`light`){let n=S({...e,mode:t}).vars,r=U.map(([e,t])=>{let r=V(n[t]);return r?` <color name="${e}">${W(r)}</color>`:` <!-- ${e}: ${n[t]} (not a flat colour) -->`});return`<?xml version="1.0" encoding="utf-8"?>\n<!-- generated by UISandbox: values${t===`dark`?`-night`:``}/colors.xml -->\n<resources>\n${r.join(`
|
|
247
|
+
`)}\n</resources>\n`}function He(e){let t=S({...e,mode:`light`}).vars,n=S({...e,mode:`dark`}).vars,r=e=>{let t=String(e??``).match(/^(-?\d*\.?\d+)(px|rem)$/);return t?Math.round((t[2]===`rem`?t[1]*16:+t[1])*10)/10:null},i=e=>U.map(([t,n])=>{let r=V(e[n]);return r?` val ${G(t)} = Color(0xFF${r.slice(1).toUpperCase()})`:` // ${t}: ${e[n]}`});return`// DesignTokens.kt: generated by UISandbox from the values in the sandbox.
|
|
248
|
+
package design
|
|
249
|
+
|
|
250
|
+
import androidx.compose.ui.graphics.Color
|
|
251
|
+
import androidx.compose.ui.unit.dp
|
|
252
|
+
import androidx.compose.ui.unit.sp
|
|
253
|
+
|
|
254
|
+
object DesignTokens {
|
|
255
|
+
object Light {
|
|
256
|
+
${i(t).join(`
|
|
257
|
+
`)}
|
|
258
|
+
}
|
|
259
|
+
object Dark {
|
|
260
|
+
${i(n).join(`
|
|
261
|
+
`)}
|
|
262
|
+
}
|
|
263
|
+
object Radius {
|
|
264
|
+
val small = ${r(t[`--k-radius-sm`])??6}.dp
|
|
265
|
+
val medium = ${r(t[`--k-radius-md`])??10}.dp
|
|
266
|
+
val large = ${r(t[`--k-radius-lg`])??12}.dp
|
|
267
|
+
}
|
|
268
|
+
object Space {
|
|
269
|
+
val unit = ${r(t[`--k-space`])??16}.dp
|
|
270
|
+
val pad = ${r(t[`--k-pad`])??24}.dp
|
|
271
|
+
val gap = ${r(t[`--k-gap`])??8}.dp
|
|
272
|
+
}
|
|
273
|
+
object Type {
|
|
274
|
+
val display = ${r(t[`--k-type-display`])??48}.sp
|
|
275
|
+
val h1 = ${r(t[`--k-type-h1`])??30}.sp
|
|
276
|
+
val h2 = ${r(t[`--k-type-h2`])??22}.sp
|
|
277
|
+
val body = ${r(t[`--k-type-body`])??14}.sp
|
|
278
|
+
val small = ${r(t[`--k-type-small`])??12}.sp
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
`}function K(e){if(typeof e==`number`)return String(e);let t=e.trim();return/^[A-Za-z][A-Za-z0-9 ._-]*$/.test(t)&&!/^(y|n|yes|no|true|false|on|off|null)$/i.test(t)?t:JSON.stringify(t)}var q=e=>/^-?\d*\.?\d+$/.test(e.trim())?`${e.trim()}px`:e.trim();function Ue(e){let t=[],n=new Set,r=e=>{!e||n.has(e.fontSize)||(n.add(e.fontSize),t.push(e))},i=e.anchors.type,a=(e,t)=>{if(!t)return;let n=parseFloat(t.fontSize);if(!Number.isFinite(n)||n<8||n>200)return;let r=parseInt(t.fontWeight,10),i=parseFloat(t.lineHeight);return{name:e,fontFamily:t.fontFamily,fontSize:t.fontSize,...Number.isFinite(r)?{fontWeight:r}:{},...Number.isFinite(i)&&n?{lineHeight:Math.round(i/n*100)/100}:{}}},o=a(`display`,i?.display),s=a(`heading`,i?.heading),c=o&&s&&parseFloat(s.fontSize)>parseFloat(o.fontSize)?s:o,l=c===s?o:s;r(c&&{...c,name:`display`}),r(l&&{...l,name:`heading`}),r(a(`body`,i?.body));let u=e.sizes;if(u.length){let n=[...u].sort((e,t)=>t.count-e.count),i=[[`display`,u[0]],[`heading`,u[1]],[`body`,n[0]],[`small`,u[u.length-1]]];for(let[n,a]of i)!a||t.some(e=>e.name===n)||r({name:n,fontFamily:n===`display`||n===`heading`?e.fonts.display:e.fonts.body,fontSize:q(a.value)})}let d=[`display`,`heading`,`body`,`small`];return t.sort((e,t)=>d.indexOf(e.name)-d.indexOf(t.name))}var We=e=>e.map(e=>` ${e.name}: ${K(q(e.value))}`).join(`
|
|
282
|
+
`);function Ge(e,t,n,r,i={}){let a=ce(e,t,n.cPrimary,{display:n.fontDisplay,body:n.fontBody},{painted:i.painted,anchors:i.anchors}),o=i.date??new Date().toISOString().slice(0,10),s=r.replace(/\.(zip|tar|gz)$/i,``).replace(/[-_]+/g,` `).trim()||`Untitled`,c=Ue(a),l=[{section:`components`,reason:`UISandbox reads values out of a built app; component structure was not observed.`}];a.spacing.length||l.push({section:`spacing`,reason:`No spacing literals could be told apart from other lengths in this build.`}),a.radii.length||l.push({section:`rounded`,reason:`This build paints no corner radius.`});let u=[`---`,`version: alpha`,`name: ${K(s)}`];u.push(`description: ${K(`Measured from the built app by UISandbox on ${o}. ${a.totals.moved} of ${a.totals.values} design values were changed in this pass; the tokens below are what the interface paints now.`)}`),u.push(`omitted:`);for(let e of l)u.push(` - section: ${e.section}\n reason: ${K(e.reason)}`);if(a.palette.length){u.push(`colors:`);for(let e of a.palette)u.push(` ${e.name}: ${K(e.value)}`)}if(c.length){u.push(`typography:`);for(let e of c)u.push(` ${e.name}:`),u.push(` fontFamily: ${K(e.fontFamily)}`),u.push(` fontSize: ${K(e.fontSize)}`),e.fontWeight&&u.push(` fontWeight: ${e.fontWeight}`),e.lineHeight!==void 0&&u.push(` lineHeight: ${typeof e.lineHeight==`number`?e.lineHeight:K(e.lineHeight)}`)}a.radii.length&&u.push(`rounded:
|
|
283
|
+
`+We(a.radii)),a.spacing.length&&u.push(`spacing:
|
|
284
|
+
`+We(a.spacing)),u.push(`---`);let d=[`# ${s}`,``];if(d.push(`## Overview`,``),d.push(`This file was measured, not written: UISandbox read ${a.totals.values} design values out of this app's own built stylesheets and ${a.totals.moved===0?`none were changed`:`${a.totals.moved} of them were changed`} in this pass. The tokens in the front matter are the values the interface paints right now, so they are the ones to build against.`,``,a.fromScreen?`Which value got which name was decided on the rendered screen, not on how often a stylesheet mentions it. A utility class nobody used does not become a token here.`:`Names were assigned from how often the stylesheets use a value; the rendered screen was not available to check them against, so treat the roles as a strong guess and the values as exact.`,``),i.notes?.length){d.push(`Where the readings came from:`,``);for(let e of i.notes.slice(0,6))d.push(`- ${e}`);d.push(``)}if(d.push(`## Colors`,``),a.palette.length){for(let e of a.palette){let t=e.count?`${qe(e)}, used ${e.count} time${e.count===1?``:`s`} in the build`:e.name===`primary`?`the brand colour`:qe(e);d.push(`- **${Ke(e.name)} (${e.value})**: ${t}.${e.changed?` Was ${e.was}.`:``}`)}let e=a.palette[0]&&/^#[0-9a-f]{6}$/i.test(a.palette[0].value)?y(a.palette[0].value):``;d.push(``,`The brand colour reads as ${e||`the primary`}. Use it for the single most important action on a screen; everything else comes from the neutrals above.`)}else d.push(`No colour could be placed in a role from this build.`);if(d.push(``),d.push(`## Typography`,``),c.length){let e=e=>c.find(t=>t.name===e)?.fontFamily,t=e(`display`)??e(`heading`)??a.fonts.display,n=e(`body`)??a.fonts.body;d.push(t===n?`Everything is set in **${n}**.`:`Headings are set in **${t}**, body copy in **${n}**.`,``);for(let e of c)d.push(`- **${Ke(e.name)}:** ${e.fontFamily} at ${e.fontSize}${e.fontWeight?`, weight ${e.fontWeight}`:``}.`);a.sizes.length>c.length&&d.push(``,`The build paints ${a.sizes.length} distinct font sizes; the four above are the ones that carry the page. Snap a new size onto the nearest of them rather than adding another step.`)}else d.push(`Headings in **${a.fonts.display}**, body in **${a.fonts.body}**. No size ladder could be read from this build.`);i.webfonts?.length&&d.push(``,`${i.webfonts.map(e=>`**${e}**`).join(` and `)} must be fetched. Put this in the document head, or every measurement here is off:`,``,"```html",b(i.webfonts),"```"),d.push(``),d.push(`## Layout`,``),d.push(a.spacing.length?`Spacing runs on the measured steps in the front matter (${a.spacing.map(e=>q(e.value)).join(`, `)}). Keep to them: they are the rhythm the existing screens already have.`:`No spacing scale could be read from this build; follow the padding already on the surrounding elements.`),d.push(``),d.push(`## Elevation & Depth`,``);let f=a.shadows.find(e=>e.value.trim().split(/\s+/).length>=3);if(f?d.push(`Depth comes from ${a.shadows.length} shadow${a.shadows.length===1?``:`s`}. The one the build leans on most is \`${f.value}\`${f.changed?` (was \`${f.was}\`)`:``}. Reuse it rather than inventing a new blur.`):a.shadows.length?d.push(`The build holds ${a.shadows.length} shadow value${a.shadows.length===1?``:`s`}, none of them a complete shadow this reader could restate. Copy the elevation off the existing components rather than from here.`):d.push(`This build paints no shadows. Hierarchy is carried by colour and borders, so keep new surfaces flat.`),d.push(``),d.push(`## Shapes`,``),a.radii.length){let e=a.radii.every(e=>_(e.value)===0);d.push(e?`Every corner in this build is square. Keep them square.`:`Corners run ${a.radii.map(e=>q(e.value)).join(` · `)}. The one used most is ${q([...a.radii].sort((e,t)=>t.count-e.count)[0].value)}; treat that as the default and step up only for large surfaces.`)}else d.push(`No corner radius is set anywhere in this build. The corners are square; keep them square.`);d.push(``),d.push(`## Do's and Don'ts`,``),d.push(`- Do take colours, sizes and radii from the front matter above instead of typing new literals.`),a.palette[0]&&d.push("- Do use `{colors.primary}` for the one most important action per screen.");let p=a.palette.filter(e=>e.changed);return p.length&&d.push(`- Don't reintroduce ${p.map(e=>`\`${e.was}\``).join(` or `)}: ${p.length===1?`it was`:`they were`} replaced everywhere in this pass.`),a.radii.every(e=>_(e.value)===0)&&d.push(`- Don't add rounded corners: this build is square throughout.`),a.shadows.length||d.push(`- Don't add shadows: this build has none, and one new card with a shadow reads as a mistake.`),d.push(`- Don't treat this file as a component spec. It records values, not structure: check the existing components before adding a new one.`),d.push(``),u.join(`
|
|
285
|
+
`)+`
|
|
286
|
+
|
|
287
|
+
`+d.join(`
|
|
288
|
+
`)}var Ke=e=>e.charAt(0).toUpperCase()+e.slice(1).replace(/-/g,` `);function qe(e){if(e.anchor===`text`)return`the body ink, read off the page`;if(e.anchor===`surface`)return`the page ground, read off the page`;if(e.paintRole&&e.painted)return`${e.paintRole===`text`?`painted on text`:e.paintRole===`surface`?`painted as a background`:`painted on borders`} on ${e.painted} element${e.painted===1?``:`s`} of this screen`;let t=e.props[0]??``;return t===`color`?`painted on text`:t.startsWith(`background`)?`painted as a background`:t.includes(`border`)?`painted on borders`:t===`fill`||t===`stroke`?`painted in icons`:t?`used on \`${t}\``:`measured in the build`}function Je(e,t={}){let n=t.date??new Date().toISOString().slice(0,10);return`<!-- Append this to AGENTS.md in your repo root. The same block works in
|
|
289
|
+
CLAUDE.md, GEMINI.md or .cursorrules, whichever your agent reads. -->
|
|
290
|
+
|
|
291
|
+
## Design
|
|
292
|
+
|
|
293
|
+
The visual system for ${e.replace(/\.(zip|tar|gz)$/i,``).replace(/[-_]+/g,` `).trim()||`this app`} is defined in [DESIGN.md](./DESIGN.md).
|
|
294
|
+
|
|
295
|
+
- Read DESIGN.md before writing or changing any UI.
|
|
296
|
+
- Take colours, type, corner radii and spacing from its front matter tokens.
|
|
297
|
+
Reference them by name (\`{colors.primary}\`, \`{rounded.md}\`) rather than
|
|
298
|
+
pasting hex values into components.
|
|
299
|
+
- If a value you need is not in DESIGN.md, use the nearest token that is, and
|
|
300
|
+
say in your summary which one you picked and why. Do not add a new literal
|
|
301
|
+
without flagging it.
|
|
302
|
+
- DESIGN.md records VALUES, not component structure. Check the existing
|
|
303
|
+
components before inventing a new one.
|
|
304
|
+
- It was measured from the built app with UISandbox on ${n}${t.moved?` (${t.moved} value${t.moved===1?``:`s`} changed in that pass)`:``}. If the UI and DESIGN.md disagree, DESIGN.md is the intent and the UI is the thing to fix.
|
|
305
|
+
`}function Ye(e){let t=x(e);if(!t)return null;let{components:n,alpha:r,hex:i}=h(t),a={colorSpace:`srgb`,components:n,hex:i};return r<1&&(a.alpha=r),a}function Xe(e){let t=e.trim(),n=t.match(/^(-?\d*\.?\d+)\s*(px|rem)$/i);if(n)return{value:parseFloat(n[1]),unit:n[2].toLowerCase()};let r=_(t);return r===null?null:{value:Math.round(r*1e3)/1e3,unit:`px`}}function Ze(e,t){let n=[],r=0,i=``;for(let a of e)a===`(`?r++:a===`)`&&r--,a===t&&r===0?(n.push(i),i=``):i+=a;return i.trim()&&n.push(i),n.map(e=>e.trim()).filter(Boolean)}function Qe(e){let t=Ze(e,`,`),n=[];for(let e of t){if(/\binset\b/i.test(e))return null;let t=Ze(e,` `),r=[],i=null;for(let e of t){let t=Xe(e);if(t&&r.length<4){r.push(t);continue}let n=Ye(e);if(n&&!i){i=n;continue}return null}if(!i||r.length<3)return null;n.push({color:i,offsetX:r[0],offsetY:r[1],blur:r[2],spread:r[3]??{value:0,unit:`px`}})}return n.length?n.length===1?n[0]:n:null}var J=(e,t)=>`${t}; used ${e.count} time${e.count===1?``:`s`} in the build${e.changed?`, was ${e.was}`:``}`;function $e(e,t,n,r,i={}){let a=ce(e,t,n.cPrimary,{display:n.fontDisplay,body:n.fontBody},{painted:i.painted,anchors:i.anchors}),o={$description:`${r}, measured from the built app by UISandbox on ${i.date??new Date().toISOString().slice(0,10)}. ${a.totals.moved} of ${a.totals.values} values changed in this pass. W3C Design Tokens Format Module 2025.10.`},s={$type:`color`},c=[];for(let e of a.palette){let t=Ye(e.value);t?s[e.name]={$value:t,$description:J(e,e.name===`primary`?`the brand colour`:`measured on ${e.props[0]??`the build`}`)}:c.push(`${e.name} (${e.value})`)}c.length&&(s.$description=`Not exported, could not be expressed as sRGB components: ${c.join(`, `)}. DESIGN.md carries them as written.`),Object.keys(s).length>1&&(o.color=s);let l={$type:`fontFamily`};l.display={$value:et(a.fonts.display),$description:`headings`},l.body={$value:et(a.fonts.body),$description:`body copy`},o.font=l;let u={$type:`dimension`};for(let[e,t]of a.sizes.slice(0,8).entries()){let n=Xe(t.value);n&&(u[`step-${e+1}`]={$value:n,$description:J(t,`font size`)})}Object.keys(u).length>1&&(o.fontSize=u);let d={$type:`fontWeight`};for(let e of a.weights.slice(0,6)){let t=parseInt(e.value,10);Number.isFinite(t)&&t>=1&&t<=1e3&&(d[`w-${t}`]={$value:t,$description:J(e,`font weight`)})}Object.keys(d).length>1&&(o.fontWeight=d);let f=(e,t)=>{let n={$type:`dimension`};for(let r of e){let e=Xe(r.value);e&&(n[r.name]={$value:e,$description:J(r,t)})}return Object.keys(n).length>1?n:null},p=f(a.radii,`corner radius`);p&&(o.radius=p);let m=f(a.spacing,`spacing step`);m&&(o.spacing=m);let h={$type:`shadow`};for(let[e,t]of a.shadows.slice(0,6).entries()){let n=Qe(t.value);n&&(h[`level-${e+1}`]={$value:n,$description:J(t,`elevation`)})}return Object.keys(h).length>1&&(o.shadow=h),JSON.stringify(o,null,2)+`
|
|
306
|
+
`}function et(e){let t=e.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``)).filter(Boolean);return t.length>1?t:t[0]??e}function Y(e){if(!e)return;let t=x(e);if(!(!t||t.a<.999))return n(t)}function tt(e){if(!e)return;let t=e.trim().match(/^(-?\d*\.?\d+)px$/);return t?parseFloat(t[1]):void 0}var X=(e,t)=>e.find(e=>e.name===t)?.value;function nt(e,t={}){let n={},r=(e,t)=>{t!==void 0&&t!==``&&(n[e]=t)};r(`brand`,Y(X(e.palette,`primary`)??e.brand)),r(`ink`,Y(X(e.palette,`text`))),r(`page`,Y(X(e.palette,`surface`))),r(`surface`,Y(X(e.palette,`surface-alt`)??X(e.palette,`fill`))),r(`inkMuted`,Y(X(e.palette,`text-muted`))),r(`line`,Y(X(e.palette,`border`))),r(`success`,Y(t.success)),r(`warning`,Y(t.warning)),r(`danger`,Y(t.danger));let i=e.anchors.type?.body,a=e.anchors.type?.display??e.anchors.type?.heading;r(`fontBody`,i?.fontFamily),r(`fontHeading`,a?.fontFamily);let o=tt(i?.fontSize);o&&r(`baseText`,`${o}px`);let s=tt(i?.lineHeight);s&&o&&r(`lineHeight`,Math.round(s/o*1e3)/1e3);let c=a?parseInt(a.fontWeight,10):NaN;Number.isFinite(c)&&r(`fontWeight`,c);let l=e.radii.filter(e=>e.name!==`none`&&e.name!==`full`).sort((e,t)=>(t.painted??0)-(e.painted??0)||t.count-e.count)[0],u=l?_(l.value)??void 0:void 0;return u!==void 0&&r(`radius`,`${u}px`),n}function rt(e,t,n){let r=n.date??new Date().toISOString().slice(0,10),i=new Map;for(let e of t){let t=e.name.startsWith(`patched/`)?`patched/`:`root`;i.has(t)||i.set(t,[]),i.get(t).push(e)}let a=(i.get(`root`)??[]).map(e=>`| \`${e.name}\` | ${e.what} |`).join(`
|
|
307
|
+
`),o=(i.get(`patched/`)??[]).length;return`# ${e}: UISandbox export
|
|
308
|
+
|
|
309
|
+
${n.moved} of ${n.total} design values were changed, across ${n.changedFiles} file${n.changedFiles===1?``:`s`}. Exported ${r}.
|
|
310
|
+
|
|
311
|
+
## Start here
|
|
312
|
+
|
|
313
|
+
**If an agent writes your code** (Claude Code, Cursor, Codex):
|
|
314
|
+
|
|
315
|
+
1. Copy \`DESIGN.md\` into the root of your repo.
|
|
316
|
+
2. Paste the block from \`AGENTS.md.snippet\` into your \`AGENTS.md\` (or \`CLAUDE.md\`). Create the file if you do not have one.
|
|
317
|
+
3. Ask your agent: *apply DESIGN.md to the UI*.
|
|
318
|
+
|
|
319
|
+
**If you edit the code yourself:**
|
|
320
|
+
|
|
321
|
+
1. Open \`patched/\`: those are your own files with the new values already written in, in their original folders.
|
|
322
|
+
2. Diff them against your source, take what you want.
|
|
323
|
+
3. \`sandbox-patch.txt\` is the same change as a find-and-replace list if you would rather do it by hand.
|
|
324
|
+
|
|
325
|
+
## What is in here
|
|
326
|
+
|
|
327
|
+
| File | What it is |
|
|
328
|
+
|---|---|
|
|
329
|
+
${a}
|
|
330
|
+
${o?`| \`patched/…\` | ${o} of your own file${o===1?``:`s`}, rewritten with the new values in place. The complete change. |\n`:``}
|
|
331
|
+
## Notes
|
|
332
|
+
|
|
333
|
+
- Values here are the ones on screen in the sandbox, not a re-derivation. What you saw is what these files say.
|
|
334
|
+
- \`DESIGN.md\` and \`design.tokens.json\` describe **your app as measured**. \`tokens.css\`, \`tokens.json\`, the Tailwind and shadcn files and the native ones describe **a fresh token system seeded from these values**, a different thing, useful if you are starting a system rather than patching one.
|
|
335
|
+
- \`sandbox-values.css\` is a reference list of every value found, under names of our own. It is not a drop-in stylesheet; your CSS does not read those variable names.
|
|
336
|
+
|
|
337
|
+
Made with [UISandbox](https://uisandbox.org). Your files never left your browser.
|
|
338
|
+
`}var Z=i(),Q={css:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M1.5 0h21l-1.91 21.563L11.977 24l-8.565-2.438L1.5 0zm17.09 4.413L5.41 4.41l.213 2.622 10.125.002-.255 2.716h-6.64l.24 2.573h6.182l-.366 3.523-2.91.804-2.956-.81-.188-2.11h-2.61l.29 3.855L12 19.288l5.373-1.53L18.59 4.414z`})}),html:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M1.5 0h21l-1.91 21.563L11.977 24l-8.564-2.438L1.5 0zm7.031 9.75l-.232-2.718 10.059.003.23-2.622L5.412 4.41l.698 8.01h9.126l-.326 3.426-2.91.804-2.955-.81-.188-2.11H6.248l.33 4.171L12 19.351l5.379-1.443.744-8.157H8.531z`})}),tailwind:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M12.001,4.8c-3.2,0-5.2,1.6-6,4.8c1.2-1.6,2.6-2.2,4.2-1.8c0.913,0.228,1.565,0.89,2.288,1.624 C13.666,10.618,15.027,12,18.001,12c3.2,0,5.2-1.6,6-4.8c-1.2,1.6-2.6,2.2-4.2,1.8c-0.913-0.228-1.565-0.89-2.288-1.624 C16.337,6.182,14.976,4.8,12.001,4.8z M6.001,12c-3.2,0-5.2,1.6-6,4.8c1.2-1.6,2.6-2.2,4.2-1.8c0.913,0.228,1.565,0.89,2.288,1.624 c1.177,1.194,2.538,2.576,5.512,2.576c3.2,0,5.2-1.6,6-4.8c-1.2,1.6-2.6,2.2-4.2,1.8c-0.913-0.228-1.565-0.89-2.288-1.624 C10.337,13.382,8.976,12,6.001,12z`})}),shadcn:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M22.219 11.784 11.784 22.219c-.407.407-.407 1.068 0 1.476.407.407 1.068.407 1.476 0L23.695 13.26c.407-.408.407-1.069 0-1.476-.408-.407-1.069-.407-1.476 0ZM20.132.305.305 20.132c-.407.407-.407 1.068 0 1.476.408.407 1.069.407 1.476 0L21.608 1.781c.407-.407.407-1.068 0-1.476-.408-.407-1.069-.407-1.476 0Z`})}),claude:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})}),openai:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`})}),cursor:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M11.503.131 1.891 5.678a.84.84 0 0 0-.42.726v11.188c0 .3.162.575.42.724l9.609 5.55a1 1 0 0 0 .998 0l9.61-5.55a.84.84 0 0 0 .42-.724V6.404a.84.84 0 0 0-.42-.726L12.497.131a1.01 1.01 0 0 0-.996 0M2.657 6.338h18.55c.263 0 .43.287.297.515L12.23 22.918c-.062.107-.229.064-.229-.06V12.335a.59.59 0 0 0-.295-.51l-9.11-5.257c-.109-.063-.064-.23.061-.23`})}),figma:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M15.852 8.981h-4.588V0h4.588c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.491-4.49 4.491zM12.735 7.51h3.117c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-3.117V7.51zm0 1.471H8.148c-2.476 0-4.49-2.014-4.49-4.49S5.672 0 8.148 0h4.588v8.981zm-4.587-7.51c-1.665 0-3.019 1.355-3.019 3.019s1.354 3.02 3.019 3.02h3.117V1.471H8.148zm4.587 15.019H8.148c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h4.588v8.98zM8.148 8.981c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h3.117V8.981H8.148zM8.172 24c-2.489 0-4.515-2.014-4.515-4.49s2.014-4.49 4.49-4.49h4.588v4.441c0 2.503-2.047 4.539-4.563 4.539zm-.024-7.51a3.023 3.023 0 0 0-3.019 3.019c0 1.665 1.365 3.019 3.044 3.019 1.705 0 3.093-1.376 3.093-3.068v-2.97H8.148zm7.704 0h-.098c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h.098c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.49-4.49 4.49zm-.097-7.509c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h.098c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-.098z`})}),swift:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M7.508 0c-.287 0-.573 0-.86.002-.241.002-.483.003-.724.01-.132.003-.263.009-.395.015A9.154 9.154 0 0 0 4.348.15 5.492 5.492 0 0 0 2.85.645 5.04 5.04 0 0 0 .645 2.848c-.245.48-.4.972-.495 1.5-.093.52-.122 1.05-.136 1.576a35.2 35.2 0 0 0-.012.724C0 6.935 0 7.221 0 7.508v8.984c0 .287 0 .575.002.862.002.24.005.481.012.722.014.526.043 1.057.136 1.576.095.528.25 1.02.495 1.5a5.03 5.03 0 0 0 2.205 2.203c.48.244.97.4 1.498.495.52.093 1.05.124 1.576.138.241.007.483.009.724.01.287.002.573.002.86.002h8.984c.287 0 .573 0 .86-.002.241-.001.483-.003.724-.01a10.523 10.523 0 0 0 1.578-.138 5.322 5.322 0 0 0 1.498-.495 5.035 5.035 0 0 0 2.203-2.203c.245-.48.4-.972.495-1.5.093-.52.124-1.05.138-1.576.007-.241.009-.481.01-.722.002-.287.002-.575.002-.862V7.508c0-.287 0-.573-.002-.86a33.662 33.662 0 0 0-.01-.724 10.5 10.5 0 0 0-.138-1.576 5.328 5.328 0 0 0-.495-1.5A5.039 5.039 0 0 0 21.152.645 5.32 5.32 0 0 0 19.654.15a10.493 10.493 0 0 0-1.578-.138 34.98 34.98 0 0 0-.722-.01C17.067 0 16.779 0 16.492 0H7.508zm6.035 3.41c4.114 2.47 6.545 7.162 5.549 11.131-.024.093-.05.181-.076.272l.002.001c2.062 2.538 1.5 5.258 1.236 4.745-1.072-2.086-3.066-1.568-4.088-1.043a6.803 6.803 0 0 1-.281.158l-.02.012-.002.002c-2.115 1.123-4.957 1.205-7.812-.022a12.568 12.568 0 0 1-5.64-4.838c.649.48 1.35.902 2.097 1.252 3.019 1.414 6.051 1.311 8.197-.002C9.651 12.73 7.101 9.67 5.146 7.191a10.628 10.628 0 0 1-1.005-1.384c2.34 2.142 6.038 4.83 7.365 5.576C8.69 8.408 6.208 4.743 6.324 4.86c4.436 4.47 8.528 6.996 8.528 6.996.154.085.27.154.36.213.085-.215.16-.437.224-.668.708-2.588-.09-5.548-1.893-7.992z`})}),android:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M18.4395 5.5586c-.675 1.1664-1.352 2.3318-2.0274 3.498-.0366-.0155-.0742-.0286-.1113-.043-1.8249-.6957-3.484-.8-4.42-.787-1.8551.0185-3.3544.4643-4.2597.8203-.084-.1494-1.7526-3.021-2.0215-3.4864a1.1451 1.1451 0 0 0-.1406-.1914c-.3312-.364-.9054-.4859-1.379-.203-.475.282-.7136.9361-.3886 1.5019 1.9466 3.3696-.0966-.2158 1.9473 3.3593.0172.031-.4946.2642-1.3926 1.0177C2.8987 12.176.452 14.772 0 18.9902h24c-.119-1.1108-.3686-2.099-.7461-3.0683-.7438-1.9118-1.8435-3.2928-2.7402-4.1836a12.1048 12.1048 0 0 0-2.1309-1.6875c.6594-1.122 1.312-2.2559 1.9649-3.3848.2077-.3615.1886-.7956-.0079-1.1191a1.1001 1.1001 0 0 0-.8515-.5332c-.5225-.0536-.9392.3128-1.0488.5449zm-.0391 8.461c.3944.5926.324 1.3306-.1563 1.6503-.4799.3197-1.188.0985-1.582-.4941-.3944-.5927-.324-1.3307.1563-1.6504.4727-.315 1.1812-.1086 1.582.4941zM7.207 13.5273c.4803.3197.5506 1.0577.1563 1.6504-.394.5926-1.1038.8138-1.584.4941-.48-.3197-.5503-1.0577-.1563-1.6504.4008-.6021 1.1087-.8106 1.584-.4941z`})}),lovable:(0,Z.jsx)(`svg`,{viewBox:`0 0 180 180`,fill:`currentColor`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M54.6052 0C83.9389 0 107.719 23.8424 107.719 53.2535V73.4931H125.395C154.729 73.4931 178.508 97.3355 178.508 126.747C178.508 156.158 154.729 180 125.395 180H1.4917V53.2535C1.4917 23.8424 25.2714 0 54.6052 0Z`})}),json:(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,Z.jsx)(`path`,{d:`M8 3.5A2.5 2.5 0 0 0 5.5 6v3A2.5 2.5 0 0 1 3 11.5 2.5 2.5 0 0 1 5.5 14v4A2.5 2.5 0 0 0 8 20.5M16 3.5A2.5 2.5 0 0 1 18.5 6v3a2.5 2.5 0 0 0 2.5 2.5 2.5 2.5 0 0 0-2.5 2.5v4a2.5 2.5 0 0 1-2.5 2.5`})})},it=new Set([`DESIGN.md`,`tokens.json`,`theme.css`,`install.md`,`MANIFEST.md`]),$={antd:`Ant Design`,bootstrap:`Bootstrap`,daisyui:`daisyUI`,mantine:`Mantine`,material:`Material`,openprops:`Open Props`,radix:`Radix Themes`,shadcn:`shadcn/ui`,tailwind:`Tailwind`};function at(e,t){let n={},r=e=>`'${e}', ${u.includes(e)?`serif`:v.includes(e)?`monospace`:`sans-serif`}`;return ot(e.fontBody,t.fontBody)&&(n.fontBody=r(e.fontBody)),ot(e.fontDisplay,t.fontDisplay)&&(n.fontHeading=r(e.fontDisplay)),n}var ot=(e,t)=>e!==t&&e!==`System`&&!l(e),st=(e,t)=>[...new Set([e.fontDisplay,e.fontBody].filter((e,n)=>ot(e,n===0?t.fontDisplay:t.fontBody)))];function ct({cfg:e,base:n,table:r,vars:i,projectName:a,kitDoorName:o,shareUrl:c,files:l,fontCss:u,notes:d,painted:f,anchors:h,kit:g,kitValues:_,readPageVars:v,onClose:y,send:b,tells:x=[]}){let[S,w]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!0;return fe(l,r,i,u).then(t=>{e&&w(t)}),()=>{e=!1}},[l,r,i,u]);let T=(0,C.useMemo)(()=>{let e=r.identityVars();return Object.keys(i).filter(t=>i[t]!==e[t]).length},[r,i]),je=(0,C.useMemo)(()=>{let e=r.identityVars();return new Set(r.entries.filter(t=>i[ie(t.id)]!==void 0&&i[ie(t.id)]!==e[ie(t.id)]).flatMap(e=>e.sites.map(e=>e.file)).filter(e=>e&&!/^<|runtime|inline/.test(e))).size},[r,i]),E=S?.length||je,[D,O]=(0,C.useState)(null),[k,A]=(0,C.useState)(null);(0,C.useEffect)(()=>{if(A(null),!g){O(null);return}let t=!0,s=ce(r,i,e.cPrimary,{display:e.fontDisplay,body:e.fontBody},{painted:f,anchors:h}),c=T===0?`none of them changed`:`${T} of them changed`,l=o?`These values start from ${o} as it ships, read off the build UISandbox made of it: ${s.totals.values} design values, ${c} in this pass. They are written here in the names this kit publishes, so they are the ones to build against.`:`These values were read off ${a}'s own CSS in UISandbox, not chosen: ${s.totals.values} design values out of its stylesheets, ${c} in this pass. They are written here in the names this kit publishes, so they are the ones to build against.`,u=at(e,n),d={...nt(s),..._,...u,elevation:String(e.sb.shadow??1),spaceScale:String(e.sb.space??1)};return oe(g,d,a,{overview:l}).then(e=>{if(v&&e[`theme.css`]){let t=v(ue(e[`theme.css`])),n=ne[g]??{};for(let e of Object.keys(u))for(let r of[n[e]?.var,...n[e]?.also??[]])r&&delete t[r];e={...e,"theme.css":_e(e[`theme.css`],t).css}}t&&O(se(e))}).catch(e=>{t&&(O(null),A(e instanceof Error?e.message:String(e)))}),()=>{t=!1}},[g,_,v,r,i,e,n,a,o,f,h,T]);let j=D?Object.keys(D).find(e=>e.endsWith(`/SKILL.md`)):void 0,M=(0,C.useMemo)(()=>[{id:`design-md`,label:`DESIGN.md`,sub:`your design system, as agents read it`,icon:(0,Z.jsx)(Te,{size:15,strokeWidth:1.75}),file:`DESIGN.md`,how:D?[`Save this as DESIGN.md in the root of your repo, and SKILL.md where its tab says.`,`It is written in ${$[g]}'s own variable names, because that is what this build runs on.`,`Then ask: apply DESIGN.md and SKILL.md, screen by screen.`]:[`Save this as DESIGN.md in the root of your repo.`,`Add the AGENTS.md block (next tab) so your agent picks it up on every task.`,`Then ask: apply DESIGN.md to the UI.`],make:()=>D?.[`DESIGN.md`]??Ge(r,i,e,a,{notes:d,painted:f,anchors:h,webfonts:st(e,n)})},{id:`agents-md`,label:`AGENTS.md`,sub:`the one line that points at it`,icon:(0,Z.jsx)(ye,{size:15,strokeWidth:1.75}),file:`AGENTS.snippet.md`,how:[`Append this to AGENTS.md in your repo root. No AGENTS.md yet? Make one with this in it.`,`Claude Code reads CLAUDE.md instead. The same block works there, and in GEMINI.md or .cursorrules.`,`It is a block to add, not a file to overwrite: your build and test instructions stay where they are.`],make:()=>Je(a,{moved:T})},{id:`dtcg`,label:`Design tokens`,sub:`W3C format, for Figma and Style Dictionary`,icon:(0,Z.jsx)(ke,{size:15,strokeWidth:1.75}),file:`design.tokens.json`,how:[`Save as design.tokens.json. This is the W3C Design Tokens format (2025.10), not a format of ours.`,`Import it in Tokens Studio for Figma, or point Style Dictionary at it to build for any platform.`,`It describes the app we measured. Values we could not express in the format were left out rather than bent to fit.`],make:()=>D?.[`tokens.json`]??$e(r,i,e,a,{painted:f,anchors:h})},...D&&j?[{id:`skill-md`,label:`SKILL.md`,sub:`how to build screens in this system`,icon:(0,Z.jsx)(ye,{size:15,strokeWidth:1.75}),file:j,how:[`Save it at ${j}. Claude Code loads it on its own when the work is UI, so nobody has to remember to paste it.`,`DESIGN.md says what is true; this says what to do: one primary action per view, how controls group, where motion comes from, in ${$[g]}'s own classes.`,`Every class it names is one that kit publishes.`],make:()=>D[j]},{id:`kit-theme`,label:`theme.css`,sub:`${$[g]}'s own variables, set`,icon:(0,Z.jsx)(xe,{size:15,strokeWidth:1.75}),file:`theme.css`,how:[`Import it after the kit, so your values win.`,`Every variable in it belongs to the kit that publishes it; nothing in it is ours.`,`install.md says how, and what has to be rebuilt.`],make:()=>D[`theme.css`]},{id:`kit-install`,label:`install.md`,sub:`what to run, in order`,icon:(0,Z.jsx)(Te,{size:15,strokeWidth:1.75}),file:`install.md`,how:[`The steps to make the kit wear these values, including any it compiles rather than reads at runtime.`],make:()=>D[`install.md`]},{id:`kit-manifest`,label:`MANIFEST.md`,sub:`what could not be set, and why`,icon:(0,Z.jsx)(Te,{size:15,strokeWidth:1.75}),file:`MANIFEST.md`,how:[`What this theme writes that the kit never reads, and what the kit has no component for. Read it before you trust a knob that seems to do nothing.`],make:()=>D[`MANIFEST.md`]},...Object.keys(D).filter(e=>!it.has(e)&&e!==j).map(e=>({id:`kit-extra:${e}`,label:e,sub:`install.md says where it goes`,icon:(0,Z.jsx)(we,{size:15,strokeWidth:1.75}),file:e,how:[`${$[g]} needs this beside theme.css; install.md says how to use it.`],make:()=>D[e]}))]:[],{id:`files`,label:S===null?`Preparing…`:S.length?`${S.length} file${S.length===1?``:`s`} changed`:`Nothing changed yet`,sub:`your CSS and HTML, new values in place`,icon:(0,Z.jsx)(we,{size:15,strokeWidth:1.75}),file:`patched-files.txt`,how:[`Your own files, whole, with the new values written in place.`,`Use Everything (.zip) at the top right to get them as real files in their original folders, ready to diff.`,`This is the complete change: a find and replace cannot tell a 12px radius from 12px of padding, and this can.`],make:()=>(S??[]).map(e=>`/* ===== ${e.path} ===== */\n${e.text}`).join(`
|
|
339
|
+
|
|
340
|
+
`)||`/* Turn a knob first, then your CSS and HTML appear here with the new values written in. */`},{id:`sheet-patch`,label:`Find and replace`,sub:`one line per value, per file`,icon:(0,Z.jsx)(De,{size:15,strokeWidth:1.75}),file:`sandbox-patch.txt`,how:[`One line per value: what it was, what it is now, and the file it sits in.`,`Hand it to an agent ("apply this patch list to my source"), or run the replacements yourself.`,`Shorter to read than the patched files, but blind to context: check radius against padding before replacing.`],make:()=>ge(r,i)},{id:`sheet-changed`,label:`Changed only`,sub:`just what you turned`,icon:(0,Z.jsx)(Se,{size:15,strokeWidth:1.75}),file:`sandbox-changes.css`,how:[`The values you turned, under names of our own making.`,`A reference to read, diff or hand over as a spec. It is not a drop-in stylesheet: your CSS never mentions these names, so pasting it on its own changes nothing.`,`To make the change land, use Patch your own files.`],make:()=>me(r,i,{changedOnly:!0})},{id:`sheet-css`,label:`Every value`,sub:`the whole sheet, as a list`,icon:(0,Z.jsx)(xe,{size:15,strokeWidth:1.75}),file:`sandbox-values.css`,how:[`Every design value we found in the build, with how often it is used and where.`,`The census behind everything else in this dialog. Useful to read, not to paste.`],make:()=>me(r,i)},{id:`sheet-json`,label:`JSON`,sub:`the same, machine-readable`,icon:(0,Z.jsx)(Ce,{size:15,strokeWidth:1.75}),file:`sandbox-values.json`,how:[`Every value with its kind, its old value, its new one, and the places it is used.`,`For scripts and codemods: this is the sheet in the shape a program wants.`],make:()=>le(r,i)},{id:`tokens-tw`,label:`Tailwind`,sub:`theme block for your config`,icon:(0,Z.jsx)(Ae,{size:15,strokeWidth:1.75}),file:`tailwind.tokens.js`,how:[`Paste into the theme block of your tailwind.config.`,`Names are ours, not your app's. This starts a system rather than patching one.`],make:()=>Fe(e)},{id:`tokens-shadcn`,label:`shadcn`,sub:`--background, --primary, …`,icon:(0,Z.jsx)(be,{size:15,strokeWidth:1.75}),file:`shadcn.css`,how:[`Replace the :root and .dark blocks in your globals.css with these.`,`The variable names are the ones shadcn/ui components already read.`],make:()=>Le(e)},{id:`tokens-css`,label:`tokens.css`,sub:`a full --k-* system`,icon:(0,Z.jsx)(ke,{size:15,strokeWidth:1.75}),file:`tokens.css`,how:[`A complete token system seeded from your values: colour ramps, a type scale, spacing, z-index, breakpoints.`,`Link it before your own stylesheet and build against the variables.`,`These are new names, not the ones your app uses. To change the app you already have, use Patch your own files instead.`],make:()=>Ne(e)},{id:`tokens-json`,label:`tokens.json`,sub:`the same system, as JSON`,icon:(0,Z.jsx)(Ce,{size:15,strokeWidth:1.75}),file:`tokens.json`,how:[`The same generated system in JSON, with the decisions that produced it.`,`For the W3C interchange format, use Design tokens under Hand it to your agent.`],make:()=>Pe(e)},{id:`ios-swift`,label:`Swift`,sub:`constants for SwiftUI and UIKit`,icon:(0,Z.jsx)(ve,{size:15,strokeWidth:1.75}),file:`DesignTokens.swift`,how:[`Drop into your Xcode target and reference the constants from SwiftUI or UIKit.`],make:()=>ze(e)},{id:`ios-assets`,label:`Asset catalog`,sub:`colour sets, light and dark`,icon:(0,Z.jsx)(Ee,{size:15,strokeWidth:1.75}),file:`DesignTokens.xcassets.txt`,how:[`Colour sets with light and dark variants.`,`Everything (.zip) writes these out as a real .xcassets folder you can drag into Xcode.`],make:()=>Be(e).map(e=>`// ${e.path}\n${e.content}`).join(`
|
|
341
|
+
`)},{id:`android-xml`,label:`colors.xml`,sub:`resources, light and night`,icon:(0,Z.jsx)(Oe,{size:15,strokeWidth:1.75}),file:`colors.xml`,how:[`The first block goes in res/values/colors.xml, the second in res/values-night/colors.xml.`],make:()=>Ve(e)+`
|
|
342
|
+
`+Ve(e,`dark`)},{id:`android-kt`,label:`Compose`,sub:`Kotlin constants`,icon:(0,Z.jsx)(Oe,{size:15,strokeWidth:1.75}),file:`DesignTokens.kt`,how:[`Drop into your theme package and reference from your Compose theme.`],make:()=>He(e)}],[e,r,i,S,a,d,f,h,T,D,j,g]),Me={bgTone:`ΔL`},N=(e,t)=>{if(t===void 0)return`as is`;let n=String(t);if(!/^-?[\d.]+$/.test(n))return n;let r=Number(n),i=m.find(t=>t.key===e)?.unit??Me[e]??`×`;return i===`×`?`×${n}`:i===`°`?`${n}°`:i===`em`?`${n}em`:r>0?`+${n}`:n},P=(0,C.useMemo)(()=>{let t=[],r=(e,n,r)=>{t.push({label:re(e),from:n,to:r,swatch:/^#/.test(r)})},i=new Set([...Object.keys(n),...Object.keys(e)]);for(let t of i){let i=n[t],a=e[t];if(JSON.stringify(i)!==JSON.stringify(a)){if(t===`sb`){let e=i??{},t=a??{};for(let n of new Set([...Object.keys(e),...Object.keys(t)]))JSON.stringify(e[n])!==JSON.stringify(t[n])&&r(n,N(n,e[n]),N(n,t[n]));continue}r(String(t),String(i),String(a))}}return t},[e,n]),F=[{title:D?`Design system + Skill`:`Hand it to your agent`,sub:D?`DESIGN.md and a SKILL.md in ${$[g]}'s own classes, so Claude Code, Cursor or Codex builds in this look`:g&&k?`DESIGN.md and one line in AGENTS.md. This build runs on ${$[g]}, but its SKILL.md could not be written: ${k}`:g?`DESIGN.md and one line in AGENTS.md. Writing the SKILL.md in ${$[g]}'s own classes…`:g===null?`DESIGN.md and one line in AGENTS.md. No SKILL.md: this build runs on none of the nine kits, so there are no published classes for one to cite`:`DESIGN.md and one line in AGENTS.md. Still reading which kit this build runs on…`,icon:(0,Z.jsx)(ye,{size:15,strokeWidth:1.75}),ids:D?[`design-md`,`skill-md`,`agents-md`,`dtcg`,`kit-theme`,`kit-install`,`kit-manifest`,...Object.keys(D).filter(e=>!it.has(e)&&e!==j).map(e=>`kit-extra:${e}`)]:[`design-md`,`agents-md`,`dtcg`],reco:!0,uses:[[Q.claude,`Claude Code`],[Q.cursor,`Cursor`],[Q.openai,`Codex`],[Q.figma,`Figma`]]},{title:`Patch your own files`,sub:`your CSS and HTML with the new values written in, or a find and replace list`,icon:(0,Z.jsx)(we,{size:15,strokeWidth:1.75}),ids:[`files`,`sheet-patch`],uses:[[Q.css,`CSS`],[Q.html,`HTML`],[null,`any repo`]]},{title:`The raw sheet`,sub:`every value we found and what it is now. A reference to read, not a stylesheet to paste`,icon:(0,Z.jsx)(xe,{size:15,strokeWidth:1.75}),ids:[`sheet-changed`,`sheet-css`,`sheet-json`],uses:[[Q.css,`CSS`],[Q.json,`JSON`]]},{title:`Tailwind or shadcn`,sub:`a theme block for your config, or the block shadcn/ui components already read`,icon:(0,Z.jsx)(Ae,{size:15,strokeWidth:1.75}),ids:[`tokens-tw`,`tokens-shadcn`],uses:[[Q.tailwind,`Tailwind`],[Q.shadcn,`shadcn/ui`],[Q.lovable,`Lovable`]]},{title:`A fresh token system`,sub:`a full set seeded from these values, under new names. For starting a system, not patching one`,icon:(0,Z.jsx)(ke,{size:15,strokeWidth:1.75}),ids:[`tokens-css`,`tokens-json`],uses:[[Q.css,`CSS`],[Q.json,`JSON`],[null,`Style Dictionary`]]},{title:`Native apps`,sub:`Swift constants, an asset catalog, Android resources`,icon:(0,Z.jsx)(Oe,{size:15,strokeWidth:1.75}),ids:[`ios-swift`,`ios-assets`,`android-xml`,`android-kt`],uses:[[Q.swift,`SwiftUI`],[Q.android,`Android`]]}],Ie=new Set([`Patch your own files`,`The raw sheet`]),I=o?F.filter(e=>!Ie.has(e.title)):F,[L,R]=(0,C.useState)(`overview`);(0,C.useEffect)(()=>{let e=e=>{e.key===`Escape`&&y()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[y]);let[z,B]=(0,C.useState)(!1),[V,H]=(0,C.useState)(!1),Re=async()=>{let e=M.find(e=>e.id===`design-md`)?.make()??``,t=M.find(e=>e.id===`skill-md`)?.make(),n=D?.[`theme.css`],r={gradients:`gradients as decoration`,"dark-only":`a dark mode with no light one`},i=[...new Set([...x.filter(e=>!e.knobs&&r[e.id]).map(e=>r[e.id]),...de])],s=[o?`Restyle this app, built on ${o}, to the design system below. It was made in UISandbox.`:`Restyle ${a} to the design system below. It was made in UISandbox from this app's own CSS.`,`Use only its tokens${t?` and the components SKILL.md names`:``}. Do not fall back to the defaults, and add no raw colours, one-off sizes or new fonts.`,``,`Keep the layout clear of the generic AI look. Avoid:`,...i.map(e=>`- ${e}`),...n?[``,`--- theme.css (put this in your global stylesheet) ---`,n]:[],``,`--- DESIGN.md ---`,e,...t?[``,`--- SKILL.md ---`,t]:[]].join(`
|
|
343
|
+
`);await navigator.clipboard.writeText(s),H(!0),setTimeout(()=>H(!1),2400)},U=M.find(e=>e.id===L),W=U?I.find(e=>e.ids.includes(U.id)):void 0,G=(0,C.useMemo)(()=>U?U.make():``,[U]),K=(e,t)=>{let n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=e,n.click(),setTimeout(()=>URL.revokeObjectURL(n.href),2e3)};return(0,Z.jsx)(`div`,{className:`dialog__backdrop`,onClick:y,children:(0,Z.jsxs)(`div`,{className:`card dialog dialog--narrow`,role:`dialog`,"aria-label":`Export`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`dialog__head`,children:[U?(0,Z.jsxs)(`button`,{type:`button`,className:`btn btn--ghost btn--sm`,onClick:()=>{R(`overview`),B(!1)},children:[(0,Z.jsx)(s,{size:14}),` Export`]}):(0,Z.jsxs)(`h2`,{children:[`Take it home `,(0,Z.jsx)(`span`,{className:`exp__h2sub`,children:`exactly what is in the sandbox`})]}),(0,Z.jsx)(`span`,{className:`stage__spacer`,style:{flex:1}}),(0,Z.jsx)(he,{url:c??null}),(0,Z.jsx)(`button`,{type:`button`,className:`btn btn--ghost btn--icon`,onClick:y,"aria-label":`Close`,children:(0,Z.jsx)(p,{size:15})})]}),U?(0,Z.jsxs)(`div`,{className:`dialog__pane`,children:[(0,Z.jsxs)(`div`,{className:`exp__head`,children:[(0,Z.jsx)(`span`,{className:`exp__ico exp__ico--lg`,children:W?.icon}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`b`,{children:W?.title}),(0,Z.jsx)(`span`,{className:`exp__headsub`,children:W?.sub})]}),(0,Z.jsx)(`span`,{className:`stage__spacer`,style:{flex:1}}),(0,Z.jsx)(`div`,{className:`exp__tabs`,role:`tablist`,children:(W?.ids??[]).map(e=>{let t=M.find(t=>t.id===e);return(0,Z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===L,className:`exp__tab ${e===L?`exp__tab--on`:``}`,onClick:()=>{R(e),B(!1)},children:t.label},e)})})]}),(0,Z.jsx)(`ol`,{className:`exp__how`,children:U.how.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))}),(0,Z.jsx)(`pre`,{children:G}),(0,Z.jsxs)(`div`,{className:`dialog__tools`,children:[(0,Z.jsxs)(`span`,{children:[U.file,` · `,G.length.toLocaleString(),` chars`]}),(0,Z.jsx)(`span`,{className:`stage__spacer`}),(0,Z.jsxs)(`button`,{type:`button`,className:`btn btn--ghost btn--sm`,onClick:async()=>{await navigator.clipboard.writeText(G),B(!0),setTimeout(()=>B(!1),1500)},children:[z?(0,Z.jsx)(ee,{size:13,strokeWidth:2}):(0,Z.jsx)(te,{size:13,strokeWidth:2}),` `,z?`Copied`:`Copy`]}),(0,Z.jsxs)(`button`,{type:`button`,className:`btn btn--secondary btn--sm`,onClick:()=>K(U.file,new Blob([G],{type:`text/plain`})),children:[(0,Z.jsx)(t,{size:13,strokeWidth:2}),` Download`]})]})]}):(0,Z.jsxs)(`div`,{className:`exp__overview`,children:[(0,Z.jsxs)(`div`,{className:`exp__home`,children:[(0,Z.jsxs)(`div`,{className:`exp__homebtns`,children:[b&&(0,Z.jsxs)(`div`,{className:`exp__opt`,children:[(0,Z.jsx)(pe,{to:b.to,onSend:b.onSend}),(0,Z.jsx)(`span`,{className:`exp__optnote`,children:`Straight to the agent in your project.`})]}),(0,Z.jsxs)(`div`,{className:`exp__opt`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`btn ${b?`btn--secondary`:`btn--primary`} exp__homebtn`,onClick:()=>void Re(),children:[V?(0,Z.jsx)(ee,{size:15,strokeWidth:2}):(0,Z.jsx)(te,{size:15,strokeWidth:2}),` `,V?`Copied. Paste it into your AI`:`Copy for your AI`]}),(0,Z.jsx)(`span`,{className:`exp__optnote`,children:`One paste and it restyles the app you have.`})]}),(0,Z.jsxs)(`div`,{className:`exp__opt`,children:[o?(0,Z.jsxs)(`button`,{type:`button`,className:`btn btn--secondary exp__homebtn`,onClick:()=>{D&&K(`${(o??a).replace(/[^\w.-]+/g,`-`).replace(/^-|-$/g,``)}-design-system.zip`,ae(Object.entries(D).map(([e,t])=>({name:e,text:t}))))},disabled:!D,title:D?`theme.css, DESIGN.md, SKILL.md, tokens.json, install.md and MANIFEST.md`:`Writing the design system…`,children:[(0,Z.jsx)(t,{size:15,strokeWidth:2}),` Design system + Skill (.zip)`]}):(0,Z.jsxs)(`button`,{type:`button`,className:`btn btn--secondary exp__homebtn`,onClick:()=>{let t=M.filter(e=>e.id!==`files`).map(e=>({name:e.file,data:e.make()}));for(let n of Be(e))t.push({name:n.path,data:n.content});for(let e of S??[])t.push({name:`patched/${e.path}`,data:e.text});t.unshift({name:`README.md`,data:rt(a,M.filter(e=>e.id!==`files`).map(e=>({name:e.file,what:e.sub??e.label})),{moved:T,total:r.entries.length,changedFiles:S?.length??0})}),K(`${a.replace(/[^\w.-]+/g,`-`)}-uisandbox.zip`,ae(t.map(e=>({name:e.name,text:e.data}))))},children:[(0,Z.jsx)(t,{size:15,strokeWidth:2}),` Everything (.zip)`]}),(0,Z.jsx)(`span`,{className:`exp__optnote`,children:o?`Kept in your repo, so screens you build later get the look too.`:`The changed files and every format, to apply by hand.`})]})]}),!b&&(0,Z.jsxs)(`p`,{className:`exp__homenote`,children:[`Works in Claude Code, Cursor, Codex, Lovable and v0. To send it straight in, run `,(0,Z.jsx)(`code`,{children:`npx uisandbox-mcp open`}),` in your project.`]})]}),(0,Z.jsxs)(`div`,{className:`exp__stats`,children:[(0,Z.jsxs)(`div`,{className:`exp__stat`,children:[(0,Z.jsx)(`b`,{children:T}),(0,Z.jsxs)(`span`,{children:[`of `,r.entries.length,` values moved`]})]}),!o&&(0,Z.jsxs)(`div`,{className:`exp__stat`,children:[(0,Z.jsx)(`b`,{children:E}),(0,Z.jsxs)(`span`,{children:[`file`,E===1?``:`s`,` changed`]})]}),(0,Z.jsxs)(`div`,{className:`exp__stat`,children:[(0,Z.jsx)(`b`,{children:P.length}),(0,Z.jsxs)(`span`,{children:[`knob`,P.length===1?``:`s`,` turned`]})]})]}),(0,Z.jsxs)(`details`,{className:`exp__dest exp__more`,children:[(0,Z.jsx)(`summary`,{className:`exp__sec`,children:`Other formats: your own files, Tailwind or shadcn, tokens, native`}),(0,Z.jsx)(`div`,{className:`exp__destgrid`,children:I.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`exp__card`,onClick:()=>{R(e.ids[0]),B(!1)},children:[(0,Z.jsx)(`span`,{className:`exp__ico`,children:e.icon}),(0,Z.jsxs)(`span`,{className:`exp__text`,children:[(0,Z.jsxs)(`span`,{className:`exp__label`,children:[e.title,e.reco&&(0,Z.jsx)(`em`,{className:`exp__reco`,children:`start here`})]}),(0,Z.jsx)(`span`,{className:`exp__sub2`,children:e.sub}),(0,Z.jsx)(`span`,{className:`exp__uses`,children:e.uses.map(([e,t])=>(0,Z.jsxs)(`span`,{className:`exp__use`,children:[e,t]},t))})]})]},e.title))})]}),P.length?(0,Z.jsxs)(`div`,{className:`exp__turned`,children:[(0,Z.jsxs)(`h3`,{className:`exp__sec`,children:[`Settings, from `,o?`the kit`:`your code`,` → the sandbox`]}),(0,Z.jsx)(`div`,{className:`exp__cols`,children:P.map((e,t)=>(0,Z.jsxs)(`div`,{className:`exp__row`,children:[(0,Z.jsx)(`span`,{className:`exp__rowlabel`,children:e.label}),(0,Z.jsxs)(`span`,{className:`exp__from`,children:[/^#/.test(e.from)&&(0,Z.jsx)(`span`,{className:`fmrow__dot`,style:{background:e.from,width:10,height:10}}),e.from]}),(0,Z.jsx)(`span`,{className:`exp__arrow`,children:`→`}),(0,Z.jsxs)(`span`,{className:`exp__to`,children:[e.swatch&&(0,Z.jsx)(`span`,{className:`fmrow__dot`,style:{background:e.to,width:10,height:10}}),e.to]})]},t))})]}):(0,Z.jsxs)(`p`,{className:`exp__none`,children:[`Nothing turned yet: every export is `,o?`${o} as it ships`:`your code's own stand`,` (the identity). Turn a knob and this list says exactly what changed.`]})]})]})})}export{ct as ExportDialog};
|