Skip to content

Commit 8c151a2

Browse files
authored
Default icon actions to the compact size (#849)
Signed-off-by: morgmart <[email protected]>
1 parent 81f8de7 commit 8c151a2

14 files changed

Lines changed: 108 additions & 12 deletions

File tree

‎docs/design-system-adoption.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Use this map to find the shared owner before changing a product surface.
1111
| Area | Shared owner | App uses |
1212
| --- | --- | --- |
1313
| Colors and type | Surface, text, border, affordance, and complete type roles | Host aliases forward to shared roles. Feature CSS uses role names; inline links pair text and hover roles. |
14-
| Actions | Button and IconButton | Retry, refresh, delete, recovery, composer send, and picker triggers. Standard sizes are 32/40/52px minimums. Labels stay on one line; surrounding layouts reflow whole controls or scroll. |
14+
| Actions | Button and IconButton | Retry, refresh, delete, recovery, composer send, and picker triggers. Standard sizes are 32/40/52px; IconButton defaults to small and labelled Button defaults to medium. Text-button heights are minimums. Labels stay on one line; surrounding layouts reflow whole controls or scroll. |
1515
| Forms and choices | Field, Input, Textarea, RadioGroup, Checkbox | Profile, community setup, appearance, plugin import, and workflow editing. |
1616
| Search | SearchField | Channels, pages, members, and GIFs retain their query, refs, and keyboard handlers. |
1717
| Navigation | NavigationItem | Settings, channel rows, shell destinations, Home, and community choices. Route destinations use button semantics; the wide shell topbar is the documented chrome-tab exception. |

‎src/bundled/channels/ChannelMembersDialog.test.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,9 +1195,10 @@ it("pages combined local and relay invitations without losing matches", async ({
11951195
}) => {
11961196
return ownedTask(signal, async (step) => {
11971197
const { t, idle, more, rows, pages } = await pagedInvitations(step, 65);
1198-
expect(rows()).toHaveLength(30);
1198+
const firstPage = rows();
1199+
expect(firstPage).toHaveLength(30);
11991200
expect(
1200-
rows().every((row) =>
1201+
firstPage.every((row) =>
12011202
row.getAttribute("aria-label")?.startsWith("Add Helper remote"),
12021203
),
12031204
).toBe(true);
@@ -1209,7 +1210,9 @@ it("pages combined local and relay invitations without losing matches", async ({
12091210
}
12101211
await more();
12111212
await idle();
1212-
screen.getByRole("button", { name: /^Add Helper final/ });
1213+
expect(
1214+
screen.getByRole("button", { name: /^Add Helper final/ }),
1215+
).toBeVisible();
12131216
expect(rows()).toHaveLength(96);
12141217
expect(pages()).toEqual([1, 2]);
12151218
expect(
@@ -1228,7 +1231,9 @@ it("resets combined invitation paging on refresh or query change", async ({
12281231
await pagedInvitations(step, 31);
12291232
for (let i = 0; i < 3; i++) await more();
12301233
await idle();
1231-
screen.getByRole("button", { name: /^Add Helper final/ });
1234+
expect(
1235+
screen.getByRole("button", { name: /^Add Helper final/ }),
1236+
).toBeVisible();
12321237
expect(rows()).toHaveLength(62);
12331238
expect(pages()).toEqual([1, 2]);
12341239
await click(refresh);

‎src/features/communities/CommunityRail.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export function CommunityRail({
193193
<Tooltip content="Personal space" side="right">
194194
<IconButton
195195
ref={personalRef}
196+
size="md"
196197
aria-label="Personal space"
197198
aria-current={client.selected === null ? "true" : undefined}
198199
data-selected={client.selected === null || undefined}
@@ -232,6 +233,7 @@ export function CommunityRail({
232233
<Tooltip content="Add a community" side="right">
233234
<IconButton
234235
ref={addRef}
236+
size="md"
235237
aria-label="Add a community"
236238
icon={<PlusIcon size={22} aria-hidden="true" />}
237239
onClick={() => setJoining(true)}

‎src/features/communities/CommunityRailItem.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export function CommunityRailItem({
156156
button.current = node;
157157
buttonRef?.(node);
158158
}}
159+
size="md"
159160
aria-label={`Switch to ${name}`}
160161
aria-current={selected ? "true" : undefined}
161162
data-selected={selected || undefined}

‎src/features/profiles/AvatarEditor.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function AvatarEditor(props: Props) {
125125
render={
126126
<IconButton
127127
variant="solid"
128+
size="md"
128129
shape="round"
129130
style={{
130131
width: "100%",

‎src/shared/design-system/DESIGN.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,12 @@ the composer's model name, `size="inline"` keeps a 24px minimum target with 4px
632632
horizontal padding and icon gap, and 12px icons. Pair it with `variant="ghost"`
633633
for an unframed label; shared hover, disabled, and keyboard focus still apply.
634634

635-
IconButton defaults to a 10px rounded rectangle (`--radius-icon-button`) and uses the same
636-
sm/md/lg sizes. Existing names
635+
Button defaults to `md` (40px minimum height); IconButton defaults to `sm`
636+
(32px square with 16px artwork) and a 10px rounded rectangle
637+
(`--radius-icon-button`). Choose `md` or `lg` explicitly when an icon action needs
638+
a larger control; community rail identities and the avatar edit badge retain their
639+
existing larger treatment. These defaults do not depend on pointer type or viewport
640+
width. Both controls use the same sm/md/lg scale. Existing names
637641
remain compatibility aliases: primary/solid → prominent, quiet → subtle,
638642
compact/toolbar → sm, default → md, large → lg. Do not add new alias call sites.
639643
Buzz's tint and chrome icon variants remain for composer and backdrop actions.

‎src/shared/design-system/ui/IconButton.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type IconButtonProps = Omit<
3030
export function IconButton({
3131
icon,
3232
variant = "ghost",
33-
size = "md",
33+
size = "sm",
3434
shape = variant === "avatar" ? "round" : "control",
3535
...props
3636
}: IconButtonProps) {

‎src/shared/design-system/ui/controls.test.tsx‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { act, cleanup, render, screen, waitFor } from "@testing-library/react";
55
import userEvent from "@testing-library/user-event";
66
import { createRef, useState } from "react";
77
import { Button } from "./Button";
8+
import { IconButton } from "./IconButton";
9+
import { PlusIcon } from "../icons";
810
import { Field } from "./Field";
911
import { Input } from "./Input";
1012
import { Textarea } from "./Textarea";
@@ -15,6 +17,39 @@ import { Composer } from "./Composer";
1517

1618
afterEach(cleanup);
1719

20+
test("icon actions default to small while labelled actions remain medium", () => {
21+
render(
22+
<>
23+
<IconButton aria-label="Add item" icon={<PlusIcon />} />
24+
<Button>Continue</Button>
25+
</>,
26+
);
27+
expect(screen.getByRole("button", { name: "Add item" })).toHaveAttribute(
28+
"data-size",
29+
"sm",
30+
);
31+
expect(screen.getByRole("button", { name: "Continue" })).toHaveAttribute(
32+
"data-size",
33+
"md",
34+
);
35+
});
36+
37+
test.each([
38+
["sm", "sm"],
39+
["md", "md"],
40+
["lg", "lg"],
41+
["compact", "sm"],
42+
["toolbar", "sm"],
43+
["default", "md"],
44+
["large", "lg"],
45+
["xs", "sm"],
46+
] as const)("explicit icon size %s retains its contract", (size, resolved) => {
47+
render(<IconButton size={size} aria-label="Add item" icon={<PlusIcon />} />);
48+
const control = screen.getByRole("button", { name: "Add item" });
49+
expect(control).toHaveAttribute("data-size", resolved);
50+
expect(control).toHaveAttribute("data-icon-size", size);
51+
});
52+
1853
test("composer enables submission only for an available non-empty draft", async () => {
1954
const user = userEvent.setup();
2055
const submit = vi.fn((event) => event.preventDefault());

‎src/shared/design-system/ui/registry.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export const COMPONENTS: readonly ComponentDefinition[] = [
414414
"outline",
415415
"inverted",
416416
"link",
417-
"size: inline | xs | sm | md | lg",
417+
"size: inline | xs | sm | md (default) | lg",
418418
"shape: capsule (default) | control (12px)",
419419
"loading",
420420
],
@@ -445,7 +445,7 @@ export const COMPONENTS: readonly ComponentDefinition[] = [
445445
"media",
446446
"bare (glyph-state toggle, no background in any state; 20px artwork at sm)",
447447
"shape: control (default, 10px) | round (avatar default) | row-end",
448-
"size: xs (20px, 12px icon) | sm (32px) | md (40px) | lg (52px)",
448+
"size: xs (20px, 12px icon) | sm (default, 32px, 16px icon) | md (40px) | lg (52px)",
449449
"legacy aliases: quiet, solid, compact, toolbar, default, large",
450450
],
451451
status: "proposed",

‎tests/browser/avatar-edit.spec.mjs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ test("avatar image controls retain their hover fill and accessible URL label", a
1010
await page
1111
.getByRole("button", { name: "Edit human profile", exact: true })
1212
.click();
13-
await page.getByRole("button", { name: "Edit avatar", exact: true }).click();
13+
const editAvatar = page.getByRole("button", {
14+
name: "Edit avatar",
15+
exact: true,
16+
});
17+
// The badge owns its outer box; opting into medium preserves the artwork
18+
// without replacing that human/agent geometry with the new compact default.
19+
await expect(editAvatar).toHaveCSS("width", "32px");
20+
await expect(editAvatar).toHaveCSS("height", "32px");
21+
await expect(editAvatar.locator("svg")).toHaveCSS("width", "24px");
22+
await editAvatar.click();
1423
const dropzone = page.getByRole("button", {
1524
name: "Drop or browse",
1625
exact: true,

0 commit comments

Comments
 (0)