Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<DotMatrix>` 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 `<DotMatrix />`, 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.
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### 变更

- **复制按钮移到了场的底部,并且成了全站唯一的主操作。** 它原先在右侧栏,读起来像四十个控件中的又一个。但你调的是**这个场**,所以把调好的东西带走的按钮属于这个场:它现在位于 sticky stage 内部、跨两列、满宽、用 accent 色。这个页面上其他一切都是为了帮你"调到某个值"而存在的;只有这一个是为了让你带着值离开,它也应该看起来就是那个区别。用 `var(--accent)` 而非硬编码色值,深色模式和以后换主题都会跟着走 —— focus ring 做了偏移,因为按钮**就是** accent,accent 描边压在 accent 填充上是看不见的。

- **Playground 现在能把自己的配置交给你。** readout 旁的复制按钮会复制安装命令、已经带上你调过参数的 `<DotMatrix>` 元素,以及样式表 import —— 所以粘贴之后不需要再打开这个页面,你也不需要。它复制的是一段 prompt 而不只是组件,因为没有安装方式的组件只是半条指令。**只输出你真正改过的参数**:每次都附上 `fill={1} peak={1} floor={0.16}` 既没有说明你选了什么,又会在默认值变动时过期;什么都没动就得到 `<DotMatrix />`,而 prop 名用的是真名 —— 看着对却编译不过的片段,和卡片自己重画点,是同一种错。动效旁边那行说明是从引擎自己的 preset 表里读出来的,所以不会和卡片对不上。剪贴板被拒绝时回退为可选中的文本,而不是一个什么都不做也不吭声的按钮。

- **Playground 现在开在一组手工挑的 showcase 参数上**,而不是引擎默认值:最大尺寸的 5×5、无间距、`dot/cell` 198% 让点连成一整块面、`grow` 3% 让点是"移动"而不是"脉动"、`stagger` 固定在 70% 以免换个动效就把访客正看着的滑杆挪走、剪影和点都是方形且圆角为 0。引擎自己的默认值没有动 —— 那是库的选择,页面被允许不同意 —— 所以这些值放在组件旁边一个具名的 `SHOWCASE` 里,每一项都写明为什么选它。
Expand Down
9 changes: 5 additions & 4 deletions apps/site/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export function Playground({ initial }: { initial?: Partial<DotMatrixOptions> })
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. */}
<ShowcaseCopy tuning={{ options, css: cssRenderer }} />
</div>

{/* Shape, as pictures. Two groups because the engine has two shapes: the field's
Expand Down Expand Up @@ -369,10 +374,6 @@ export function Playground({ initial }: { initial?: Partial<DotMatrixOptions> })
`${m.readout_renderer()} ${cssRenderer ? "css" : "svg"} ${m.readout_speed()} ${m.value_speed({ value: (options.speed ?? 1).toFixed(2) })}`,
].join("\n")}
</pre>

{/* 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. */}
<ShowcaseCopy tuning={{ options, css: cssRenderer }} />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/site/src/components/ShowcaseCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export function ShowcaseCopy({ tuning }: { tuning: Tuning }) {
return (
<div className="showcase-copy">
<div className="showcase-copy-head">
<p>{m.showcase_note()}</p>
<button
type="button"
// the same refusal handling as InstallCommand: a clipboard write can fail on an
Expand All @@ -50,6 +49,7 @@ export function ShowcaseCopy({ tuning }: { tuning: Tuning }) {
>
{label}
</button>
<p>{m.showcase_note()}</p>
</div>
{/* 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. */}
Expand Down
73 changes: 47 additions & 26 deletions apps/site/src/styles/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 11 additions & 0 deletions apps/site/test/playground.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading