Skip to content

Commit 76ee267

Browse files
fix(ui): replace --base with spacer tokens in Row field CSS (#16425)
Replaces deprecated `--base` variable with proper spacer tokens in Row field CSS. ## Changes - Updates the **Row** field component (`packages/ui/src/fields/Row/index.css`) - Introduces `--row-gap` local CSS variable set to `var(--spacer-3)` (16px) - Replaces all `--base` calculations with the new variable - Adds comments explaining the negative margin technique - Improves mobile responsiveness with `flex-direction: column` instead of `display: block` - Also updates Point field and RenderFields spacing to use spacer tokens ## References https://app.asana.com/1/10497086658021/project/1213409914712008/task/1214061555627426?focus=true
1 parent 972d401 commit 76ee267

4 files changed

Lines changed: 176 additions & 11 deletions

File tree

packages/ui/src/fields/Point/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
.point__wrap {
2222
display: flex;
23-
gap: var(--spacer-2);
23+
gap: var(--spacer-3);
2424
width: 100%;
2525
margin: 0;
2626
list-style: none;

packages/ui/src/fields/Row/index.css

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
@layer payload-default {
22
.field-type.row {
3+
--row-gap: var(--spacer-3); /* 16px gap between row items */
4+
35
margin-bottom: 0;
46

57
.row__fields {
68
display: flex;
79
flex-wrap: wrap;
8-
row-gap: 1rem;
10+
row-gap: var(--row-gap);
911

1012
> * {
1113
flex: 0 1 var(--field-width);
@@ -15,22 +17,24 @@
1517
}
1618

1719
&:has(> *:nth-child(1)) {
18-
margin-bottom: var(--base);
20+
margin-bottom: var(--row-gap);
1921
}
2022

23+
/* Negative margin technique: each item gets half the gap as margin-inline,
24+
container pulls back with negative margin to maintain alignment */
2125
&:has(> *:nth-child(2)) {
22-
margin-inline: calc(var(--base) / -4);
26+
margin-inline: calc(var(--row-gap) / -2);
2327

2428
> * {
25-
flex: 0 1 calc(var(--field-width) - var(--base) * 0.5);
26-
margin-inline: calc(var(--base) / 4);
29+
flex: 0 1 calc(var(--field-width) - var(--row-gap));
30+
margin-inline: calc(var(--row-gap) / 2);
2731
}
2832
}
2933
}
3034

3135
@media (max-width: 1024px) {
3236
.row__fields {
33-
display: block;
37+
flex-direction: column;
3438
margin-left: 0;
3539
margin-right: 0;
3640
width: 100%;

packages/ui/src/forms/RenderFields/index.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
}
1616

1717
.render-fields {
18-
--spacing-field: var(--base);
18+
--spacing-field: var(--spacer-3);
1919

2020
&--margins-small {
21-
--spacing-field: var(--base);
21+
--spacing-field: var(--spacer-2);
2222
}
2323

2424
&--margins-none {

test/v4/collections/Row/index.ts

Lines changed: 163 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,179 @@ import { rowFieldsSlug } from '../../slugs.js'
55
const RowFields: CollectionConfig = {
66
slug: rowFieldsSlug,
77
fields: [
8+
// Basic 50/50 split
9+
{
10+
type: 'row',
11+
fields: [
12+
{
13+
name: 'firstName',
14+
type: 'text',
15+
label: 'First Name',
16+
admin: { width: '50%' },
17+
},
18+
{
19+
name: 'lastName',
20+
type: 'text',
21+
label: 'Last Name',
22+
admin: { width: '50%' },
23+
},
24+
],
25+
},
26+
// Three column layout
27+
{
28+
type: 'row',
29+
fields: [
30+
{
31+
name: 'city',
32+
type: 'text',
33+
label: 'City',
34+
admin: { width: '50%' },
35+
},
36+
{
37+
name: 'state',
38+
type: 'text',
39+
label: 'State',
40+
admin: { width: '25%' },
41+
},
42+
{
43+
name: 'zip',
44+
type: 'text',
45+
label: 'Zip',
46+
admin: { width: '25%' },
47+
},
48+
],
49+
},
50+
// Mixed field types
851
{
952
type: 'row',
1053
fields: [
1154
{
1255
name: 'email',
1356
type: 'email',
1457
label: 'Email',
58+
admin: { width: '50%' },
59+
},
60+
{
61+
name: 'phone',
62+
type: 'text',
63+
label: 'Phone',
64+
admin: { width: '25%' },
65+
},
66+
{
67+
name: 'newsletter',
68+
type: 'checkbox',
69+
label: 'Subscribe to newsletter',
70+
admin: { width: '25%' },
71+
},
72+
],
73+
},
74+
// Select and number in row
75+
{
76+
type: 'row',
77+
fields: [
78+
{
79+
name: 'category',
80+
type: 'select',
81+
label: 'Category',
82+
options: [
83+
{ label: 'Option A', value: 'a' },
84+
{ label: 'Option B', value: 'b' },
85+
{ label: 'Option C', value: 'c' },
86+
],
87+
admin: { width: '50%' },
88+
},
89+
{
90+
name: 'quantity',
91+
type: 'number',
92+
label: 'Quantity',
93+
admin: { width: '50%' },
94+
},
95+
],
96+
},
97+
// Auto width (no explicit width set)
98+
{
99+
type: 'row',
100+
fields: [
101+
{
102+
name: 'autoWidthA',
103+
type: 'text',
104+
label: 'Auto Width A',
105+
},
106+
{
107+
name: 'autoWidthB',
108+
type: 'text',
109+
label: 'Auto Width B',
110+
},
111+
],
112+
},
113+
// Mixed explicit and auto widths
114+
{
115+
type: 'row',
116+
fields: [
117+
{
118+
name: 'explicit30',
119+
type: 'text',
120+
label: '30% Width',
121+
admin: { width: '30%' },
122+
},
123+
{
124+
name: 'autoFill',
125+
type: 'text',
126+
label: 'Auto Fill Remaining',
127+
},
128+
],
129+
},
130+
// Four equal columns
131+
{
132+
type: 'row',
133+
fields: [
134+
{
135+
name: 'q1',
136+
type: 'text',
137+
label: 'Q1',
138+
admin: { width: '25%' },
15139
},
16140
{
17-
name: 'password',
141+
name: 'q2',
18142
type: 'text',
19-
label: 'Password',
143+
label: 'Q2',
144+
admin: { width: '25%' },
145+
},
146+
{
147+
name: 'q3',
148+
type: 'text',
149+
label: 'Q3',
150+
admin: { width: '25%' },
151+
},
152+
{
153+
name: 'q4',
154+
type: 'text',
155+
label: 'Q4',
156+
admin: { width: '25%' },
157+
},
158+
],
159+
},
160+
// Collapsibles in a row
161+
{
162+
type: 'row',
163+
fields: [
164+
{
165+
type: 'collapsible',
166+
label: 'Billing Address',
167+
admin: { width: '50%' },
168+
fields: [
169+
{ name: 'billingStreet', type: 'text', label: 'Street' },
170+
{ name: 'billingCity', type: 'text', label: 'City' },
171+
],
172+
},
173+
{
174+
type: 'collapsible',
175+
label: 'Shipping Address',
176+
admin: { width: '50%' },
177+
fields: [
178+
{ name: 'shippingStreet', type: 'text', label: 'Street' },
179+
{ name: 'shippingCity', type: 'text', label: 'City' },
180+
],
20181
},
21182
],
22183
},

0 commit comments

Comments
 (0)