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
10 changes: 10 additions & 0 deletions .changeset/voice-meter-fills-card.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@schlessera/brain-ui-kit": patch
---

Voice surface review fixes (#3746):

- **Live cards.** The tall `VoiceField`'s meter now fills the whole card in every mode: the level bars, the thinking/working sweep, the muted line and the reconnecting hatch. A top fade across the label row keeps the state label readable.
- **Dictation.** While a state label shows (D3–D5), the compact field anchors the label to the top and the words to the bottom, over a fade that blends the meter into the field behind the words.
- **Text backgrounds.** Text in the field no longer has a solid background of its own. It reads through the fades and a soft halo in the field's colour.
- **Start card.** "What's shared ›" sits closer under Start, with its 44px target kept.
8 changes: 5 additions & 3 deletions packages/ui-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,11 @@ state onto them and owns every timer, permission and connection.
`fail` (red, only End and failures). `VOICE_SKINS` names the
`--bk-voice-*` tokens behind it.
- `meter` shows the `level` prop (0–1) as bars, a `sweep` (thinking/working), a
`flat` line (muted) or a paused `hatch` (reconnecting). The words and the
state label sit on the field's opaque ground, so the meter never lowers text
contrast.
`flat` line (muted) or a paused `hatch` (reconnecting). The meter fills the
whole card. Text has no background of its own. In the compact field with a
label, the label sits at the top and the words at the bottom, over a fade into
the field's ground. In the tall field, a top fade holds the label row. A soft
halo in the field's ground surrounds every glyph.
- `MicButton` draws `idle`, `pressed`, `holding` (the ring from `progress`) and
`complete`, plus the "Keep holding to talk live" hint. It hands every pointer
and key event to the caller, which owns the hold threshold. `onTalkLive` adds
Expand Down
31 changes: 22 additions & 9 deletions packages/ui-kit/src/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,12 @@ html:has(dialog.bk-overlay[open]:modal) { overflow: hidden; }
.bk-voice-field[data-outline="true"] { border-width: 1.5px; border-color: var(--bk-color-ink-dim); }
.bk-voice-field[data-shape="compact"] { height: 52px; padding: 0 6px 0 16px; flex-direction: row; align-items: center; gap: 8px; }
.bk-voice-field[data-shape="compact"][data-labelled="true"] { height: 84px; }
/* While a state label shows (D3–D5), the label anchors to the top of the card
* and the words to the bottom, with the meter's bars between and around them.
* A gradient over the meter fades the bars into the field's ground behind the
* words, so the words read clearly (#3746). */
.bk-voice-field[data-shape="compact"][data-labelled="true"] .bk-voice-body { justify-content: space-between; padding: 9px 0 8px; }
.bk-voice-field[data-shape="compact"][data-labelled="true"] > .bk-voice-meter::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 58px; background-image: linear-gradient(to bottom, transparent, var(--bk-voice-ground) 18px); }
.bk-voice-field[data-shape="tall"] { height: 136px; padding: 10px 10px 10px 16px; }
.bk-voice-field[data-shape="card"] { padding: 14px; gap: 12px; border-radius: 20px; }
.bk-voice-body { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; flex: 1 1 auto; min-width: 0; align-self: stretch; }
Expand All @@ -2783,20 +2789,25 @@ html:has(dialog.bk-overlay[open]:modal) { overflow: hidden; }
* bottom-aligned, so a long dictation scrolls up out of the top. */
.bk-voice-text { font: 400 13.5px/20px "Plus Jakarta Sans", sans-serif; color: var(--bk-color-ink); max-height: 40px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; overflow-wrap: anywhere; }
.bk-voice-text-partial { color: var(--bk-color-ink-mute); }
/* Words and the state label sit on the field's opaque ground, line by line:
* the meter shows around them, never under a glyph. */
.bk-voice-text > span, .bk-voice-field[data-shape="compact"] .bk-voice-label > span:not(.bk-voice-label-meta) { background: var(--bk-voice-ground); -webkit-box-decoration-break: clone; box-decoration-break: clone; border-radius: 4px; }
.bk-voice-text > span { padding: 1px 2px; margin: 0 -2px; }
/* Text in the field has no background of its own (maintainer direction,
* #3746). It reads through the meter's fades (bottom in the compact field,
* top in the tall one) and a soft halo in the field's own ground drawn around
* each glyph. */
.bk-voice-text, .bk-voice-label { text-shadow: 0 0 2px var(--bk-voice-ground), 0 0 8px var(--bk-voice-ground); }
.bk-voice-text-placeholder { color: var(--bk-color-ink-mute); }

.bk-voice-label { display: flex; align-items: center; gap: 6px; min-width: 0; font: 600 12px/16px "Plus Jakarta Sans", sans-serif; color: var(--bk-voice-ink); }
.bk-voice-label-icon { display: inline-flex; flex: none; }
.bk-voice-label-meta { margin-left: auto; padding-left: 8px; font: 500 10.5px/16px "JetBrains Mono", ui-monospace, monospace; color: var(--bk-color-ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-voice-label-meta { margin-left: auto; padding: 0 2px; font: 500 10.5px/16px "JetBrains Mono", ui-monospace, monospace; color: var(--bk-color-ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The meter sits BEHIND the words: a band across the field, clipped to its
* corners, never a target. */
/* The meter sits BEHIND the words and fills the whole card in every shape and
* mode (#3746), clipped to its corners, never a target. */
.bk-voice-meter { position: absolute; inset: 0; z-index: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.bk-voice-field[data-shape="tall"] > .bk-voice-meter { top: 30px; bottom: 6px; border-radius: 0 0 21px 21px; }
/* The tall field fades its meter into the field's ground across the label
* row: solid to 28px, clear by 50px. The label and meta read on the ground
* with no chip behind them, and the sweep, hatch and bars show below (#3746).
* `::after`, so it paints over the meter's own layers. */
.bk-voice-field[data-shape="tall"] > .bk-voice-meter::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 50px; background-image: linear-gradient(to bottom, var(--bk-voice-ground) 28px, transparent); }
.bk-voice-bars { position: absolute; inset: 6px 12px; display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.bk-voice-bar { flex: 0 0 3px; min-height: 2px; border-radius: 2px; background: var(--bk-voice-bar); transition: height 90ms linear; }
.bk-voice-level { display: none; position: absolute; left: 12px; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: var(--bk-voice-bar); }
Expand Down Expand Up @@ -2865,7 +2876,9 @@ html:has(dialog.bk-overlay[open]:modal) { overflow: hidden; }
.bk-voice-card-notice > .bk-voice-label-icon { padding-top: 1px; }
.bk-voice-start { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; margin: 0; border: 0; border-radius: 999px; background: var(--bk-teal-fill); color: var(--bk-on-fill); font: 600 15px/1 "Plus Jakarta Sans", sans-serif; cursor: pointer; }
.bk-voice-start[aria-disabled="true"] { opacity: .45; cursor: default; }
.bk-voice-shared { align-self: center; }
/* Its 44px target keeps its size but is pulled into the card gap and padding
* (#3746), so the link sits close under Start rather than in a 44px band. */
.bk-voice-shared { align-self: center; margin: -10px 0 -12px; }
.bk-voice-shared-list { margin: 0; padding: 0 0 0 18px; font: 400 12px/18px "Plus Jakarta Sans", sans-serif; color: var(--bk-color-ink-dim); }

/* Spoken turns in the chat: small inline marks, never diagnostics. */
Expand Down
21 changes: 21 additions & 0 deletions packages/ui-kit/stories/voice/Dictation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,27 @@ export const LongDestinationAt320 = meta.story({
},
});

/**
* While listening or finishing, the state label anchors to the top of the card
* and the words to the bottom, over a gradient that fades the meter behind
* them (#3746).
*/
export const LabelTopWordsBottom = meta.story({
render: () => <>{(["D3", "D4", "D5"] as const).map((id) => <div key={id} style={{ width: "100%" }}>{dictation(id)}</div>)}</>,
play: async ({ canvasElement }) => {
for (const field of canvasElement.querySelectorAll<HTMLElement>(".bk-voice-field")) {
const box = field.getBoundingClientRect();
const label = field.querySelector("[data-voice-label]")!.getBoundingClientRect();
const words = field.querySelector(".bk-voice-text")!.getBoundingClientRect();
const word = field.querySelector("[data-voice-word]")!.textContent;
await expect(Math.round(label.top - box.top), `${word}: label anchored to the top`).toBeLessThanOrEqual(10);
await expect(Math.round(box.bottom - words.bottom), `${word}: words attached to the bottom`).toBeLessThanOrEqual(10);
const fade = getComputedStyle(field.querySelector(".bk-voice-meter")!, "::after").backgroundImage;
await expect(fade, `${word}: gradient behind the words`).toContain("linear-gradient");
}
},
});

/** Reduced motion: one static level line, a flat tint for the sweep, a still ✓. */
export const ReducedMotion = meta.story({
parameters: { stageWidth: "none" },
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-kit/stories/voice/Live.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import preview from "#.storybook/preview";
import { expect, type within } from "storybook/test";

import { stage } from "../_stage.js";
import { fieldHeights, reducedMotion, voiceA11y } from "./_checks.js";
import { fieldHeights, meterFillsTheCard, reducedMotion, voiceA11y } from "./_checks.js";
import { LIVE_TITLES, Sheet, live, type LiveId } from "./_voice.js";

/**
Expand Down Expand Up @@ -250,6 +250,8 @@ export const AllStates = meta.story({
play: async ({ canvasElement }) => {
await expect(canvasElement.querySelectorAll("[data-state]")).toHaveLength(17);
await voiceA11y(canvasElement);
// L1–L5, L7, L8 and the five overlay forms from #3738 (drafts, notices, recovery).
await expect(await meterFillsTheCard(canvasElement), "every tall state with a meter").toBe(12);
},
});

Expand Down
7 changes: 7 additions & 0 deletions packages/ui-kit/stories/voice/Start.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export const S2StartCard = meta.story({
await expect(canvas.queryByRole("button", { name: /Change service/ }), "no Change with one service").toBeNull();
await expect(canvas.getByRole("radio", { name: /Ithaca steward/ })).toHaveAttribute("aria-checked", "true");
const shared = canvas.getByRole("button", { name: /What’s shared/ });
// Close under Start, with its full 44px target (#3746).
const start = canvas.getByRole("button", { name: "Start" }).getBoundingClientRect();
const text = document.createRange();
text.selectNodeContents(shared);
await expect(Math.round(text.getBoundingClientRect().top - start.bottom), "What’s shared sits close under Start").toBeLessThanOrEqual(16);
await expect(shared.getBoundingClientRect().height, "44px target kept").toBeGreaterThanOrEqual(44);
await expect(shared.getBoundingClientRect().top, "target clear of Start").toBeGreaterThanOrEqual(start.bottom);
await userEvent.click(shared);
await expect(shared).toHaveAttribute("aria-expanded", "true");
await expect(canvas.getByText(/Audio is not saved/)).toBeVisible();
Expand Down
35 changes: 35 additions & 0 deletions packages/ui-kit/stories/voice/_checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function targetOf(button: HTMLElement): { width: number; height: number } {
* - every control's target is at least 44px on both axes (an inline
* uncertain word is text, and exempt as inline text is; an inline text
* button's target is its box plus the `::before` that extends it);
* - text in the field has no background of its own; it carries a halo in the
* field's ground, and the tall label row sits in the meter's solid top
* fade (#3746);
* - nothing escapes the story's column (except the thinking sweep, which
* travels across its meter and is clipped by it, and the contents of the
* out-of-sight "Talk live…" button, clipped by its own 1px box).
Expand All @@ -45,6 +48,20 @@ export async function voiceA11y(root: HTMLElement) {
await expect(label.querySelector("svg"), "state label has an icon").not.toBeNull();
await expect(label.querySelector("[data-voice-word]")?.textContent?.trim(), "state label has a word").toBeTruthy();
}
for (const text of root.querySelectorAll<HTMLElement>("[data-voice-word], .bk-voice-label-meta, .bk-voice-text")) {
const field = text.closest<HTMLElement>(".bk-voice-field");
if (!field) continue;
const name = text.textContent?.trim().slice(0, 24);
await expect(getComputedStyle(text).backgroundColor, `${name}: no text background`).toBe("rgba(0, 0, 0, 0)");
for (const inner of text.querySelectorAll("span")) await expect(getComputedStyle(inner).backgroundColor, `${name}: no text background`).toBe("rgba(0, 0, 0, 0)");
await expect(getComputedStyle(text).textShadow, `${name}: halo in the field's ground`).not.toBe("none");
const meter = field.querySelector(":scope > .bk-voice-meter");
if (field.dataset.shape === "tall" && meter && !text.matches(".bk-voice-text")) {
// The tall label row sits in the meter's solid top fade.
await expect(getComputedStyle(meter, "::after").backgroundImage, `${name}: in the top fade`).toContain("linear-gradient");
await expect(text.getBoundingClientRect().bottom, `${name}: within the fade's solid band`).toBeLessThanOrEqual(meter.getBoundingClientRect().top + 28);
}
}
await expect(overflowing(root, "*:not(.bk-voice-sweep):not(.bk-voice-talk-live *)")).toEqual([]);
}

Expand All @@ -67,3 +84,21 @@ export async function reducedMotion(root: HTMLElement) {
for (const el of root.querySelectorAll(".bk-voice-ring-fill")) await expect(getComputedStyle(el).transitionDuration, "ring without easing").toBe("0s");
for (const el of root.querySelectorAll(".bk-voice-field")) await expect(getComputedStyle(el).transitionDuration, "instant shape changes").toBe("0s");
}

/**
* The meter fills the whole card (#3746): in every field with a meter, the
* meter layer's box is the field's padding box, so the sweep, hatch, flat
* line and bars reach every edge.
*/
export async function meterFillsTheCard(root: HTMLElement) {
const fields = [...root.querySelectorAll<HTMLElement>(".bk-voice-field")].filter((f) => f.querySelector(":scope > .bk-voice-meter"));
for (const field of fields) {
const meter = field.querySelector<HTMLElement>(":scope > .bk-voice-meter")!.getBoundingClientRect();
const box = field.getBoundingClientRect();
const inset = { x: field.clientLeft, y: field.clientTop };
const label = field.querySelector("[data-voice-word]")?.textContent ?? field.dataset.shape;
await expect([meter.top - box.top, box.bottom - meter.bottom, meter.left - box.left, box.right - meter.right].map((n) => Math.round(n * 10) / 10), `${label} meter fills the card`)
.toEqual([inset.y, inset.y, inset.x, inset.x]);
}
return fields.length;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading