diff --git a/CHANGELOG.md b/CHANGELOG.md index d14f3a5..f2e9ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,8 @@ All notable changes to BotUI are recorded here. The format follows ### Fixed +- **`softness`, `grow` and `floor` were on the page but could not be reached.** They sat below the fold of a side column holding 1001px of content in an 813px viewport, under a grid of picture cards, in a column with no visible bottom — "there is no way to adjust these" was a position bug, not a missing control. The side column is now sticky with its own scrollport, the picture cards moved beside the field they describe, and the three moved ahead of the geometric detail as their own group, because what a field _feels_ like is asked before how big it is. The readout moved below the playground: it is output, not input, and it was the cheapest 112px in the column. + - **Three playground sliders were broken in the same way, and none of the tests could see it.** `radius`, `aspect` and `speed` passed the raw 0…1 option against a track measured in hundredths. Radius `0.7` on a `0…90` track put the thumb at 0.8% of the travel, which is why diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md index d464f57..edf9c52 100644 --- a/CHANGELOG.zh.md +++ b/CHANGELOG.zh.md @@ -60,6 +60,8 @@ BotUI 的所有值得注意的变更都记录在此。格式遵循 ### 修复 +- **`softness`、`grow`、`floor` 一直在页面上,只是够不到。** 它们落在侧栏的折叠线以下 —— 813px 视口里塞了 1001px 的内容,上面压着一组图片卡片,而这个列看不到底部 —— "这三个没法调"是位置问题,不是控件缺失。现在侧栏 sticky 且有独立滚动区,图片卡片移到它所描述的预览旁边,而这三个被提到几何细节之前、独立成组:点阵"感觉如何"总比"有多大"先被问到。readout 移到了 playground 下方 —— 它是输出不是输入,而且是侧栏里最便宜的 112px。 + - **三个 playground 滑杆以同一种方式坏掉,而当时的测试全都看不出来。** `radius`、`aspect`、 `speed` 把 0…1 的原始值传给了以百分之一为单位的轨道。radius `0.7` 落在 `0…90` 的轨道上, 滑块停在全程的 0.8%,所以"感觉拉不动";`speed` 1 落在 `5…300` 上、`aspect` 1 落在 diff --git a/apps/site/messages/en.json b/apps/site/messages/en.json index 26230e0..ebd25f3 100644 --- a/apps/site/messages/en.json +++ b/apps/site/messages/en.json @@ -103,5 +103,6 @@ "scope_field_shape": "Changes the outline of the whole field", "scope_dot_shape": "Changes each individual dot", "scope_motion": "Hover or focus a card to play it", - "group_timing": "Timing" + "group_timing": "Timing", + "group_envelope": "Envelope" } diff --git a/apps/site/messages/zh.json b/apps/site/messages/zh.json index b44abc7..fe9fb5a 100644 --- a/apps/site/messages/zh.json +++ b/apps/site/messages/zh.json @@ -103,5 +103,6 @@ "scope_field_shape": "改变整个点阵的外轮廓", "scope_dot_shape": "改变每一个点本身", "scope_motion": "悬停或聚焦卡片即可播放", - "group_timing": "节奏" + "group_timing": "节奏", + "group_envelope": "包络" } diff --git a/apps/site/src/components/Playground.tsx b/apps/site/src/components/Playground.tsx index f2245bf..2d8ced1 100644 --- a/apps/site/src/components/Playground.tsx +++ b/apps/site/src/components/Playground.tsx @@ -103,6 +103,28 @@ export function Playground({ initial }: { initial?: Partial }) {/* Shape, as pictures. Two groups because the engine has two shapes: the field's outline and the dot inside it. A single slider list called them both "shape" and left the reader to guess which was which. */} + set({ preset: preset as PresetName })} + options={PRESET_KEYS.map((key) => ({ value: key, label: taskLabel(key) }))} + columns={3} + renderPreview={(value) => ( + + )} + /> + }) only half-conveys it. These run the engine, and only once you reach them — twelve fields animating at once is a page that melts the laptop it is trying to sell a component for. */} - set({ preset: preset as PresetName })} - options={PRESET_KEYS.map((key) => ({ value: key, label: taskLabel(key) }))} - columns={3} - renderPreview={(value) => ( - - )} - /> - {/* speed and stagger stay sliders: both are continuous, and a still frame cannot show a rate at all — the label is the honest representation */} @@ -206,6 +206,32 @@ export function Playground({ initial }: { initial?: Partial }) /> + {/* The envelope, its breath and its floor, ahead of the geometric detail. + They change what a field FEELS like rather than how big it is, and they + were the three the page was reported as having "no way to adjust" — a 20px + overflow in an 813px viewport put them below the fold, under a side column + nobody could see the bottom of. */} + + set({ softness: v / 100 })} + /> + set({ grow: v / 100 })} + /> + set({ floor: v / 100 })} + /> + + {/* the polygon is a slider because it is a NUMBER: the cards show named glyphs, and `sides` is what reaches the ones with no name — a 7-gon, a 9-gon */} @@ -240,24 +266,6 @@ export function Playground({ initial }: { initial?: Partial }) display={percent(options.spec?.aspect ?? 1)} onChange={(aspect) => setSpec({ aspect })} /> - set({ softness: v / 100 })} - /> - set({ grow: v / 100 })} - /> - set({ floor: v / 100 })} - /> diff --git a/apps/site/src/styles/site.css b/apps/site/src/styles/site.css index 4124264..1715b43 100644 --- a/apps/site/src/styles/site.css +++ b/apps/site/src/styles/site.css @@ -369,23 +369,6 @@ footer { margin-top: 20px; } -.playground-stage { - display: grid; - place-items: center; - min-height: 300px; - border: 1px solid var(--line); - border-radius: var(--radius); - background: var(--card); - /* the field is sized in px by the component; the pane must not stretch it */ - overflow: hidden; - color: var(--ink); - /* The control column is far taller than the field, so on a wide screen the field - would sit stranded at the top with a column of empty space beside it. Sticky - keeps the thing you are adjusting in view while you drag the thing adjusting it. */ - position: sticky; - top: 20px; -} - .playground-controls { display: flex; flex-direction: column; @@ -395,7 +378,7 @@ footer { .playground-field { display: flex; flex-direction: column; - gap: 4px; + gap: 2px; font-size: 12px; } @@ -425,7 +408,7 @@ footer { background: var(--card); border: 1px solid var(--line); border-radius: 8px; - padding: 5px 8px; + padding: 4px 8px; } .playground-check { @@ -441,6 +424,12 @@ footer { font-size: 11px; } +.playground-note:empty { + display: none; +} + +/* the refusal note: shown only when the engine actually refuses a motion, so it + reserves no space when the renderer can express what is selected */ .playground-note { color: var(--muted); font-size: 12px; @@ -480,10 +469,10 @@ footer { border: 0; border-top: 1px solid var(--line); margin: 0; - padding: 12px 0 0; + padding: 9px 0 0; display: flex; flex-direction: column; - gap: 9px; + gap: 7px; } .playground-group:first-of-type { @@ -529,7 +518,7 @@ footer { .playground-side { display: flex; flex-direction: column; - gap: 16px; + gap: 10px; min-width: 0; } @@ -537,14 +526,47 @@ footer { dot size are what you reach for while looking at the field — how many dots, how fat — so they belong to the thing they change. `z-index` is load-bearing: the engine paints its SVG into this box, and an overlay without it sits UNDER the dots. */ -.playground-stage { +/* Both columns are sticky, at the same offset, so they scroll as one. Sticky on the + stage alone left the sliders half a page below the fold: at a 900px viewport the + side column's `softness`, `grow` and `floor` sat at y≈1356, unreachable until you had + scrolled past two card groups — which is what "there is no way to adjust these" was. + A control you cannot see is a control you cannot find, and the whole page is about + adjusting things while looking at them. */ +.playground-stage, +.playground-side { position: sticky; - top: 20px; + /* 8px, not 20px: the side column is 817px of content and a 20px offset left a + 773px box, so `softness`, `grow` and `floor` — the three the report was about — + sat just below the fold again. Both columns share the offset so they scroll as + one; the columns are independent scrollers, not one pane. */ + top: 8px; +} + +/* A sticky element taller than its scrollport stops sticking — it scrolls with the page + from the top, which is the original bug. Capping the column at the viewport and + letting it scroll internally keeps every slider reachable however short the window + is. Only the side column needs this; the stage is bounded by its own content. */ +.playground-side { + max-height: calc(100vh - 16px); + overflow-y: auto; + padding-right: 4px; + /* the scrollbar was eating 20px of the column's width, which is 20px the sliders + did not get. `auto` lets the browser decide and most of them overlay it. */ + scrollbar-width: thin; +} + +.playground-stage { display: grid; grid-template-columns: auto minmax(0, 1fr); + border: 1px solid var(--line); + border-radius: var(--radius); + background: var(--card); + /* the field is sized in px by the component; the pane must not stretch it */ + overflow: hidden; + color: var(--ink); align-items: center; gap: 20px; - padding: 16px; + padding: 12px; min-height: 0; } @@ -634,7 +656,7 @@ footer { border: 0; border-top: 1px solid var(--line); margin: 0; - padding: 12px 0 0; + padding: 9px 0 0; min-width: 0; } @@ -654,7 +676,7 @@ footer { /* The scope line is the whole point of splitting shape into two groups: it says, in the same place on every group, whether the cards change the field or each dot. */ .card-scope { - margin: 0 0 8px; + margin: 0 0 5px; font-size: 11px; color: var(--muted); } @@ -662,15 +684,15 @@ footer { .card-grid { display: grid; grid-template-columns: repeat(var(--cards, 4), minmax(0, 1fr)); - gap: 6px; + gap: 4px; } .card { display: flex; flex-direction: column; align-items: center; - gap: 2px; - padding: 6px 2px 4px; + gap: 1px; + padding: 4px 2px 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); @@ -706,8 +728,14 @@ footer { place-items: center; color: var(--ink); /* fixed, not intrinsic: a row of cards where the label wraps to two lines for one - value and one line for another leaves the pictures on different baselines */ - height: 52px; + value and one line for another leaves the pictures on different baselines. + 52 -> 40: the side column is 1520px of content in an 813px viewport, so every + pixel of card height is a pixel of scrolling somebody has to do to reach + `softness`. The BOX shrinks; the dot grid inside it does not — 3x3 was measured + at 5 distinct brightness levels for both spiral and snake against 11 at 5x5, so + shrinking the grid would make the two hardest presets to tell apart, well, + impossible. */ + height: 40px; } .card-label { @@ -721,7 +749,7 @@ footer { -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; - min-height: 2.5em; + min-height: 1.3em; } .card[data-selected] .card-label { diff --git a/apps/site/test/playground.test.tsx b/apps/site/test/playground.test.tsx index 1aa6f34..20c1394 100644 --- a/apps/site/test/playground.test.tsx +++ b/apps/site/test/playground.test.tsx @@ -156,6 +156,42 @@ describe("the playground controls", () => { expect(readout()).toContain("ring"); }); + it("the sliders people reported as unreachable come before the ones nobody opens first", () => { + // `softness`, `grow` and `floor` were reported as having "no way to adjust them". + // They were on the page the whole time: the side column was 1001px of content in an + // 813px viewport, so they sat below the fold of a column nobody could see the + // bottom of, under a card grid above them. Position is the bug, not absence, and + // only an ORDER assertion catches a regression here — a test that checked the + // controls exist would have passed while they were unreachable. + // by index rather than by string search on the joined text: the legend is CSS + // `text-transform: uppercase`d on screen but the DOM text is `Envelope`, and a + // lowercase `.indexOf` found nothing while the control was right there + const legends = [...container.querySelectorAll(".playground-side .playground-group")].map( + (g) => g.querySelector("legend")?.textContent ?? "", + ); + const order = legends.join("|"); + const envelopeAt = legends.findIndex((l) => /envelope|包络/i.test(l)); + const detailAt = legends.findIndex((l) => /dot detail/i.test(l)); + expect(envelopeAt, `ENVELOPE must exist in the side column: ${order}`).toBeGreaterThanOrEqual( + 0, + ); + expect(envelopeAt, "the envelope sliders must come BEFORE the geometric detail").toBeLessThan( + detailAt, + ); + + // and the three of them are the ones named, in this order + const envelope = [...container.querySelectorAll(".playground-side .playground-group")].find( + (g) => /envelope|包络/i.test(g.querySelector("legend")?.textContent ?? ""), + ); + const labels = [...(envelope?.querySelectorAll(".playground-field") ?? [])].map((f) => + (f.querySelector("span")?.textContent ?? "").slice(0, 14), + ); + expect(labels).toHaveLength(3); + expect(labels[0]).toMatch(/softness|波宽/i); + expect(labels[1]).toMatch(/grow|呼吸/i); + expect(labels[2]).toMatch(/floor|底噪/i); + }); + it("a card group is one tab stop with one selection, not a grid of buttons", () => { // A grid of