Skip to content

Commit 12180a0

Browse files
ktaborsdannify
andauthored
Disclosure button label size update to match new sizes from Specturm (#8006)
Co-authored-by: Danni <[email protected]>
1 parent 77589c2 commit 12180a0

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

packages/@react-spectrum/s2/src/Disclosure.tsx

+18-24
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ const buttonStyles = style({
130130
fontWeight: 'bold',
131131
fontSize: {
132132
size: {
133-
S: 'heading-xs',
134-
M: 'heading-sm',
135-
L: 'heading',
136-
XL: 'heading-lg'
133+
S: 'title-sm',
134+
M: 'title',
135+
L: 'title-lg',
136+
XL: 'title-xl'
137137
}
138138
},
139139
lineHeight: 'ui',
@@ -147,32 +147,32 @@ const buttonStyles = style({
147147
// compact is equivalent to 'control', but other densities have more padding.
148148
size: {
149149
S: {
150+
density: {
151+
compact: 18,
152+
regular: 24,
153+
spacious: 32
154+
}
155+
},
156+
M: {
150157
density: {
151158
compact: 24,
152159
regular: 32,
153160
spacious: 40
154161
}
155162
},
156-
M: {
163+
L: {
157164
density: {
158165
compact: 32,
159166
regular: 40,
160167
spacious: 48
161168
}
162169
},
163-
L: {
170+
XL: {
164171
density: {
165172
compact: 40,
166173
regular: 48,
167174
spacious: 56
168175
}
169-
},
170-
XL: {
171-
density: {
172-
compact: 48,
173-
regular: 56,
174-
spacious: 64
175-
}
176176
}
177177
}
178178
},
@@ -219,18 +219,12 @@ function DisclosureHeaderWithForwardRef(props: DisclosureHeaderProps, ref: DOMRe
219219
let domRef = useDOMRef(ref);
220220
let {size, isQuiet, density} = useSlottedContext(DisclosureContext)!;
221221

222-
let mapSize = {
223-
S: 'XS',
224-
M: 'S',
225-
L: 'M',
226-
XL: 'L'
227-
};
228-
229-
// maps to one size smaller in the compact density to ensure there is space between the top and bottom of the action button and container
222+
// Shift button size down by 2 for compact density, 1 for regular/spacious to ensure there is space between the top and bottom of the action button and container
230223
let newSize : 'XS' | 'S' | 'M' | 'L' | 'XL' | undefined = size;
231-
if (density === 'compact') {
232-
newSize = mapSize[size ?? 'M'] as 'XS' | 'S' | 'M' | 'L';
233-
}
224+
const sizes = ['XS', 'S', 'M', 'L', 'XL'];
225+
const currentIndex = sizes.indexOf(size ?? 'M');
226+
const shift = density === 'compact' ? 2 : 1;
227+
newSize = sizes[Math.max(0, currentIndex - shift)] as 'XS' | 'S' | 'M' | 'L' | 'XL';
234228

235229
return (
236230
<Provider

0 commit comments

Comments
 (0)