Skip to content

Commit ff342df

Browse files
authored
fix(ui): align header widgets to one height and baseline (#97)
* fix(ui): align header widgets to one height and baseline Header tiles took their content's height and the header row centred them, so a tile with a bar under its value (Memory, Disk) sat higher than the others and its label and value no longer lined up with the row's. Every header tile is now 56 px high with its content centred, and the bar sits on the tile's bottom edge instead of adding height, so labels and values share one line across the header. Board tiles are unchanged. * fix(ui): reserve the bar strip in every header tile instead of fixing its height Address review: a fixed 56 px tile broke the overflow menu's Menu.Item layout, overflowed the 55 px header row and its focus ring, and clipped large text. Instead every header tile keeps the same 4 px strip below its value, holding the bar where a tile has one, so tiles are equal in height in flow. The header stories now check that labels and values share one line, and a mixed-tile story covers the case that was misaligned.
1 parent 6618a95 commit ff342df

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/web/app/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<!doctype html>
2-
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Driga</title><meta name="driga-style-nonce" content="__DRIGA_STYLE_NONCE__"> <script type="module" crossorigin src="/app/assets/index-Istn2m08.js"></script>
2+
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Driga</title><meta name="driga-style-nonce" content="__DRIGA_STYLE_NONCE__"> <script type="module" crossorigin src="/app/assets/index-Nf1ipJ0R.js"></script>
33
<link rel="stylesheet" crossorigin href="/app/assets/index-bMbUfRA6.css">
44
</head><body><div id="root"></div></body></html>

‎ui/src/host/ClustersHeader.stories.tsx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ function geometry(root: HTMLElement) {
7171
expect(rect.right).toBeLessThanOrEqual(slot.parentElement!.parentElement!.getBoundingClientRect().right + 1);
7272
expect(rect.right).toBeLessThanOrEqual(within(root).getByRole("button", { name: /^Fleet:/ }).getBoundingClientRect().left);
7373
}
74+
// Labels and values share one line across the row, whether or not a tile
75+
// has a bar under its value.
76+
const stacks = slots.map(slot => slot.querySelector<HTMLElement>(".w-tile > .mantine-Stack-root")).filter(stack => stack?.checkVisibility()) as HTMLElement[];
77+
for (const [i, part] of [[0, "label"], [1, "value"]] as const) {
78+
const tops = stacks.map(stack => (stack.children[i] as HTMLElement).getBoundingClientRect().top);
79+
expect(Math.max(...tops) - Math.min(...tops), `${part} tops ${tops}`).toBeLessThanOrEqual(1);
80+
}
7481
}
7582

7683
export const Busy: Story = {
@@ -252,6 +259,17 @@ export const Memory: Story = {
252259
geometry(context.canvasElement);
253260
},
254261
};
262+
/** Tiles with and without a bar under the value, side by side as in the
263+
* screenshot that found them misaligned: labels and values share one line. */
264+
export const MixedAlignment: Story = {
265+
args: { data: { ...allWidgets, tiles: ["finished", "leftover", "reclaim", "memory", "cpu", "disk"].map(id => allWidgets.tiles.find(t => t.id === id)!) } },
266+
globals: { viewport: { value: "headerWide", isRotated: false } },
267+
play: async ({ canvasElement }) => {
268+
await ready(canvasElement);
269+
for (const id of ["memory", "disk", "leftover"]) await expect(await tile(canvasElement, id)).toBeVisible();
270+
geometry(canvasElement);
271+
},
272+
};
255273
export const CPU = widget("cpu");
256274
export const Disk = widget("disk");
257275
export const Load = widget("load");

‎ui/src/widgets/KpiTile.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export function KpiTile({ label, sublabel, icon: Glyph, value, unit, total, capt
104104
{chip ?? <span />}
105105
{line && <Box h={24} style={{ flex: "1 1 48px", minWidth: 40, maxWidth: 96 }}>{line}</Box>}
106106
</Group>}
107-
{children}
107+
{/* Every header tile keeps the same strip below its value, so a bar under
108+
memory adds no height and labels and values line up across the row. */}
109+
{header ? <Box h={4} aria-hidden={children ? undefined : true}>{children}</Box> : children}
108110
</Stack>}
109111
</Root>;
110112
return <Box className="w-tile-box" visibleFrom={visibleFrom} hiddenFrom={hiddenFrom} style={header ? { display: "inline-block" } : undefined}>

0 commit comments

Comments
 (0)