Skip to content

Commit 2ede7ee

Browse files
fix(ui): align Section styles
1 parent cbd62f4 commit 2ede7ee

4 files changed

Lines changed: 52 additions & 21 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/swingset/src/stories/section.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Section } from '@clerk/ui/mosaic/components/section';
2626
</Section.Root>
2727
```
2828

29-
`Section.Group` owns the outlined surface. Its direct `Section.Row` children own separation and may stack one or more `Section.Item` entries. Each item lays out optional media, flexible content, and trailing actions. `Section.Media` accepts `md` and `lg` sizes.
29+
`Section.Group` owns the outlined surface. Its direct `Section.Row` children own separation and may stack one or more `Section.Item` entries. Each item lays out optional media, flexible content, and trailing actions. `Section.Media` accepts `sm`, `md`, `lg`, and `xl` sizes.
3030

3131
Use `Section.Items` for a nested value list beneath a row's header item. The row keeps an 8px header-to-list gap, nested items stack without gaps at a 44px minimum height, and their content receives 12px vertical padding.
3232

packages/swingset/src/stories/section.stories.tsx

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,27 @@ export function Default() {
3535
<Section.Group>
3636
<Section.Row>
3737
<Section.Item>
38-
<Section.Content>
39-
<Section.Label>Profile picture</Section.Label>
40-
<Section.Description>PNG or JPEG, Recommended size 1:1, up to 10MB.</Section.Description>
41-
</Section.Content>
42-
<Section.Actions>
43-
<Avatar.Root size='lg'>
38+
<Section.Media size='xl'>
39+
<Avatar.Root size='fit'>
4440
<Avatar.Image
4541
alt='Preston Booth'
4642
src='https://avatars.githubusercontent.com/u/51144033?v=4'
4743
/>
4844
<Avatar.Fallback>PB</Avatar.Fallback>
4945
</Avatar.Root>
46+
</Section.Media>
47+
<Section.Content>
48+
<Section.Label>Profile picture</Section.Label>
49+
<Section.Description>Recommend size 1:1, up to 10MB.</Section.Description>
50+
</Section.Content>
51+
<Section.Actions>
52+
<Button
53+
color='neutral'
54+
size='sm'
55+
variant='outline'
56+
>
57+
Upload
58+
</Button>
5059
</Section.Actions>
5160
</Section.Item>
5261
</Section.Row>
@@ -63,7 +72,7 @@ export function Default() {
6372
size='sm'
6473
variant='outline'
6574
>
66-
Update name
75+
Edit name
6776
</Button>
6877
</Section.Actions>
6978
</Section.Item>
@@ -81,7 +90,7 @@ export function Default() {
8190
size='sm'
8291
variant='outline'
8392
>
84-
Update username
93+
Edit username
8594
</Button>
8695
</Section.Actions>
8796
</Section.Item>
@@ -116,18 +125,27 @@ export function MultipleEmailAndPhoneNumbers() {
116125
<Section.Group>
117126
<Section.Row>
118127
<Section.Item>
119-
<Section.Content>
120-
<Section.Label>Profile picture</Section.Label>
121-
<Section.Description>PNG or JPEG, Recommended size 1:1, up to 10MB.</Section.Description>
122-
</Section.Content>
123-
<Section.Actions>
124-
<Avatar.Root size='lg'>
128+
<Section.Media size='xl'>
129+
<Avatar.Root size='fit'>
125130
<Avatar.Image
126131
alt='Preston Booth'
127132
src='https://avatars.githubusercontent.com/u/51144033?v=4'
128133
/>
129134
<Avatar.Fallback>PB</Avatar.Fallback>
130135
</Avatar.Root>
136+
</Section.Media>
137+
<Section.Content>
138+
<Section.Label>Profile picture</Section.Label>
139+
<Section.Description>Recommend size 1:1, up to 10MB.</Section.Description>
140+
</Section.Content>
141+
<Section.Actions>
142+
<Button
143+
color='neutral'
144+
size='sm'
145+
variant='outline'
146+
>
147+
Upload
148+
</Button>
131149
</Section.Actions>
132150
</Section.Item>
133151
</Section.Row>
@@ -144,7 +162,7 @@ export function MultipleEmailAndPhoneNumbers() {
144162
size='sm'
145163
variant='outline'
146164
>
147-
Update name
165+
Edit name
148166
</Button>
149167
</Section.Actions>
150168
</Section.Item>
@@ -162,7 +180,7 @@ export function MultipleEmailAndPhoneNumbers() {
162180
size='sm'
163181
variant='outline'
164182
>
165-
Update username
183+
Edit username
166184
</Button>
167185
</Section.Actions>
168186
</Section.Item>

packages/ui/src/mosaic/components/section/section.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type SectionGroupProps = MosaicComponentProps<'div'>;
1717
export type SectionRowProps = MosaicComponentProps<'div'>;
1818
export type SectionItemsProps = MosaicComponentProps<'div'>;
1919
export type SectionItemProps = MosaicComponentProps<'div'>;
20-
export type SectionMediaSize = 'sm' | 'md' | 'lg';
20+
export type SectionMediaSize = 'sm' | 'md' | 'lg' | 'xl';
2121
export type SectionMediaProps = MosaicComponentProps<'div'> & { size?: SectionMediaSize };
2222
export type SectionContentProps = MosaicComponentProps<'div'>;
2323
export type SectionLabelProps = MosaicComponentProps<'div'>;
@@ -33,13 +33,19 @@ const styles = stylex.create({
3333
rowGap: space['2'],
3434
width: '100%',
3535
},
36+
title: {
37+
alignItems: 'center',
38+
display: 'flex',
39+
fontWeight: fontWeightVars['--cl-font-medium'],
40+
minHeight: space['8'],
41+
},
3642
group: {
3743
borderColor: colorVars['--cl-color-border'],
3844
borderRadius: radiusVars['--cl-radius-xl'],
3945
borderStyle: 'solid',
4046
borderWidth: '1px',
4147
overflow: 'hidden',
42-
backgroundColor: colorVars['--cl-color-background'],
48+
backgroundColor: colorVars['--cl-color-card'],
4349
width: '100%',
4450
},
4551
row: {
@@ -96,6 +102,10 @@ const styles = stylex.create({
96102
height: space['8'],
97103
width: space['8'],
98104
},
105+
mediaXl: {
106+
height: space['10'],
107+
width: space['10'],
108+
},
99109
content: {
100110
display: 'flex',
101111
flexDirection: 'column',
@@ -116,7 +126,7 @@ const styles = stylex.create({
116126
description: {
117127
color: colorVars['--cl-color-neutral-faded'],
118128
fontSize: typeScaleVars['--cl-text-sm-size'],
119-
fontWeight: fontWeightVars['--cl-font-medium'],
129+
fontWeight: fontWeightVars['--cl-font-normal'],
120130
lineHeight: typeScaleVars['--cl-text-sm-leading'],
121131
textWrap: 'balance',
122132
},
@@ -134,6 +144,7 @@ const mediaSizes = {
134144
sm: styles.mediaSm,
135145
md: styles.mediaMd,
136146
lg: styles.mediaLg,
147+
xl: styles.mediaXl,
137148
};
138149

139150
const SectionTitleContext = React.createContext<React.Dispatch<React.SetStateAction<string[]>> | null>(null);
@@ -183,7 +194,7 @@ const Title = React.forwardRef<HTMLHeadingElement, SectionTitleProps>(function S
183194
id={id}
184195
render={render ?? (props => <h4 {...props} />)}
185196
size='sm'
186-
{...mergeStyleProps(themeProps('section-title'), className, style)}
197+
{...mergeStyleProps(themeProps('section-title'), stylex.props(styles.title), className, style)}
187198
{...rest}
188199
/>
189200
);

0 commit comments

Comments
 (0)