Skip to content

Commit 74460d9

Browse files
committed
fix(buttons): align [role="button"] and group vertical rhythm
- Add margin-block-end to [role="button"] so wrapped link-as-button rows don't collide - Reduce button group margin from var(--nc-spacing) to 0.25em to match individual button rhythm - Annotate all magic numbers across 15 SCSS files with Open Props token comments (OP --size-*, --font-*, --font-lineheight-*, --font-weight-*) and cross-reference with OP normalize choices - Flag values with no OP match for future alignment
1 parent 74eb026 commit 74460d9

15 files changed

Lines changed: 98 additions & 91 deletions

src/_buttons.scss

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
// ----- Base button -----
1212

1313
:where(button, [type="submit"], [type="reset"], [type="button"], [role="button"]) {
14-
--_btn-padding-v: 0.5em;
15-
--_btn-padding-h: 1em;
14+
--_btn-padding-v: 0.5em; // OP ~size-2 (em-relative)
15+
--_btn-padding-h: 1em; // OP ~size-3 (em-relative)
1616

1717
padding: var(--_btn-padding-v) var(--_btn-padding-h);
1818
background-color: var(#{$prefix}primary);
1919
color: var(#{$prefix}primary-contrast);
2020
border: 1px solid var(#{$prefix}primary);
2121
border-radius: var(#{$prefix}radius);
2222
font: inherit;
23-
font-size: 1rem;
23+
font-size: 1rem; // OP --size-3
2424
line-height: 1.5;
2525
cursor: pointer;
2626
text-decoration: none;
@@ -30,10 +30,10 @@
3030
transition: background-color 0.2s, border-color 0.2s;
3131
}
3232

33-
// Vertical rhythm for flow-level buttons (not [role="button"] on
34-
// arbitrary elements like logo containers — those opt in manually).
35-
:where(button, [type="submit"], [type="reset"], [type="button"]) {
36-
margin-block-end: 0.25em;
33+
// Vertical rhythm for flow-level buttons and link-as-button elements
34+
// so wrapped rows don't collide.
35+
:where(button, [type="submit"], [type="reset"], [type="button"], [role="button"]) {
36+
margin-block-end: 0.25em; // OP ~size-1 (em-relative)
3737
}
3838

3939
:where(button, [type="submit"], [type="reset"], [type="button"], [role="button"]):hover {
@@ -66,10 +66,10 @@
6666
// ----- Inline (buttons within flow text) -----
6767

6868
:where(button, [type="submit"], [type="reset"], [type="button"], [role="button"]).inline {
69-
--_btn-padding-v: 0.05em;
70-
--_btn-padding-h: 0.4em;
71-
margin: 0.1em 0.15em;
72-
font-size: 0.875em;
69+
--_btn-padding-v: 0.05em; // no OP match (micro)
70+
--_btn-padding-h: 0.4em; // no OP match (near ~size-2)
71+
margin: 0.1em 0.15em; // no OP match (micro)
72+
font-size: 0.875em; // no OP match (7/8)
7373
vertical-align: baseline;
7474
}
7575

@@ -87,7 +87,7 @@
8787

8888
:where([role="group"]) {
8989
display: inline-flex;
90-
margin-bottom: var(#{$prefix}spacing);
90+
margin-bottom: 0.25em; // OP ~size-1 (em-relative); match individual buttons
9191
}
9292

9393
[role="group"] > * {
@@ -171,15 +171,15 @@
171171
// ----- Search groups (pill shape) -----
172172

173173
[role="search"] [role="group"] > :first-child {
174-
border-start-start-radius: 5rem;
175-
border-end-start-radius: 5rem;
176-
padding-inline-start: 1.25em;
174+
border-start-start-radius: 5rem; // OP --size-10 (pill)
175+
border-end-start-radius: 5rem; // OP --size-10 (pill)
176+
padding-inline-start: 1.25em; // OP ~size-4 (em-relative)
177177
}
178178

179179
[role="search"] [role="group"] > :last-child {
180-
border-start-end-radius: 5rem;
181-
border-end-end-radius: 5rem;
182-
padding-inline-end: 1.25em;
180+
border-start-end-radius: 5rem; // OP --size-10 (pill)
181+
border-end-end-radius: 5rem; // OP --size-10 (pill)
182+
padding-inline-end: 1.25em; // OP ~size-4 (em-relative)
183183
}
184184

185185
}

src/_code.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
:where(code, kbd, samp) {
1111
font-family: var(#{$prefix}font-mono);
12-
font-size: 0.875em;
12+
font-size: 0.875em; // no OP match (7/8); OP normalize inherits font-size
1313
background-color: var(#{$prefix}surface-2);
1414
border-radius: var(#{$prefix}radius);
15-
padding: 0.15em 0.35em;
15+
padding: 0.15em 0.35em; // no OP match; OP normalize: --size-1 --size-2
1616
}
1717

1818
:where(pre) {

src/_config.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ $surface-dark-chroma-boost: 0.003 !default;
4646
$surface-dark-hue-shift: 10 !default;
4747

4848
// --- Typography ---
49-
$font-sans: system-ui, sans-serif !default;
50-
$font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro',
49+
$font-sans: system-ui, sans-serif !default; // OP --font-sans (--font-system-ui)
50+
$font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', // OP ~--font-mono (--font-monospace-code); subset
5151
Menlo, Consolas, 'DejaVu Sans Mono', monospace !default;
5252

5353
// --- Spacing & Layout ---
54-
$spacing: 1rem !default;
55-
$radius: 0.25rem !default;
54+
$spacing: 1rem !default; // OP --size-3
55+
$radius: 0.25rem !default; // OP --size-1
5656
$content-width: 60ch !default;
5757
$wide-width: 1200px !default;
5858

src/_details.scss

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@
1414
border-radius: var(#{$prefix}radius);
1515
// No vertical padding — summary provides its own via the
1616
// negative-margin/padding trick for vertical centering.
17-
padding: 0 1em;
17+
padding: 0 1em; // OP ~size-3 (em-relative)
18+
// OP normalize: padding-inline: --size-3, padding-block: --size-2
1819
}
1920

2021
:where(details) {
21-
margin-bottom: 0.5em;
22+
margin-bottom: 0.5em; // OP ~size-2 (em-relative)
2223
}
2324

2425
:where(summary) {
2526
cursor: pointer;
26-
font-weight: 600;
27+
font-weight: 600; // OP --font-weight-6 (OP normalize uses weight-7: 700 for dt/summary)
2728
// Stretch summary across the horizontal padding area, then
2829
// re-apply vertical + horizontal padding on itself. When
2930
// collapsed the text is vertically centered with equal padding.
3031
// Vertical padding matches button padding (0.5em) so collapsed
3132
// details height equals button height (2px border + 2.5em).
32-
margin: 0 -1em;
33-
padding: 0.5em 1em;
33+
margin: 0 -1em; // OP ~size-3 (em-relative, negative)
34+
padding: 0.5em 1em; // OP ~size-2 ~size-3 (em-relative)
3435
// Custom markers fix iOS Safari's tiny native disclosure triangle.
3536
// Full-size Unicode triangles inherit font metrics and sit on the
3637
// baseline like native markers.
@@ -51,15 +52,15 @@
5152
:where(summary[role="button"]) {
5253
display: block;
5354
width: auto;
54-
margin: 0 -1em; // restore stretch (button sets margin: 0)
55+
margin: 0 -1em; // OP ~size-3 (em-relative, negative); restore stretch
5556
list-style: none; // remove ▶/▼ marker — replaced by ::before
5657
}
5758

5859
:where(summary[role="button"])::before {
5960
content: '\00a0';
6061
display: inline-block;
6162
transition: transform 0.2s ease;
62-
font-size: 0.75em;
63+
font-size: 0.75em; // no OP match (3/4)
6364
vertical-align: middle;
6465
}
6566

@@ -69,7 +70,7 @@
6970

7071
// When open, restore vertical padding for content spacing.
7172
:where(details[open]) {
72-
padding-bottom: 0.5em;
73+
padding-bottom: 0.5em; // OP ~size-2 (em-relative)
7374
}
7475

7576
}

src/_dialog.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
background-color: var(#{$prefix}surface-4);
1414
border: 1px solid var(#{$prefix}border);
1515
border-radius: var(#{$prefix}radius);
16-
max-width: min(90vw, 40rem);
16+
max-width: min(90vw, 40rem); // no OP match (above scale)
1717
max-height: 85vh;
1818
padding: var(#{$prefix}spacing);
1919
}
@@ -40,7 +40,7 @@
4040

4141
dialog::backdrop {
4242
background: rgb(0 0 0 / 0.5);
43-
backdrop-filter: blur(4px);
43+
backdrop-filter: blur(4px); // OP --size-px-1
4444
animation: nc-backdrop-in 0.2s ease;
4545
}
4646

src/_document.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
html {
1212
font-family: var(#{$prefix}font-sans);
13-
font-size: 100%; // = 16px in most browsers
14-
line-height: 1.5;
13+
font-size: 100%; // = 16px (OP --size-3) in most browsers
14+
line-height: 1.5; // OP --font-lineheight-3
1515
color: var(#{$prefix}text);
1616
background-color: var(#{$prefix}surface-1);
1717
scrollbar-gutter: stable;

src/_forms.scss

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
select, textarea) {
1414
--_input-bg: color-mix(in oklch, var(#{$prefix}surface-1), var(#{$prefix}surface-2) 20%);
1515

16-
padding: 0.5em 0.75em;
16+
padding: 0.5em 0.75em; // 0.5em: OP ~size-2; 0.75em: no OP match
17+
// OP normalize: padding-block: --size-1, padding-inline: --size-2
1718
min-height: calc(1em * 1.5 + 1em + 2px); // line-height + vertical padding + border
1819
background-color: var(--_input-bg);
1920
border: 1px solid var(#{$prefix}border);
2021
border-radius: var(#{$prefix}radius);
2122
color: var(#{$prefix}text);
2223
font: inherit;
23-
font-size: 1rem; // >=16px prevents iOS Safari auto-zoom on focus
24+
font-size: 1rem; // OP --size-3; >=16px prevents iOS Safari auto-zoom on focus
2425
transition: border-color 0.2s, box-shadow 0.2s;
2526
}
2627

@@ -51,7 +52,7 @@
5152
display: block;
5253
margin-top: calc(var(#{$prefix}spacing) * -0.75); // pull up under the input
5354
margin-bottom: var(#{$prefix}spacing);
54-
font-size: 0.875em;
55+
font-size: 0.875em; // no OP match (7/8)
5556
color: color-mix(in oklch, var(#{$prefix}text), transparent 40%);
5657
}
5758

@@ -78,17 +79,17 @@
7879

7980
:where(label) {
8081
display: block;
81-
margin-bottom: 0.25em;
82+
margin-bottom: 0.25em; // OP ~size-1 (em-relative)
8283
}
8384

8485
:where(label:has(+ input, + select, + textarea)) {
85-
font-weight: 600;
86+
font-weight: 600; // OP --font-weight-6
8687
}
8788

8889
// file and range are short/inline controls — increase the label gap to match
8990
// the visual weight of the spacing above and beside them.
9091
:where(label:has(+ [type="file"], + [type="range"])) {
91-
margin-bottom: 0.5em;
92+
margin-bottom: 0.5em; // OP ~size-2 (em-relative)
9293
}
9394

9495
// ----- Fieldset -----
@@ -109,25 +110,25 @@
109110
}
110111

111112
:where(legend) {
112-
font-weight: 600;
113-
padding-inline: 0.25em;
113+
font-weight: 600; // OP --font-weight-6
114+
padding-inline: 0.25em; // OP ~size-1 (em-relative)
114115
}
115116

116117
// ----- Checkbox & Radio -----
117118
// Use accent-color to tint native controls to match the primary color
118119

119120
:where([type="checkbox"], [type="radio"]) {
120121
accent-color: var(#{$prefix}primary);
121-
width: 1.125em;
122-
height: 1.125em;
122+
width: 1.125em; // no OP match (OP normalize: --size-3 = 1rem)
123+
height: 1.125em; // no OP match (OP normalize: --size-3 = 1rem)
123124
margin: 0; // Remove browser default margin so flex labels align flush left
124125
}
125126

126127
:where(label:has([type="checkbox"], [type="radio"])) {
127128
display: flex;
128129
align-items: center;
129-
gap: 0.35em;
130-
margin-bottom: 0.5em;
130+
gap: 0.35em; // no OP match (near ~size-1)
131+
margin-bottom: 0.5em; // OP ~size-2 (em-relative)
131132
}
132133

133134
// Last checkbox/radio label in a group drops its bottom margin
@@ -139,8 +140,8 @@
139140
// ----- Search (pill shape) -----
140141

141142
:where([type="search"]) {
142-
border-radius: 5rem;
143-
padding-inline: 1.25em;
143+
border-radius: 5rem; // OP --size-10 (pill)
144+
padding-inline: 1.25em; // OP ~size-4 (em-relative)
144145
}
145146

146147
// ----- Range -----
@@ -170,9 +171,9 @@
170171
}
171172

172173
:where([type="file"])::file-selector-button {
173-
padding: 0.5em 1em;
174-
margin-right: 0.75em;
175-
margin-inline-end: 0.75em;
174+
padding: 0.5em 1em; // OP ~size-2 ~size-3 (em-relative)
175+
margin-right: 0.75em; // no OP match (between ~size-2/~size-3)
176+
margin-inline-end: 0.75em; // no OP match (between ~size-2/~size-3)
176177
background-color: var(#{$prefix}primary);
177178
color: var(#{$prefix}primary-contrast);
178179
border: 1px solid var(#{$prefix}primary);
@@ -191,7 +192,7 @@
191192
// Natural width so picker icon stays near content (excluded from full-width rule above).
192193
// appearance: none is applied outside @layer (see below) to fix iOS Safari sizing.
193194
:where([type="date"], [type="month"], [type="week"], [type="time"], [type="datetime-local"]) {
194-
min-width: 10em; // Prevent collapse when empty (e.g. time with no value)
195+
min-width: 10em; // no OP match; prevent collapse when empty (e.g. time with no value)
195196
margin-bottom: var(#{$prefix}spacing);
196197
}
197198

@@ -201,7 +202,7 @@
201202
--_color-size: calc(1em * 1.5 + 1em + 2px); // Match text input height
202203
margin-bottom: var(#{$prefix}spacing);
203204

204-
--_color-pad: 0.25em;
205+
--_color-pad: 0.25em; // OP ~size-1 (em-relative)
205206

206207
height: var(--_color-size);
207208
width: calc((var(--_color-size) - 2 * var(--_color-pad)) * 1.618 + 2 * var(--_color-pad)); // Golden ratio inner swatch
@@ -229,14 +230,14 @@
229230
:where(label:has([type="checkbox"][role="switch"])) {
230231
display: flex;
231232
align-items: center;
232-
gap: 0.5em;
233+
gap: 0.5em; // OP ~size-2 (em-relative)
233234
}
234235

235236
:where([type="checkbox"][role="switch"]) {
236237
appearance: none;
237-
width: 2.5em;
238-
height: 1.25em;
239-
border-radius: 1em;
238+
width: 2.5em; // no OP match (custom switch width)
239+
height: 1.25em; // OP ~size-4 (em-relative)
240+
border-radius: 1em; // OP ~size-3 (pill, em-relative)
240241
background-color: var(#{$prefix}border);
241242
position: relative;
242243
cursor: pointer;

src/_links.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:where(a:not([role="button"])) {
1212
color: var(#{$prefix}primary);
1313
text-decoration: underline;
14-
text-underline-offset: 0.15em;
14+
text-underline-offset: 0.15em; // no OP match; OP normalize: 1px (2px Firefox)
1515
text-decoration-color: #{string.unquote('color-mix(in oklch, var(#{$prefix}primary), transparent 50%)')};
1616
transition: color 0.2s, text-decoration-color 0.2s;
1717
}

src/_media.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
}
1919

2020
:where(figcaption) {
21-
font-size: 0.9em;
21+
font-size: 0.9em; // no OP match; OP normalize: --font-size-1 (1rem)
2222
color: color-mix(in oklch, var(#{$prefix}text), transparent 40%);
23-
margin-top: 0.5em;
23+
margin-top: 0.5em; // OP ~size-2 (em-relative)
2424
}
2525

2626
}

src/_meter.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-moz-appearance: none;
1717
appearance: none;
1818
width: 100%;
19-
height: 0.5rem;
19+
height: 0.5rem; // OP --size-2
2020
overflow: hidden;
2121
border: 0;
2222
border-radius: var(#{$prefix}radius);
@@ -32,7 +32,7 @@
3232
border-radius: var(#{$prefix}radius);
3333
background-color: var(#{$prefix}surface-3);
3434
border: 0;
35-
height: 0.5rem;
35+
height: 0.5rem; // OP --size-2
3636
}
3737

3838
// WebKit: value bars for each semantic state

0 commit comments

Comments
 (0)