Skip to content

Commit 53cee34

Browse files
committed
Update alignment of multi-section menus
1 parent 773715a commit 53cee34

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,12 @@ export function ComboBoxItem(props: ComboBoxItemProps) {
379379

380380
export interface ComboBoxSectionProps<T extends object> extends SectionProps<T> {}
381381
export function ComboBoxSection<T extends object>(props: ComboBoxSectionProps<T>) {
382+
let {size} = useContext(InternalComboboxContext);
382383
return (
383384
<>
384385
<AriaListBoxSection
385386
{...props}
386-
className={section}>
387+
className={section({size})}>
387388
{props.children}
388389
</AriaListBoxSection>
389390
<Divider />

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,19 @@ export interface MenuProps<T> extends Omit<AriaMenuProps<T>, 'children' | 'style
8888

8989
export const MenuContext = createContext<ContextValue<MenuProps<any>, DOMRefValue<HTMLDivElement>>>(null);
9090

91+
const menuItemGrid = {
92+
size: {
93+
S: [edgeToText(24), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(24)],
94+
M: [edgeToText(32), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(32)],
95+
L: [edgeToText(40), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(40)],
96+
XL: [edgeToText(48), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(48)]
97+
}
98+
} as const;
99+
91100
export let menu = style({
92101
outlineStyle: 'none',
93102
display: 'grid',
94-
gridTemplateColumns: {
95-
size: {
96-
S: [edgeToText(24), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(24)],
97-
M: [edgeToText(32), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(32)],
98-
L: [edgeToText(40), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(40)],
99-
XL: [edgeToText(48), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(48)]
100-
}
101-
},
103+
gridTemplateColumns: menuItemGrid,
102104
boxSizing: 'border-box',
103105
maxHeight: '[inherit]',
104106
overflow: {
@@ -123,7 +125,7 @@ export let section = style({
123125
'. checkmark icon label value keyboard descriptor .',
124126
'. . . description . . . .'
125127
],
126-
gridTemplateColumns: 'subgrid'
128+
gridTemplateColumns: menuItemGrid
127129
});
128130

129131
export let sectionHeader = style<{size?: 'S' | 'M' | 'L' | 'XL'}>({
@@ -425,11 +427,12 @@ export function Divider(props: SeparatorProps) {
425427
export interface MenuSectionProps<T extends object> extends AriaMenuSectionProps<T> {}
426428
export function MenuSection<T extends object>(props: MenuSectionProps<T>) {
427429
// remember, context doesn't work if it's around Section nor inside
430+
let {size} = useContext(InternalMenuContext);
428431
return (
429432
<>
430433
<AriaMenuSection
431434
{...props}
432-
className={section}>
435+
className={section({size})}>
433436
{props.children}
434437
</AriaMenuSection>
435438
<Divider />

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,12 @@ function DefaultProvider({context, value, children}: {context: React.Context<any
464464

465465
export interface PickerSectionProps<T extends object> extends SectionProps<T> {}
466466
export function PickerSection<T extends object>(props: PickerSectionProps<T>) {
467+
let {size} = useContext(InternalPickerContext);
467468
return (
468469
<>
469470
<AriaListBoxSection
470471
{...props}
471-
className={section}>
472+
className={section({size})}>
472473
{props.children}
473474
</AriaListBoxSection>
474475
<Divider />

0 commit comments

Comments
 (0)