Skip to content

Commit b254854

Browse files
feat(ui): update Group field styles to match v4 design (#16423)
## Summary Updates the Group field component styles to match the v4 design. ## Changes - **Separator line position**: Changed from top border to bottom border - each group now owns its bottom separator instead of top - **Description color**: Updated FieldDescription color from `--text-tertiary` to `--text-secondary` - **ErrorPill positioning**: Restructured header to place ErrorPill inline with the title (instead of after description) - **Test collection**: Added test variants for required fields with validation errors ## References https://app.asana.com/1/10497086658021/project/1213409914712008/task/1214061555627424?focus=true
1 parent 019335b commit b254854

3 files changed

Lines changed: 54 additions & 16 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
&::before {
1010
content: '';
1111
position: absolute;
12-
top: calc(var(--spacer-5) / 2);
12+
top: calc(var(--spacer-5) / -2);
1313
left: calc(var(--gutter-h) * -1);
1414
right: calc(var(--gutter-h) * -1);
1515
height: 0;
@@ -87,15 +87,15 @@
8787

8888
.group-field__header {
8989
margin-bottom: var(--spacer-2-5);
90+
display: flex;
91+
flex-direction: column;
92+
gap: var(--spacer-1);
93+
}
94+
95+
.group-field__title-row {
9096
display: flex;
9197
align-items: center;
9298
gap: var(--spacer-2);
93-
94-
> header {
95-
display: flex;
96-
flex-direction: column;
97-
gap: var(--spacer-1);
98-
}
9999
}
100100

101101
.group-field__title {

packages/ui/src/fields/Group/index.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export const GroupFieldComponent: GroupFieldClientComponent = (props) => {
8181
<div className={`${baseClass}__wrap`}>
8282
{Boolean(Label || Description || label || fieldHasErrors) && (
8383
<div className={`${baseClass}__header`}>
84-
{Boolean(Label || Description || label) && (
85-
<header>
84+
<div className={`${baseClass}__title-row`}>
85+
{Boolean(Label || Description || label) && (
8686
<RenderCustomComponent
8787
CustomComponent={Label}
8888
Fallback={
@@ -97,13 +97,13 @@ export const GroupFieldComponent: GroupFieldClientComponent = (props) => {
9797
</h3>
9898
}
9999
/>
100-
<RenderCustomComponent
101-
CustomComponent={Description}
102-
Fallback={<FieldDescription description={description} path={path} />}
103-
/>
104-
</header>
105-
)}
106-
{fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}
100+
)}
101+
{fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}
102+
</div>
103+
<RenderCustomComponent
104+
CustomComponent={Description}
105+
Fallback={<FieldDescription description={description} path={path} />}
106+
/>
107107
</div>
108108
)}
109109
{BeforeInput}

test/v4/collections/Group/index.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const GroupFields: CollectionConfig = {
99
name: 'shippingInfo',
1010
type: 'group',
1111
label: 'Shipping Info',
12+
admin: {
13+
description: 'Enter the shipping address details',
14+
},
1215
fields: [
1316
{
1417
name: 'name',
@@ -37,6 +40,41 @@ const GroupFields: CollectionConfig = {
3740
},
3841
],
3942
},
43+
{
44+
name: 'requiredInfo',
45+
type: 'group',
46+
label: 'Required Info',
47+
admin: {
48+
description: 'This group has required fields to test error state',
49+
},
50+
fields: [
51+
{
52+
name: 'requiredField',
53+
type: 'text',
54+
label: 'Required Field',
55+
required: true,
56+
},
57+
{
58+
name: 'anotherRequired',
59+
type: 'text',
60+
label: 'Another Required',
61+
required: true,
62+
},
63+
],
64+
},
65+
{
66+
type: 'group',
67+
name: 'unnamedGroup',
68+
label: '',
69+
fields: [
70+
{
71+
name: 'unnamedGroupField',
72+
type: 'text',
73+
label: 'Field in Unnamed Group',
74+
required: true,
75+
},
76+
],
77+
},
4078
],
4179
}
4280

0 commit comments

Comments
 (0)