diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ff12dc..d14f3a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ All notable changes to BotUI are recorded here. The format follows ### Changed +- **The playground's shape and motion controls are pictures now, not sliders.** `sides` and `silhouette` sat in one list under one "shape" heading, so a reader could not tell which moved the whole field and which moved each dot; the silhouette is now a card group whose cards change the field's outline and a second group whose cards change the dot inside it, each stating its scope in the same place. Presets were a ``,它无法表达 `spiral` 和 `ring` 的区别;现在是运行真实引擎的卡片,并且只有指针或焦点移上去时才播放,而不是十二个一起动。 +- 每张卡片画的都是引擎自己的输出 —— 静帧用 `field()`、剪影用 `cellsFor()`、动效用实时点阵。卡片若自己画一个"近似"的点,那就是给它推销的东西写了第二份实现,glyph 代码一改就会漂移。相位刻意不用 0:遍历的动感在于格子之间的**差异**,而在 t=0 所有格子都处于静止,静帧只会显示一团均匀的模糊。 +- 行列改成预览区上的加减步进器,`dot/cell` 也一并移了过去:它们是你盯着点阵时最常调的三个。整体 `size` 挪到最后,因为它决定占多少空间,而不是看起来是什么样。 + - `check-registry.mjs` 现在会在已发布的包缺少 README、`repository` 未指向本仓库、缺少 homepage 或 bugs URL 时让构建失败。 diff --git a/apps/site/messages/en.json b/apps/site/messages/en.json index a20c9cc..26230e0 100644 --- a/apps/site/messages/en.json +++ b/apps/site/messages/en.json @@ -20,9 +20,7 @@ "group_shape": "shape · 形状", "group_size": "size · 尺寸", "group_motion": "motion · 动效", - "ctl_silhouette": "silhouette", "ctl_sides": "sides", - "ctl_glyph": "glyph preset", "ctl_radius": "corner radius", "ctl_aspect": "aspect", "ctl_size": "size", @@ -31,7 +29,6 @@ "ctl_dot_cell": "dot / cell", "ctl_gap_x": "gap x", "ctl_gap_y": "gap y", - "ctl_preset": "preset", "ctl_speed": "speed", "ctl_stagger": "stagger", "ctl_softness": "softness", @@ -100,5 +97,11 @@ "sil_hex": "hexagon", "sil_ring": "ring", "sil_cross": "cross", - "readout_speed": "speed" + "readout_speed": "speed", + "group_dot": "Dot shape", + "group_geometry": "Dot detail", + "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" } diff --git a/apps/site/messages/zh.json b/apps/site/messages/zh.json index 52f4f99..b44abc7 100644 --- a/apps/site/messages/zh.json +++ b/apps/site/messages/zh.json @@ -20,9 +20,7 @@ "group_shape": "形状 shape", "group_size": "尺寸 size", "group_motion": "动效 motion", - "ctl_silhouette": "整体轮廓 silhouette", "ctl_sides": "点边数 sides", - "ctl_glyph": "点预设 glyph", "ctl_radius": "圆角 radius", "ctl_aspect": "拉伸 aspect", "ctl_size": "size", @@ -31,7 +29,6 @@ "ctl_dot_cell": "点占格 dot/cell", "ctl_gap_x": "列间距 gap x", "ctl_gap_y": "行间距 gap y", - "ctl_preset": "preset", "ctl_speed": "速度 speed", "ctl_stagger": "错峰 stagger", "ctl_softness": "波宽 softness", @@ -100,5 +97,11 @@ "sil_hex": "六边", "sil_ring": "圆环", "sil_cross": "十字", - "readout_speed": "速度" + "readout_speed": "速度", + "group_dot": "点的形状", + "group_geometry": "点的细节", + "scope_field_shape": "改变整个点阵的外轮廓", + "scope_dot_shape": "改变每一个点本身", + "scope_motion": "悬停或聚焦卡片即可播放", + "group_timing": "节奏" } diff --git a/apps/site/src/components/Cards.tsx b/apps/site/src/components/Cards.tsx new file mode 100644 index 0000000..9e7474a --- /dev/null +++ b/apps/site/src/components/Cards.tsx @@ -0,0 +1,120 @@ +import type { ReactNode } from "react"; +import { cellsFor, glyphPath, type Silhouette } from "@botharness/botui-core"; + +/** + * A choice you can see rather than a control you have to imagine. + * + * The engine has two independent notions of "shape" that used to sit in one slider + * group, so a slider labelled `sides` sat next to one labelled `silhouette` and a reader + * had no way to know which moved the whole field and which moved each dot. Each card + * therefore carries the SCOPE it acts on, in the same place on every card, so the + * distinction is visible before you click anything: the silhouette row's cards change + * the outline of the whole field, the dot row's cards change each dot inside it. + * + * Selecting is a radio group, not a set of buttons: a screen reader announces "3 of 14" + * and arrow keys move between options, which a grid of buttons does not. `role` and the + * roving tabindex come from the fieldset semantics rather than from JavaScript. + */ +export function CardGroup({ + label, + /** what this group changes, shown once at the top: "the whole field" / "each dot" */ + scope, + value, + options, + onChange, + renderPreview, + columns, +}: { + label: string; + scope: string; + /** the option may legitimately be unset, which is what the engine's own default is */ + value: T | undefined; + options: readonly { value: T; label: string }[]; + onChange: (value: T) => void; + /** the card's visual — the engine's own output, not an illustration of it */ + renderPreview: (value: T) => ReactNode; + /** how many cards per row; the CSS handles wrapping, this sets the target */ + columns?: number; +}) { + return ( +
+ {label} +

{scope}

+
+ {options.map((option) => { + const selected = option.value === value; + return ( + + ); + })} +
+
+ ); +} + +/** + * The field's outline, drawn as the cells that exist. + * + * NOT a `Still`. A still frame at phase 0 runs the motion, and at phase 0 most cells + * sit at the resting level — so `ring` and `circle` both came out as a uniform smudge + * of near-invisible dots, and the card that exists to answer "which cells does this + * silhouette keep?" answered it with "a faint blob". The silhouette is a question about + * the LATTICE, not about the motion, so this asks the lattice directly. + * + * `cellsFor` is the engine's own function, so this cannot disagree with what the field + * below it renders; the only thing decided here is the dot size, chosen to fill the + * cell so the shape reads at 44px. + */ +export function SilhouetteCard({ + value, + size = 44, + cols = 7, + rows = 7, +}: { + value: Silhouette; + size?: number; + cols?: number; + rows?: number; +}) { + const cells = cellsFor(cols, rows, value); + // one dot per cell, at the pitch the engine would use with no gap and a dot that + // fills its cell — so the card shows the shape and not an accident of spacing + const pitch = size / (cols + 1); + const dot = glyphPath({ sides: 4, radius: 0 }).d; + const scale = (pitch * 0.82) / 2; + return ( + + ); +} diff --git a/apps/site/src/components/Matrix.tsx b/apps/site/src/components/Matrix.tsx index 81f3f76..f2a7cf5 100644 --- a/apps/site/src/components/Matrix.tsx +++ b/apps/site/src/components/Matrix.tsx @@ -1,6 +1,8 @@ -import { useEffect, useRef } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { createDotMatrix, + field, + resolveOptions, type DotMatrixHandle, type DotMatrixOptions, } from "@botharness/botui-core"; @@ -54,3 +56,90 @@ export function Matrix({ playing = true, className, ...options }: MatrixProps) { return