From 58a0a7bede83c27b38fa802990fe6b1c35cfdd0d Mon Sep 17 00:00:00 2001 From: DoodleBear Date: Thu, 1 Oct 2026 05:27:52 +0900 Subject: [PATCH] feat: the copy button belongs to the field, and looks like it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was in the sidebar, where it read as one more control among forty — which is what it was, as a piece of markup. But the argument is not that. You tuned THE FIELD, so the button that takes the tuning away belongs to the field, and putting it at the bottom of the sticky stage says that without a word: the thing you adjusted now carries the thing that takes your adjustment away. It also stops being a control and becomes the page's primary action. Everything else on this page exists to help you ARRIVE at a setting — forty controls, one of them primary would mean nothing. This is the one that lets you LEAVE with it, so it is the only primary, full width, spanning both of the stage's columns. That is a hierarchy claim, not a styling preference: if there are two primaries, neither is. var(--accent) rather than a hex, so the dark scheme and any future theme follow — the token table is the whole reason to have tokens. The focus ring is offset because the button IS the accent, and an accent outline drawn on an accent fill is invisible; that one is easy to get wrong precisely because it only fails on the element you just made primary. The grid needed one line of care: .playground-stage is `auto minmax(0, 1fr)`, so the button would have taken the controls column and squeezed the field. `grid-column: 1 / -1`. A test asserts the placement — in the stage, not in the sidebar — because placement is the requirement here and a visual regression is harder to catch than a DOM assertion. 177 tests (was 176), oxlint 0, both changelog ledgers. --- CHANGELOG.md | 2 + CHANGELOG.zh.md | 2 + apps/site/src/components/Playground.tsx | 9 +-- apps/site/src/components/ShowcaseCopy.tsx | 2 +- apps/site/src/styles/site.css | 73 +++++++++++++++-------- apps/site/test/playground.test.tsx | 11 ++++ 6 files changed, 68 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20fb8f9..c26150c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Changed +- **The copy button moved to the bottom of the field, and became the page's only primary action.** It was in the sidebar, where it read as one more control among forty. But you tuned _the field_, so the button that takes the tuning away belongs to the field: it now sits inside the sticky stage, spanning both columns, full width, in the accent colour. Everything else on this page exists to help you arrive at a setting; this is the one that lets you leave with it, and it should look like the difference. `var(--accent)` rather than a hex, so dark mode and any future theme follow — and the focus ring is offset, because the button _is_ the accent and an accent outline against an accent fill is invisible. + - **The playground can hand you its own settings.** A copy button next to the readout copies the install command, the `` element with the settings you arrived at already in it, and the stylesheet import — so the paste needs nothing else, and neither do you. It is a prompt rather than a component alone because a component with no way to install it is half an instruction. **Only the options you changed are emitted**, because a snippet carrying `fill={1} peak={1} floor={0.16}` on every copy says nothing about what you chose and goes stale when a default moves; touch nothing and you get ``, and the names are the real props — a snippet that looks right and does not compile is the same failure as a card redrawing its own dots. The description beside the motion is read out of the engine's own preset table, so it cannot drift from the card. Falls back to selectable text when the clipboard is refused, rather than a button that silently does nothing. - **The playground now opens on a hand-picked showcase state** rather than the engine's defaults: 5×5 with no gap at the largest size, `dot/cell` at 198% so the dots overlap into one surface, `grow` at 3% so a dot moves rather than pulses, `stagger` pinned at 70% so picking another motion does not move a slider under the visitor, square silhouette and square dots at radius 0. The engine's own defaults are untouched — that is the library's choice and the page is allowed to disagree — so the values live in a named `SHOWCASE` beside the component, each with the reason it was picked. diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md index 4bf2913..18b5547 100644 --- a/CHANGELOG.zh.md +++ b/CHANGELOG.zh.md @@ -4,6 +4,8 @@ ### 变更 +- **复制按钮移到了场的底部,并且成了全站唯一的主操作。** 它原先在右侧栏,读起来像四十个控件中的又一个。但你调的是**这个场**,所以把调好的东西带走的按钮属于这个场:它现在位于 sticky stage 内部、跨两列、满宽、用 accent 色。这个页面上其他一切都是为了帮你"调到某个值"而存在的;只有这一个是为了让你带着值离开,它也应该看起来就是那个区别。用 `var(--accent)` 而非硬编码色值,深色模式和以后换主题都会跟着走 —— focus ring 做了偏移,因为按钮**就是** accent,accent 描边压在 accent 填充上是看不见的。 + - **Playground 现在能把自己的配置交给你。** readout 旁的复制按钮会复制安装命令、已经带上你调过参数的 `` 元素,以及样式表 import —— 所以粘贴之后不需要再打开这个页面,你也不需要。它复制的是一段 prompt 而不只是组件,因为没有安装方式的组件只是半条指令。**只输出你真正改过的参数**:每次都附上 `fill={1} peak={1} floor={0.16}` 既没有说明你选了什么,又会在默认值变动时过期;什么都没动就得到 ``,而 prop 名用的是真名 —— 看着对却编译不过的片段,和卡片自己重画点,是同一种错。动效旁边那行说明是从引擎自己的 preset 表里读出来的,所以不会和卡片对不上。剪贴板被拒绝时回退为可选中的文本,而不是一个什么都不做也不吭声的按钮。 - **Playground 现在开在一组手工挑的 showcase 参数上**,而不是引擎默认值:最大尺寸的 5×5、无间距、`dot/cell` 198% 让点连成一整块面、`grow` 3% 让点是"移动"而不是"脉动"、`stagger` 固定在 70% 以免换个动效就把访客正看着的滑杆挪走、剪影和点都是方形且圆角为 0。引擎自己的默认值没有动 —— 那是库的选择,页面被允许不同意 —— 所以这些值放在组件旁边一个具名的 `SHOWCASE` 里,每一项都写明为什么选它。 diff --git a/apps/site/src/components/Playground.tsx b/apps/site/src/components/Playground.tsx index 39c4ed1..ad96b05 100644 --- a/apps/site/src/components/Playground.tsx +++ b/apps/site/src/components/Playground.tsx @@ -162,6 +162,11 @@ export function Playground({ initial }: { initial?: Partial }) renderer={cssRenderer ? "css" : "svg"} key={`${options.preset ?? DEFAULTS.preset}-${options.silhouette}-${options.cols}x${options.rows}-${options.dot}`} /> + {/* The way out, under the field rather than in the sidebar: you tuned this THING, + and the button that takes it away belongs to the thing. Spans both columns — + it is a full-width primary action, not another sidebar control, and a control + that reads as primary should look like one rather than like a ghost button. */} + {/* Shape, as pictures. Two groups because the engine has two shapes: the field's @@ -369,10 +374,6 @@ export function Playground({ initial }: { initial?: Partial }) `${m.readout_renderer()} ${cssRenderer ? "css" : "svg"} ${m.readout_speed()} ${m.value_speed({ value: (options.speed ?? 1).toFixed(2) })}`, ].join("\n")} - - {/* The readout is where a visitor has just SEEN the numbers, so the way out is - right here — a copy button over the settings they arrived at. */} - ); diff --git a/apps/site/src/components/ShowcaseCopy.tsx b/apps/site/src/components/ShowcaseCopy.tsx index deb29ec..297e82b 100644 --- a/apps/site/src/components/ShowcaseCopy.tsx +++ b/apps/site/src/components/ShowcaseCopy.tsx @@ -32,7 +32,6 @@ export function ShowcaseCopy({ tuning }: { tuning: Tuning }) { return (
-

{m.showcase_note()}

+

{m.showcase_note()}

{/* Always rendered, never conditionally: a `manual` state has to have something to select. Hidden with CSS rather than unmounted so the text stays in the DOM. */} diff --git a/apps/site/src/styles/site.css b/apps/site/src/styles/site.css index 706f9c4..ebaf3d6 100644 --- a/apps/site/src/styles/site.css +++ b/apps/site/src/styles/site.css @@ -167,53 +167,74 @@ h3 { cursor: pointer; } -/* The carried-away settings. Same visual language as .install so the two read as one - idea at two sizes — a command to run, and the component that follows from it. */ +/* The carried-away settings: the primary action of the playground, so it reads as one. + + It sits inside .playground-stage, which is a two-column grid (controls | field), so it + spans both — a full-width button under the field. Placing it here rather than in the + sidebar is the argument: you tuned THIS field, so the button that takes the tuning away + belongs to the field. In the sidebar it read as one more control among forty. */ .showcase-copy { - border: 1px solid var(--line); - background: var(--card); - border-radius: var(--radius); - margin-top: 14px; + grid-column: 1 / -1; + display: flex; + flex-direction: column; + gap: 10px; } .showcase-copy-head { display: flex; - align-items: center; - gap: 12px; - padding: 12px 14px; -} - -.showcase-copy-head p { - flex: 1; - margin: 0; - font-size: 13px; - color: var(--muted); + flex-direction: column; + gap: 7px; } +/* PRIMARY, and the only primary control on the page. Copying is the one thing a visitor + came here to do with what they tuned; everything else on this page is for arriving at a + setting, not for leaving with it. `var(--accent)` rather than a hex so the dark scheme + and any future theme follow. */ .showcase-copy button { font: inherit; - font-size: 13px; - border: 1px solid var(--line); - background: transparent; - color: var(--muted); - border-radius: 8px; - padding: 4px 10px; + font-size: 14px; + font-weight: 500; + width: 100%; + border: 1px solid transparent; + background: var(--accent); + color: #fff; + border-radius: 10px; + padding: 10px 16px; cursor: pointer; - white-space: nowrap; + transition: filter 120ms ease; +} + +.showcase-copy button:hover { + filter: brightness(1.08); +} + +.showcase-copy button:focus-visible { + outline: 2px solid var(--accent); + /* the button IS the accent, so an accent outline would be invisible against it — + offset against the field instead */ + outline-offset: 3px; +} + +.showcase-copy-head p { + margin: 0; + font-size: 12px; + color: var(--muted); } .showcase-copy-body { margin: 0; padding: 12px 14px; - border-top: 1px solid var(--line); + border: 1px solid var(--line); + border-radius: 10px; + background: var(--bg); font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre; } -/* Collapsed by default: the snippet is long, and the page is about the field. When a - clipboard write is refused the body becomes the thing to select, so it shows then. */ +/* Folded away by default: the snippet is long and the page is about the field. When a + clipboard write is refused this becomes the thing to select, so it appears then. */ .showcase-copy-body[aria-hidden="true"] { display: none; } diff --git a/apps/site/test/playground.test.tsx b/apps/site/test/playground.test.tsx index e154bb4..e736f91 100644 --- a/apps/site/test/playground.test.tsx +++ b/apps/site/test/playground.test.tsx @@ -876,6 +876,17 @@ describe("copying the tuning away", () => { expect(copyBody().textContent).toContain("npx"); }); + it("lives inside the sticky stage, not in the sidebar", () => { + // the argument for the placement: you tuned the FIELD, so the button that takes the + // tuning away belongs to the field. In the sidebar it read as one more control. + const stage = container.querySelector(".playground-stage")!; + expect(stage.querySelector(".showcase-copy"), "inside the sticky stage").toBeTruthy(); + expect( + container.querySelector(".playground-side .showcase-copy"), + "and not back in the sidebar", + ).toBeNull(); + }); + it("keeps the snippet out of the way until it is needed", () => { stubClipboard(); expect(copyBody().getAttribute("aria-hidden"), "long text, folded away by default").toBe(