Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Result panel: long action labels wrap to two lines instead of truncating

Adarsh87a5a7b25dc2
diff --git a/src/components/studio/viewer.tsx b/src/components/studio/viewer.tsx
index f4a74a54..2bbd2749 100644
--- a/src/components/studio/viewer.tsx
+++ b/src/components/studio/viewer.tsx
@@ -151,6 +151,10 @@ function LayerList({ g, index, all, onPick, onAll }: { g: Generation; index: num
);
}
+/** The two-column action grid: a long label wraps to a second line, and the buttons of a row share its height. */
+const ACTION_GRID =
+ "@container/actions grid grid-cols-2 gap-2 [&>*]:h-auto [&>*]:min-h-7 [&>*]:py-1 [&>*]:whitespace-normal [&_[data-label]]:line-clamp-2 [&_[data-label]]:whitespace-normal [&_[data-label]]:text-center [&_[data-label]]:leading-tight";
+
export function Viewer({
generation: g,
index,
@@ -261,9 +265,9 @@ export function Viewer({
const Icon = ACTION_ICONS[a.id];
const label = a.id === "favorite" ? (g.favorite ? "Favorited" : "Favorite") : a.id === "save-character" ? "Save as element" : a.label;
const icon = <Icon className={cn(a.id === "favorite" && g.favorite && "fill-current text-highlight")} />;
- // The label truncates inside its own button, so a long one never spills into the next column.
+ // The label stays inside its own button (one line here, up to two in the action grid), never in the next column.
const text = (
- <span className="min-w-0 truncate" title={label}>
+ <span data-label className="min-w-0 truncate" title={label}>
{label}
</span>
);
@@ -460,7 +464,7 @@ export function Viewer({
/>
)}
</div>
- <div className="@container/actions grid grid-cols-2 gap-2 border-t p-3">
+ <div className={cn(ACTION_GRID, "border-t p-3")}>
{primary && actionButton(primary, { variant: "default" })}
{bar.map((a) => actionButton(a))}
{menu.filter((a) => !a.destructive && a.id !== "compare").map((a) => actionButton(a))}
@@ -511,7 +515,7 @@ export function Viewer({
<div className="space-y-4 overflow-y-auto px-4">
{/* The next steps first: on a phone this sheet is where they are. */}
{!layered && <NextSteps g={g} index={index} variant="list" max={5} onNavigate={onClose} />}
- <div className="@container/actions grid grid-cols-2 gap-2">
+ <div className={ACTION_GRID}>
{source && (
<Button variant="secondary" size="sm" aria-pressed={comparing} onClick={() => (setComparing((v) => !v), setDrawer(false))}>
<Columns2 /> {comparing ? "Hide original" : "Compare"}
diff --git a/tests/result-actions-layout.test.ts b/tests/result-actions-layout.test.ts
index 355aab9d..2684dfec 100644
--- a/tests/result-actions-layout.test.ts
+++ b/tests/result-actions-layout.test.ts
@@ -5,7 +5,7 @@ import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vitest";
/*
- * The result panel's action grid: a long label truncates inside its own button, and an action that runs on the visitor's
+ * The result panel's action grid: a long label wraps inside its own button, and an action that runs on the visitor's
* own setup shows its mark (an icon with its words as tooltip) in a narrow cell and the short words where there is room,
* never the long label that pushed the button out of its column. The owner sees no mark.
*/
@@ -37,14 +37,16 @@ describe("the own-setup chip in the result panel", () => {
describe("the result panel's action buttons", () => {
const viewer = source("src/components/studio/viewer.tsx");
- it("truncate their label inside their own cell", () => {
- expect(viewer).toMatch(/className="min-w-0 truncate" title=\{label\}/);
+ it("keep their label inside their own cell: up to two lines in the grid, rows of one height", () => {
+ expect(viewer).toMatch(/<span data-label className="min-w-0 truncate" title=\{label\}>/);
expect(viewer).toMatch(/const cls = cn\("min-w-0"/);
expect(viewer).not.toMatch(/\{icon\} \{label\}/);
+ const grid = /const ACTION_GRID =\s*"([^"]+)"/.exec(viewer)?.[1] ?? "";
+ for (const c of ["@container/actions", "grid-cols-2", "[&>*]:h-auto", "[&>*]:min-h-7", "[&>*]:whitespace-normal", "[&_[data-label]]:line-clamp-2", "[&_[data-label]]:whitespace-normal"]) expect(grid).toContain(c);
});
it("show the short chip only where the grid has room, the mark elsewhere, and nothing to the owner", () => {
- expect(viewer.match(/@container\/actions grid grid-cols-2/g)).toHaveLength(2);
+ expect(viewer.match(/className=\{(cn\()?ACTION_GRID/g)).toHaveLength(2);
expect(viewer).toMatch(/a\.ownSetup && !owner &&/);
expect(viewer).toMatch(/<OwnSetupMark setup=\{a\.ownSetup\} className="@min-\[34rem\]\/actions:hidden" \/>/);
expect(viewer).toMatch(/<OwnSetupChip setup=\{a\.ownSetup\} short="always" className="min-w-0 shrink @max-\[34rem\]\/actions:hidden" \/>/);