feat(webui): refine composer action feedback (#6419)
* feat(webui): refine composer action feedback * fix(webui): preserve composer hit targets and ring previews
This commit is contained in:
1 parent
03e9b5430b
commit
6d4add200b
20 files changed
+351
-48
No files matched your search
@@ -179,7 +179,7 @@ OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
## loading.dev Blocks and Ring — loading animations (MIT)
|
||||
|
||||
- **Source**: https://github.com/jakubkrehel/loading/tree/48ff9a1cd5f0446901ff1a8a3d5d5f906d3e36ff
|
||||
- **Adapted**: the diagonal Blocks sweep in `webui/src/components/thread/ThreadHistoryStatus.tsx` and `webui/src/globals.css`, and the circular Ring in `webui/src/components/ChatList.tsx` and `webui/src/globals.css`.
|
||||
- **Adapted**: the diagonal Blocks sweep in `webui/src/components/thread/ThreadHistoryStatus.tsx` and `webui/src/globals.css`, and the circular Ring in `webui/src/components/ui/loading-ring.tsx` and `webui/src/globals.css`.
|
||||
- **Bundled**: `nanobot/web/dist/assets/index-*.{js,css}`
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { useState } from "react";
|
||||
import { ThreadComposer } from "@/components/thread/ThreadComposer";
|
||||
|
||||
export function ComposerActionFixture({ parameters }: { parameters: URLSearchParams }) {
|
||||
const [running, setRunning] = useState(false);
|
||||
const [stopRequested, setStopRequested] = useState(false);
|
||||
return <main className="mx-auto w-full max-w-5xl px-4 pt-24">
|
||||
<ThreadComposer
|
||||
variant={parameters.get("composerVariant") === "thread" ? "thread" : "hero"}
|
||||
modelLabel="Preview"
|
||||
isStreaming={running}
|
||||
onTranscribeAudio={async () => "Voice draft"}
|
||||
onSend={() => { setStopRequested(false); setRunning(true); }}
|
||||
onStop={() => setStopRequested(true)}
|
||||
/>
|
||||
<div className="mt-6 flex gap-4 text-sm">
|
||||
<output aria-label="Execution status">{stopRequested ? "Stop requested" : running ? "Working" : "Idle"}</output>
|
||||
<button onClick={() => { setRunning(false); setStopRequested(false); }}>Finish response</button>
|
||||
<button onClick={() => document.documentElement.classList.toggle("dark")}>Toggle theme</button>
|
||||
</div>
|
||||
</main>;
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
for (const width of [1280, 390]) {
|
||||
for (const variant of ["hero", "thread"]) {
|
||||
test(`composer edge presses send and stop without losing the click (${width}px, ${variant})`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 844 });
|
||||
await page.goto(`/browser/fixture.html?case=composer-action&composerVariant=${variant}`);
|
||||
await page.getByRole("textbox").fill("An edge press");
|
||||
const action = page.locator(".composer-primary-action");
|
||||
await expect(action).toHaveAccessibleName("Send message");
|
||||
for (const status of ["Working", "Stop requested"]) {
|
||||
const bounds = (await action.boundingBox())!;
|
||||
await page.mouse.move(bounds.x + bounds.width - 0.5, bounds.y + bounds.height / 2);
|
||||
await page.mouse.down();
|
||||
// Let the press animation settle before releasing at the same edge point.
|
||||
await page.waitForTimeout(200);
|
||||
await page.mouse.up();
|
||||
await expect(page.getByLabel("Execution status")).toHaveText(status);
|
||||
expect(await action.boundingBox()).toEqual(bounds);
|
||||
}
|
||||
});
|
||||
|
||||
test(`composer actions crossfade without shifting or delaying Stop (${width}px, ${variant})`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 844 });
|
||||
await page.goto(`/browser/fixture.html?case=composer-action&composerVariant=${variant}`);
|
||||
const input = page.getByRole("textbox");
|
||||
const action = page.locator(".composer-primary-action");
|
||||
await expect(action).toHaveAccessibleName("Voice input");
|
||||
const bounds = await action.boundingBox();
|
||||
const pillBounds = await page.locator(".composer-model-pill").boundingBox();
|
||||
expect(bounds!.height).toBe(pillBounds!.height);
|
||||
expect(bounds!.y + bounds!.height / 2).toBe(pillBounds!.y + pillBounds!.height / 2);
|
||||
const model = page.getByText("Preview", { exact: true });
|
||||
const modelBounds = await model.boundingBox();
|
||||
await input.fill("Please work");
|
||||
await expect(action).toHaveAccessibleName("Send message");
|
||||
const samples = await action.evaluate((button) => new Promise<number[]>((resolve) => {
|
||||
const values: number[] = [];
|
||||
const start = performance.now();
|
||||
const sample = () => {
|
||||
values.push(Number(getComputedStyle(button.querySelector('[data-action-icon="send"]')!).opacity));
|
||||
if (performance.now() - start < 200) requestAnimationFrame(sample);
|
||||
else resolve(values);
|
||||
};
|
||||
requestAnimationFrame(sample);
|
||||
}));
|
||||
expect(samples.some((opacity) => opacity > 0 && opacity < 1)).toBe(true);
|
||||
expect(await action.boundingBox()).toEqual(bounds);
|
||||
expect(await model.boundingBox()).toEqual(modelBounds);
|
||||
|
||||
// Reverse mid-transition, then send before the new icon has settled.
|
||||
await input.fill("");
|
||||
await input.fill("A newer draft");
|
||||
await action.click();
|
||||
await expect(action).toHaveAccessibleName("Stop response");
|
||||
const stop = action.locator('[data-action-icon="stop"]');
|
||||
const ring = stop.locator(".loading-ring-arc");
|
||||
await expect.poll(() => ring.evaluate((node) => node.getAnimations().length)).toBe(1);
|
||||
const phase = await ring.evaluate((node) => Number(node.getAnimations()[0].currentTime));
|
||||
await expect.poll(() => ring.evaluate((node) => Number(node.getAnimations()[0].currentTime))).toBeGreaterThan(phase);
|
||||
await action.click();
|
||||
await expect(page.getByLabel("Execution status")).toHaveText("Stop requested");
|
||||
await expect(action).toHaveAccessibleName("Stop response");
|
||||
await expect.poll(() => stop.evaluate((node) => getComputedStyle(node).opacity)).toBe("1");
|
||||
expect(await action.boundingBox()).toEqual(bounds);
|
||||
await page.getByRole("button", { name: "Finish response" }).click();
|
||||
await expect(action).toHaveAccessibleName("Voice input");
|
||||
await expect.poll(() => stop.evaluate((node) => getComputedStyle(node).opacity)).toBe("0");
|
||||
expect(await ring.evaluate((node) => node.getAnimations().length)).toBe(0);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test("composer activity follows both themes and live reduced-motion preferences", async ({ page }) => {
|
||||
await page.goto("/browser/fixture.html?case=composer-action");
|
||||
await page.getByRole("textbox").fill("Run a task");
|
||||
await page.getByRole("button", { name: "Send message", exact: true }).click();
|
||||
const action = page.getByRole("button", { name: "Stop response", exact: true });
|
||||
const ring = action.locator('[data-action-icon="stop"] svg:has(.loading-ring-arc)');
|
||||
const colors: string[] = [];
|
||||
for (const dark of [false, true]) {
|
||||
await page.evaluate((enabled) => document.documentElement.classList.toggle("dark", enabled), dark);
|
||||
colors.push(await ring.evaluate((node) => getComputedStyle(node).color));
|
||||
}
|
||||
expect(colors[0]).not.toBe(colors[1]);
|
||||
for (const reducedMotion of ["reduce", "no-preference"] as const) {
|
||||
await page.emulateMedia({ reducedMotion });
|
||||
await expect.poll(() => ring.evaluate((node) => node.getAnimations({ subtree: true }).length))
|
||||
.toBe(reducedMotion === "reduce" ? 0 : 1);
|
||||
}
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await action.hover();
|
||||
await page.mouse.down();
|
||||
expect(await action.evaluate((node) => getComputedStyle(node).transform)).toBe("none");
|
||||
expect(await action.locator(".composer-action-icons").evaluate((node) => getComputedStyle(node).transform)).toBe("none");
|
||||
await page.mouse.up();
|
||||
await page.getByRole("button", { name: "Finish response" }).click();
|
||||
await page.getByRole("textbox").fill("Another draft");
|
||||
await expect(page.getByRole("button", { name: "Send message", exact: true })).toBeEnabled();
|
||||
expect(await action.count()).toBe(0);
|
||||
});
|
||||
|
||||
|
||||
test("idle voice and ready send remain distinct from the composer in both themes", async ({ page }) => {
|
||||
const measurements = [];
|
||||
for (const variant of ["hero", "thread"]) {
|
||||
for (const theme of ["light", "dark"]) {
|
||||
await page.goto(`/browser/fixture.html?case=composer-action&composerVariant=${variant}`);
|
||||
await page.locator("html").evaluate((element, dark) => element.classList.toggle("dark", dark), theme === "dark");
|
||||
const action = page.locator(".composer-primary-action");
|
||||
for (const [state, value] of [["voice", ""], ["send", "A ready message"]]) {
|
||||
await page.getByRole("textbox").fill(value);
|
||||
await expect(action).toBeEnabled();
|
||||
await expect(action).toHaveAccessibleName(state === "voice" ? "Voice input" : "Send message");
|
||||
await page.waitForTimeout(250);
|
||||
const contrast = await action.evaluate((button) => {
|
||||
const parse = (color: string) => color.match(/[\d.]+/g)!.map(Number);
|
||||
const composite = (foreground: number[], background: number[]) => {
|
||||
const alpha = foreground[3] ?? 1;
|
||||
return background.map((channel, index) => foreground[index] * alpha + channel * (1 - alpha));
|
||||
};
|
||||
const luminance = (color: number[]) => {
|
||||
const channels = color.map((value) => {
|
||||
const channel = value / 255;
|
||||
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
||||
});
|
||||
return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2];
|
||||
};
|
||||
const ratio = (first: number[], second: number[]) => {
|
||||
const a = luminance(first), b = luminance(second);
|
||||
return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
|
||||
};
|
||||
const ancestors: Element[] = [];
|
||||
for (let node = button.parentElement; node; node = node.parentElement) ancestors.unshift(node);
|
||||
let background = [255, 255, 255];
|
||||
for (const node of ancestors) background = composite(parse(getComputedStyle(node).backgroundColor), background);
|
||||
const style = getComputedStyle(button);
|
||||
const surface = composite(parse(style.backgroundColor), background);
|
||||
const glyph = composite(parse(style.color), surface);
|
||||
return { surface: ratio(surface, background), glyph: ratio(glyph, surface) };
|
||||
});
|
||||
expect(contrast.surface, `${variant}/${theme}/${state} button boundary`).toBeGreaterThanOrEqual(3);
|
||||
expect(contrast.glyph, `${variant}/${theme}/${state} icon`).toBeGreaterThanOrEqual(4.5);
|
||||
measurements.push({ variant, theme, state, ...contrast });
|
||||
}
|
||||
}
|
||||
}
|
||||
await test.info().attach("action-contrast", { body: JSON.stringify(measurements, null, 2), contentType: "application/json" });
|
||||
});
|
||||
@@ -34,6 +34,7 @@ import { IdleCompactionFixture, installIdleCompactionApi } from "./idle-compacti
|
||||
import { FileEditPathFixture } from "./file-edit-path-fixture";
|
||||
import { QueuedGuidanceFixture } from "./queued-guidance-fixture";
|
||||
import { WorkspaceAlignmentFixture } from "./workspace-alignment-fixture";
|
||||
import { ComposerActionFixture } from "./composer-action-fixture";
|
||||
|
||||
const history: UIMessage[] = [
|
||||
{ id: "question", role: "user", content: "Earlier question", createdAt: 1_700_000_000_000 },
|
||||
@@ -185,7 +186,9 @@ if (parameters.get("case") === "skeleton-additions") installSkeletonPreviewApi()
|
||||
if (parameters.get("case") === "idle-compaction") installIdleCompactionApi();
|
||||
await initializeI18n();
|
||||
createRoot(document.getElementById("root")!).render(<TooltipProvider>
|
||||
{parameters.get("case") === "workspace-alignment"
|
||||
{parameters.get("case") === "composer-action"
|
||||
? <ComposerActionFixture parameters={parameters} />
|
||||
: parameters.get("case") === "workspace-alignment"
|
||||
? <WorkspaceAlignmentFixture parameters={parameters} />
|
||||
: parameters.get("case") === "queued-guidance"
|
||||
? <QueuedGuidanceFixture />
|
||||
|
||||
@@ -49,6 +49,7 @@ import {
|
||||
import { MAX_WORKBENCH_PANES } from "@/components/workbench/workbench-model";
|
||||
import { SidebarTopicRename } from "@/components/SidebarTopicRename";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { LoadingRing } from "@/components/ui/loading-ring";
|
||||
import {
|
||||
SIDEBAR_SELECTION_ITEM_CLASS,
|
||||
SidebarSelectionHighlight,
|
||||
@@ -1880,12 +1881,6 @@ function ChatsFoldFooter({
|
||||
);
|
||||
}
|
||||
|
||||
function synchronizeRunningRing(element: SVGCircleElement | null) {
|
||||
if (!element) return;
|
||||
// Align pending animations before their first frame, not only after animationstart.
|
||||
for (const animation of element.getAnimations()) animation.startTime = 0;
|
||||
}
|
||||
|
||||
function SessionActivityIndicator({
|
||||
state,
|
||||
}: {
|
||||
@@ -1919,18 +1914,7 @@ function SessionActivityIndicator({
|
||||
aria-label={label}
|
||||
className="grid h-4 w-4 shrink-0 place-items-center"
|
||||
>
|
||||
<svg
|
||||
className="h-3 w-3 text-sidebar-muted-foreground"
|
||||
viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" aria-hidden="true"
|
||||
>
|
||||
<circle cx="12" cy="12" r="10" opacity="0.2" />
|
||||
<circle
|
||||
cx="12" cy="12" r="10" strokeDasharray="16 46.8" strokeLinecap="round"
|
||||
className="sidebar-running-ring"
|
||||
ref={synchronizeRunningRing}
|
||||
onAnimationStart={(event) => synchronizeRunningRing(event.currentTarget)}
|
||||
/>
|
||||
</svg>
|
||||
<LoadingRing className="h-3 w-3 text-sidebar-muted-foreground" />
|
||||
</span>
|
||||
</HoverHint>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { ModelsIcon, StopIcon } from "@/components/icons/product-icons";
|
||||
import { LoadingRing } from "@/components/ui/loading-ring";
|
||||
|
||||
export type ComposerActionState = "voice" | "recording" | "busy" | "stop" | "setup" | "send";
|
||||
|
||||
export function ComposerActionIcon({ state }: { state: ComposerActionState }) {
|
||||
return (
|
||||
<span className="composer-action-icons pointer-events-none relative block h-7 w-7 shrink-0" data-state={state} aria-hidden="true">
|
||||
<span className="composer-action-glyph" data-action-icon="voice" data-active={state === "voice" || undefined}>
|
||||
<svg className="h-6 w-6" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<rect x="9.5" y="4.75" width="5" height="9.5" rx="2.5" fill="currentColor" />
|
||||
<path d="M7 11.25v.5a5 5 0 0 0 10 0v-.5M12 16.75v2.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="send" data-active={state === "send" || undefined}>
|
||||
<svg className="h-6 w-6" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<path d="m8.25 10.25 3.75-3.75 3.75 3.75M12 7v10.5" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="stop" data-active={state === "stop" || undefined}>
|
||||
<LoadingRing track={false} strokeDasharray="12 50.8" className="absolute h-6 w-6 text-foreground/50" strokeWidth="1.5" />
|
||||
<svg className="h-6 w-6" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||||
<rect x="8" y="8" width="8" height="8" rx="1.75" />
|
||||
</svg>
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="recording" data-active={state === "recording" || undefined}>
|
||||
<StopIcon className="h-3.5 w-3.5" fill="currentColor" />
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="busy" data-active={state === "busy" || undefined}>
|
||||
<LoadingRing className="h-4 w-4" />
|
||||
</span>
|
||||
<span className="composer-action-glyph" data-action-icon="setup" data-active={state === "setup" || undefined}>
|
||||
<ModelsIcon className="h-4 w-4" />
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
HelpIcon,
|
||||
HistoryIcon,
|
||||
ConversationIcon,
|
||||
VoiceIcon,
|
||||
AttachIcon,
|
||||
RestartIcon,
|
||||
RestrictedAccessIcon,
|
||||
@@ -53,7 +52,6 @@ import {
|
||||
} from "@/lib/composer-mention-text";
|
||||
import { INLINE_TOKEN_HIGHLIGHT_COLOR } from "@/components/InlineTokenHighlight";
|
||||
import {
|
||||
ArrowUp,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
CornerDownRight,
|
||||
@@ -69,6 +67,7 @@ import {
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ComposerActionIcon, type ComposerActionState } from "@/components/thread/ComposerActionIcon";
|
||||
import {
|
||||
floatingItemClassName,
|
||||
floatingItemFocusClassName,
|
||||
@@ -2480,6 +2479,9 @@ export function ThreadComposer({
|
||||
: t("thread.composer.voice.hint");
|
||||
// Touch users need an explicit send action; keep Stop while sending is unavailable.
|
||||
const showStopButton = isStreaming && !!onStop && !canSend;
|
||||
const actionState: ComposerActionState = showVoiceButton
|
||||
? voiceRecorder.state === "transcribing" ? "busy" : voiceRecorder.isRecording ? "recording" : "voice"
|
||||
: showStopButton ? "stop" : modelNeedsSetup ? "setup" : canSend || !isStreaming ? "send" : "busy";
|
||||
const relaxedHeroInput = isHero && images.length === 0 && !isStreaming;
|
||||
const compactIdle = compactWhenIdle && !compactControls && !isHero && !composerFocused
|
||||
&& value.length === 0 && images.length === 0 && !inlineError
|
||||
@@ -2864,31 +2866,18 @@ export function ThreadComposer({
|
||||
}}
|
||||
onClick={showVoiceButton ? voiceRecorder.handleClick : showStopButton ? handleStop : modelNeedsSetup ? onModelBadgeClick : undefined}
|
||||
className={cn(
|
||||
"thread-composer-action thread-composer-round-action touch-target rounded-full",
|
||||
showStopButton && !showVoiceButton
|
||||
? "border border-border/70 bg-card text-foreground/85 hover:text-foreground disabled:text-muted-foreground/50"
|
||||
: "border border-foreground bg-foreground text-background disabled:border-foreground disabled:bg-foreground disabled:text-background",
|
||||
showVoiceButton && voiceRecorder.isRecording && "border-red-500 bg-red-500 text-white hover:bg-red-500 hover:text-white",
|
||||
"composer-primary-action thread-composer-action thread-composer-round-action touch-target rounded-full bg-clip-padding",
|
||||
actionState === "stop"
|
||||
? "border border-transparent bg-foreground/[0.045] text-foreground/85 hover:bg-foreground/[0.08] hover:text-foreground disabled:text-muted-foreground/50"
|
||||
: actionState === "voice"
|
||||
? "border border-transparent bg-foreground/75 text-background hover:bg-foreground/[0.85] hover:text-background disabled:bg-foreground/[0.12] disabled:text-muted-foreground"
|
||||
: "border border-transparent bg-foreground text-background hover:bg-foreground/90 hover:text-background disabled:border-foreground disabled:bg-foreground disabled:text-background",
|
||||
actionState === "send" && "disabled:border-transparent disabled:bg-foreground/[0.12] disabled:text-muted-foreground",
|
||||
showVoiceButton && voiceRecorder.isRecording && "border-transparent bg-red-500 text-white hover:bg-red-500 hover:text-white",
|
||||
isHero ? "h-8 w-8" : "h-9 w-9",
|
||||
)}
|
||||
>
|
||||
{showVoiceButton ? (
|
||||
voiceRecorder.state === "transcribing" ? (
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
) : voiceRecorder.isRecording ? (
|
||||
<StopIcon className="h-3.5 w-3.5" fill="currentColor" />
|
||||
) : (
|
||||
<VoiceIcon className="h-4 w-4" />
|
||||
)
|
||||
) : showStopButton ? (
|
||||
<StopIcon className={cn("fill-current stroke-current", isHero ? "h-3 w-3" : "h-3.5 w-3.5")} />
|
||||
) : modelNeedsSetup ? (
|
||||
<ModelsIcon className="h-4 w-4" />
|
||||
) : canSend || !isStreaming ? (
|
||||
<ArrowUp className="h-4 w-4" />
|
||||
) : (
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
)}
|
||||
<ComposerActionIcon state={actionState} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
{showVoiceButton ? (
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { SVGProps } from "react";
|
||||
|
||||
function synchronizeRing(element: SVGCircleElement | null) {
|
||||
if (!element) return;
|
||||
// Align the first frame and animations restarted by a live motion preference change.
|
||||
for (const animation of element.getAnimations()) animation.startTime = 0;
|
||||
}
|
||||
|
||||
export function LoadingRing({ track = true, strokeDasharray = "16 46.8", ...props }: SVGProps<SVGSVGElement> & { track?: boolean }) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" aria-hidden="true" {...props}>
|
||||
{track ? <circle cx="12" cy="12" r="10" opacity="0.2" /> : null}
|
||||
<circle
|
||||
cx="12" cy="12" r="10" strokeDasharray={strokeDasharray} strokeLinecap="round"
|
||||
className="loading-ring-arc"
|
||||
ref={synchronizeRing}
|
||||
onAnimationStart={(event) => synchronizeRing(event.currentTarget)}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import { HoverHint, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tr
|
||||
import { Disclosure } from "@/components/ui/disclosure";
|
||||
import { ExpandableText } from "@/components/ui/expandable-text";
|
||||
import { StreamingLabelSheen } from "@/components/ui/streaming-label-sheen";
|
||||
import { LoadingRing } from "@/components/ui/loading-ring";
|
||||
import { ImageViewport } from "@/components/ui/image-viewport";
|
||||
import { Sample, type ComponentExample } from "./example";
|
||||
import { useGalleryTranslation } from "./i18n";
|
||||
@@ -302,6 +303,13 @@ export const foundationExamples: ComponentExample[] = [
|
||||
{ title: "controls.imageViewport.title", files: ["image-viewport"], Preview: ImageViewports,
|
||||
description: "controls.imageViewport.description", options: "controls.imageViewport.options",
|
||||
code: '<div className="flex h-80 flex-col"><ImageViewport src={url} alt={label} className="flex-1" /></div>' },
|
||||
{ title: "controls.loadingRing.title", files: ["loading-ring"],
|
||||
Preview: () => <div className="flex items-center gap-6 text-muted-foreground">
|
||||
<LoadingRing className="h-3 w-3" />
|
||||
<LoadingRing track={false} strokeWidth="1.5" strokeDasharray="12 50.8" className="h-6 w-6" />
|
||||
</div>,
|
||||
description: "controls.loadingRing.description", options: "controls.loadingRing.options",
|
||||
code: '<LoadingRing className="h-3 w-3 text-muted-foreground" />\n<LoadingRing track={false} strokeWidth="1.5" strokeDasharray="12 50.8" className="h-6 w-6" />' },
|
||||
{ title: "controls.streaming.title", files: ["streaming-label-sheen"], Preview: StreamingLabels,
|
||||
description: "controls.streaming.description", options: "controls.streaming.options",
|
||||
code: '<StreamingLabelSheen active={running}>Working…</StreamingLabelSheen>' },
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Image-local fit, zoom, pan and pinch controls.",
|
||||
"options": "Supply a bounded className and remount for a different image identity. Set panWithArrows=false when a gallery owns arrow navigation."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Loading ring",
|
||||
"description": "A shared activity ring with an optional track.",
|
||||
"options": "className sets size and color. track=false hides the track; strokeWidth and strokeDasharray adjust the arc. Respects reduced-motion settings."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Animated labels",
|
||||
"description": "A shared text animation for active thinking and tool labels.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Ajuste, zoom, desplazamiento y pellizco propios de cada imagen.",
|
||||
"options": "Proporciona una className con límites y vuelve a montar si cambia la identidad de la imagen. Usa panWithArrows=false cuando una galería gestione las flechas."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Anillo de actividad",
|
||||
"description": "Un indicador de actividad compartido con pista opcional.",
|
||||
"options": "className define el tamaño y el color. track=false oculta la pista; strokeWidth y strokeDasharray ajustan el arco. Respeta la preferencia de movimiento reducido."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Etiquetas animadas",
|
||||
"description": "Una animación de texto compartida para la reflexión activa y las etiquetas de herramientas.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Commandes d’ajustement, zoom, déplacement et pincement propres à l’image.",
|
||||
"options": "Fournissez une className délimitant la zone et remontez le composant si l’identité de l’image change. Définissez panWithArrows=false si une galerie gère les flèches."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Anneau d’activité",
|
||||
"description": "Un indicateur d’activité partagé avec une piste facultative.",
|
||||
"options": "className définit la taille et la couleur. track=false masque la piste ; strokeWidth et strokeDasharray ajustent l’arc. Respecte la préférence de réduction des animations."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Libellés animés",
|
||||
"description": "Une animation de texte partagée pour la réflexion et les libellés d’outils actifs.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Kontrol penyesuaian, zoom, geser, dan cubit untuk setiap gambar.",
|
||||
"options": "Sediakan className dengan batas area dan pasang ulang untuk identitas gambar yang berbeda. Atur panWithArrows=false jika galeri mengelola navigasi panah."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Cincin aktivitas",
|
||||
"description": "Indikator aktivitas bersama dengan jalur opsional.",
|
||||
"options": "className mengatur ukuran dan warna. track=false menyembunyikan jalur; strokeWidth dan strokeDasharray mengatur busur. Mengikuti preferensi pengurangan gerakan."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Label beranimasi",
|
||||
"description": "Animasi teks bersama untuk proses berpikir aktif dan label alat.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "画像単位のフィット、ズーム、移動、ピンチ操作。",
|
||||
"options": "className で領域を制限し、画像の識別情報が変わったら再マウントします。ギャラリーが矢印キー操作を管理する場合は panWithArrows=false にします。"
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "処理リング",
|
||||
"description": "背景リングを省略できる共通の処理インジケーター。",
|
||||
"options": "className でサイズと色を設定します。track=false で背景リングを非表示にし、strokeWidth と strokeDasharray で円弧を調整します。視差効果を減らす設定に従います。"
|
||||
},
|
||||
"streaming": {
|
||||
"title": "アニメーションラベル",
|
||||
"description": "思考中や実行中のツールラベルで共有するテキストアニメーション。",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "이미지별 맞춤, 확대/축소, 이동, 핀치 컨트롤입니다.",
|
||||
"options": "className으로 영역을 제한하고 이미지 식별 정보가 달라지면 다시 마운트합니다. 갤러리가 방향키 탐색을 관리하면 panWithArrows=false로 설정합니다."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "진행 링",
|
||||
"description": "배경 링을 선택적으로 표시하는 공용 진행 표시기입니다.",
|
||||
"options": "className으로 크기와 색상을 설정합니다. track=false는 배경 링을 숨기고, strokeWidth와 strokeDasharray는 호를 조절합니다. 동작 줄이기 설정을 따릅니다."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "애니메이션 레이블",
|
||||
"description": "진행 중인 사고와 도구 레이블이 공유하는 텍스트 애니메이션입니다.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Controles de ajuste, zoom, deslocamento e pinça locais à imagem.",
|
||||
"options": "Forneça uma className com limites e remonte o componente se a identidade da imagem mudar. Use panWithArrows=false quando uma galeria gerenciar as setas."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Anel de atividade",
|
||||
"description": "Um indicador de atividade compartilhado com trilha opcional.",
|
||||
"options": "className define o tamanho e a cor. track=false oculta a trilha; strokeWidth e strokeDasharray ajustam o arco. Respeita a preferência por movimento reduzido."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Rótulos animados",
|
||||
"description": "Uma animação de texto compartilhada para raciocínio ativo e rótulos de ferramentas.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "Điều khiển vừa khung, thu phóng, di chuyển và chụm ngón cho từng ảnh.",
|
||||
"options": "Dùng className để giới hạn vùng và gắn kết lại khi danh tính ảnh thay đổi. Đặt panWithArrows=false nếu thư viện ảnh quản lý điều hướng bằng phím mũi tên."
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "Vòng hoạt động",
|
||||
"description": "Chỉ báo hoạt động dùng chung với vòng nền tùy chọn.",
|
||||
"options": "className đặt kích thước và màu sắc. track=false ẩn vòng nền; strokeWidth và strokeDasharray điều chỉnh cung tròn. Tuân theo tùy chọn giảm chuyển động."
|
||||
},
|
||||
"streaming": {
|
||||
"title": "Nhãn động",
|
||||
"description": "Hiệu ứng văn bản dùng chung cho trạng thái suy nghĩ và nhãn công cụ đang hoạt động.",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "单张图片的适应、缩放、平移与双指缩放控件。",
|
||||
"options": "用 className 限定边界;更换图片身份时重新挂载。图库管理方向键导航时设置 panWithArrows=false。"
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "运行圆环",
|
||||
"description": "可选底环的共享运行指示器。",
|
||||
"options": "className 设置尺寸和颜色。track=false 隐藏底环;strokeWidth 和 strokeDasharray 调整圆弧。遵循减少动态效果设置。"
|
||||
},
|
||||
"streaming": {
|
||||
"title": "流光文字",
|
||||
"description": "思考中与工具标签共用的文字动画。",
|
||||
|
||||
@@ -166,6 +166,11 @@
|
||||
"description": "單張圖片的適應、縮放、平移與雙指縮放。",
|
||||
"options": "用 className 限定邊界;更換圖片身分時重新掛載。圖庫管理方向鍵導覽時設定 panWithArrows=false。"
|
||||
},
|
||||
"loadingRing": {
|
||||
"title": "執行圓環",
|
||||
"description": "可選底環的共用執行指示器。",
|
||||
"options": "className 設定尺寸和顏色。track=false 隱藏底環;strokeWidth 和 strokeDasharray 調整圓弧。遵循減少動態效果設定。"
|
||||
},
|
||||
"streaming": {
|
||||
"title": "流光文字",
|
||||
"description": "思考中與工具標籤共用的文字動畫。",
|
||||
|
||||
+43
-4
@@ -1054,17 +1054,56 @@
|
||||
}
|
||||
|
||||
/* loading.dev Ring, Copyright (c) 2026 Jakub Krehel (MIT); THIRD_PARTY_NOTICES.md. */
|
||||
.sidebar-running-ring {
|
||||
.loading-ring-arc {
|
||||
transform-origin: center;
|
||||
animation: sidebar-running-ring 800ms linear infinite;
|
||||
animation: loading-ring-spin 800ms linear infinite;
|
||||
}
|
||||
@keyframes sidebar-running-ring {
|
||||
@keyframes loading-ring-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.composer-primary-action {
|
||||
transition: color 160ms ease-out, background-color 160ms ease-out, border-color 160ms ease-out;
|
||||
}
|
||||
.composer-action-icons {
|
||||
transition: transform 120ms ease-out;
|
||||
}
|
||||
.composer-primary-action:active:not(:disabled) .composer-action-icons {
|
||||
transform: scale(0.94);
|
||||
}
|
||||
.composer-action-glyph {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
opacity: 0;
|
||||
transform: scale(0.72);
|
||||
transition: opacity 140ms ease-out, transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
.composer-action-glyph[data-active] {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
.composer-action-icons[data-state="stop"] [data-action-icon="send"] {
|
||||
transform: translateY(-3px) scale(0.8);
|
||||
}
|
||||
.composer-action-glyph:not([data-active]) .loading-ring-arc {
|
||||
animation: none;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.sidebar-running-ring {
|
||||
.loading-ring-arc {
|
||||
animation: none;
|
||||
}
|
||||
.composer-primary-action,
|
||||
.composer-action-icons,
|
||||
.composer-primary-action:active:not(:disabled) .composer-action-icons {
|
||||
transition: none;
|
||||
transform: none;
|
||||
}
|
||||
.composer-action-icons[data-state] .composer-action-glyph {
|
||||
transform: none;
|
||||
transition: opacity 80ms linear;
|
||||
}
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
|
||||
Reference in new issue
Block a user