Skip to content

Commit d45401e

Browse files
v6: Tidy up token/consistency nits (method pills, status bar, icon sizing) (#4421)
## Summary - `MethodPill`'s query/mutation/subscription colors were hand-typed OKLCH values that approximated `--accent-green`/`--accent-yellow`/`--accent-purple` but didn't reference them, so the pills never re-themed with the rest of the app. They now read the tokens directly. Query and subscription flip their text color between near-black and near-white depending on theme, the same split `.graphiql-button-success` and the query-builder's variable toggle already use, since the token values (unlike the old hardcoded ones) differ enough per theme to change which text color clears contrast. - The status bar's item gap (`--px-14`) didn't match the top bar's (`--px-12`), its closest structural sibling, for no obvious reason. Both now use `--px-12`. Leaving the status bar's mono/small/muted type scale alone on purpose here, that reads as a deliberate "quiet metadata strip" choice, not a bug. - Icon buttons in the toolbar, activity rail, and response header each sized themselves differently: a legacy `--toolbar-width` variable, a hardcoded 32px, and a hardcoded 28px override. Added a shared `--icon-button-size-sm/md/lg` scale to the density presets in `tokens.css` and pointed all three at it. ## Test plan - [x] Switch between light and dark themes and confirm the QRY/MUT/SUB method pills recolor with the rest of the accent palette and their text stays legible in both. - [x] Confirm the status bar's item spacing now matches the top bar's. - [x] At each density preset (Compact/Comfortable/Spacious in Settings), confirm icon buttons in the activity rail, top-bar toolbar, and response header size consistently with each other. - [x] In the response header, confirm the toolbar icon buttons still fit comfortably inside the 32px-tall header bar without touching its edges. Refs: #4219
1 parent 54d37eb commit d45401e

7 files changed

Lines changed: 63 additions & 15 deletions

File tree

packages/graphiql-react/src/components/activity-rail/index.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
}
2020

2121
.graphiql-activity-rail-item {
22-
width: 32px;
23-
height: 32px;
22+
width: var(--icon-button-size-md);
23+
height: var(--icon-button-size-md);
2424
border: 0;
2525
border-left: 2px solid transparent;
2626
margin-left: -2px;
@@ -64,8 +64,8 @@
6464
}
6565

6666
.graphiql-activity-rail-settings {
67-
width: 32px;
68-
height: 32px;
67+
width: var(--icon-button-size-md);
68+
height: var(--icon-button-size-md);
6969
margin: 0 auto;
7070
border: 0;
7171
background: transparent;

packages/graphiql-react/src/components/method-pill/index.css

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,28 @@
1717
* the pill text stays well above WCAG AA in both themes.
1818
*/
1919
.graphiql-method-pill-query {
20-
color: oklch(98% 0 0);
21-
background: oklch(50% 0.15 146);
20+
/* --accent-green is near-black-readable in dark theme (light L) and
21+
near-white-readable in light theme (darker L) — same split as
22+
.graphiql-button-success. */
23+
color: oklch(15% 0 0);
24+
background: oklch(var(--accent-green));
25+
26+
[data-theme='light'] & {
27+
color: oklch(98% 0 0);
28+
}
2229
}
2330

2431
.graphiql-method-pill-mutation {
2532
color: oklch(15% 0 0);
26-
background: oklch(85% 0.13 90);
33+
background: oklch(var(--accent-yellow));
2734
}
2835

2936
.graphiql-method-pill-subscription {
30-
color: oklch(98% 0 0);
31-
background: oklch(45% 0.18 295);
37+
/* Same theme split as --accent-green above, see .graphiql-qb-var-toggle. */
38+
color: oklch(15% 0 0);
39+
background: oklch(var(--accent-purple));
40+
41+
[data-theme='light'] & {
42+
color: oklch(98% 0 0);
43+
}
3244
}

packages/graphiql-react/src/components/method-pill/method-pill.stories.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,22 @@ export const Mutation: Story = {
2121
export const Subscription: Story = {
2222
render: () => <MethodPill operation="subscription" />,
2323
};
24+
25+
// The pills read their colors from --accent-green/-yellow/-purple, which
26+
// resolve differently per theme, so the default (dark) stories above don't
27+
// exercise light-theme contrast. These pin the light theme explicitly so the
28+
// a11y check covers both.
29+
export const QueryLight: Story = {
30+
render: () => <MethodPill operation="query" />,
31+
globals: { theme: 'light' },
32+
};
33+
34+
export const MutationLight: Story = {
35+
render: () => <MethodPill operation="mutation" />,
36+
globals: { theme: 'light' },
37+
};
38+
39+
export const SubscriptionLight: Story = {
40+
render: () => <MethodPill operation="subscription" />,
41+
globals: { theme: 'light' },
42+
};

packages/graphiql-react/src/components/response-header/index.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@
5656
flex: 1;
5757
}
5858

59-
/* ToolbarButton defaults to --toolbar-width (40px); shrink it so the hover
59+
/* ToolbarButton defaults to --icon-button-size-lg; shrink it so the hover
6060
background fits inside the 32px header bar. */
6161
.graphiql-response-header .graphiql-toolbar-button {
62-
height: 28px;
63-
width: 28px;
62+
height: var(--icon-button-size-sm);
63+
width: var(--icon-button-size-sm);
6464
}
6565

6666
.graphiql-response-pane {

packages/graphiql-react/src/components/status-bar/index.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
.graphiql-status-bar {
22
display: flex;
33
align-items: center;
4-
gap: var(--px-14);
4+
gap: var(--px-12);
55
height: var(--status-bar-height);
66
flex-shrink: 0;
77
padding: 0 var(--px-12);
88
background: oklch(var(--bg-elevated));
99
border-top: 1px solid oklch(var(--border-default));
10+
/* Mono + eyebrow + --fg-subtle is intentional here — the status bar
11+
reads as a quiet metadata strip, unlike the top bar's primary-content
12+
type scale. Leave this as-is. */
1013
color: oklch(var(--fg-subtle));
1114
font-family: var(--font-family-mono);
1215
font-size: var(--font-size-eyebrow);

packages/graphiql-react/src/components/toolbar-button/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ button.graphiql-toolbar-button {
22
display: flex;
33
align-items: center;
44
justify-content: center;
5-
height: var(--toolbar-width);
6-
width: var(--toolbar-width);
5+
height: var(--icon-button-size-lg);
6+
width: var(--icon-button-size-lg);
77
color: oklch(var(--fg-subtle));
88
border-radius: var(--radius-sm);
99

packages/graphiql-react/src/style/tokens.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@
173173
--dialog-padding-y: 16px;
174174
--dialog-bar-padding-y: 6px;
175175
--dialog-gap: 16px;
176+
177+
/* Icon-button hit-target sizes. -sm/-md/-lg cover the three sizes icon
178+
buttons render at today (response header / activity rail / top-bar
179+
toolbar), so all three can read one scale instead of each hardcoding
180+
its own pixel value. */
181+
--icon-button-size-sm: 28px;
182+
--icon-button-size-md: 32px;
183+
--icon-button-size-lg: 40px;
176184
}
177185

178186
[data-density='compact'] {
@@ -188,6 +196,9 @@
188196
--dialog-padding-y: 12px;
189197
--dialog-bar-padding-y: 4px;
190198
--dialog-gap: 12px;
199+
--icon-button-size-sm: 24px;
200+
--icon-button-size-md: 26px;
201+
--icon-button-size-lg: 34px;
191202
}
192203

193204
[data-density='spacious'] {
@@ -203,6 +214,9 @@
203214
--dialog-padding-y: 20px;
204215
--dialog-bar-padding-y: 10px;
205216
--dialog-gap: 20px;
217+
--icon-button-size-sm: 34px;
218+
--icon-button-size-md: 40px;
219+
--icon-button-size-lg: 48px;
206220
}
207221

208222
/* -------------------------------------------------------------------------

0 commit comments

Comments
 (0)