Skip to content

Commit c076724

Browse files
committed
Add section styles
1 parent 70fbbaa commit c076724

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

src/menu/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const menuULCSS = css`
4646
max-height: inherit;
4747
list-style: none;
4848
margin: 0;
49-
padding: 0;
49+
padding: ${theme.spacing.padding4}px 0;
5050
`;
5151
function Menu<T extends object>(
5252
props: MenuComponentProps<T>,

src/menu/MenuSection.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import React, { Fragment, Key } from 'react';
44
import { TreeState } from '@react-stately/tree';
55
import { useMenuSection } from '@react-aria/menu';
66
import { useSeparator } from '@react-aria/separator';
7+
import { css } from '@emotion/core';
8+
import theme from '../theme';
79

810
interface MenuSectionProps<T> {
911
item: Node<T>;
@@ -26,15 +28,36 @@ export function MenuSection<T>(props: MenuSectionProps<T>) {
2628
return (
2729
<Fragment>
2830
{item.key !== state.collection.getFirstKey() && (
29-
<li {...separatorProps} className={'ac-menu-divider'} />
31+
<li
32+
{...separatorProps}
33+
className={'ac-menu-divider'}
34+
css={css`
35+
border-bottom: 1px solid ${theme.components.dropdown.borderColor};
36+
`}
37+
/>
3038
)}
3139
<li {...itemProps}>
3240
{item.rendered && (
33-
<span {...headingProps} className={'ac-menu__section-heading'}>
41+
<span
42+
{...headingProps}
43+
className={'ac-menu__section-heading'}
44+
css={css`
45+
display: inline-block;
46+
margin: ${theme.spacing.margin8}px ${theme.spacing.margin16}px;
47+
font-size: ${theme.typography.sizes.small.fontSize}px;
48+
color: ${theme.textColors.white70};
49+
`}
50+
>
3451
{item.rendered}
3552
</span>
3653
)}
37-
<ul {...groupProps} className={'ac-menu'}>
54+
<ul
55+
{...groupProps}
56+
className={'ac-menu'}
57+
css={css`
58+
padding: 0;
59+
`}
60+
>
3861
{[...item.childNodes].map(node => {
3962
let item = (
4063
<MenuItem

stories/ActionMenu.stories.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
DropdownProps,
1111
ActionMenu,
1212
Item,
13+
Heading,
14+
Section,
1315
} from '../src';
1416
import { Icon, PlusCircleOutline } from '../src/icon';
1517

@@ -37,13 +39,15 @@ const Template: Story<DropdownProps> = args => (
3739
<div
3840
css={css`
3941
margin: 24px;
42+
> * {
43+
margin-bottom: 16px;
44+
}
4045
`}
4146
>
4247
<div
4348
css={css`
4449
display: flex;
4550
gap: 4px;
46-
margin-bottom: 16px;
4751
`}
4852
>
4953
<ActionMenu
@@ -88,6 +92,20 @@ const Template: Story<DropdownProps> = args => (
8892
<Item key="three">Three</Item>
8993
</ActionMenu>
9094
</div>
95+
<div>
96+
<Heading>With Section</Heading>
97+
<ActionMenu isOpen>
98+
<Section title="File">
99+
<Item key="new">New</Item>
100+
<Item key="open">Open...</Item>
101+
</Section>
102+
<Section title="Save">
103+
<Item key="save">Save</Item>
104+
<Item key="saveAs">Save As...</Item>
105+
<Item key="saveAll">Save All</Item>
106+
</Section>
107+
</ActionMenu>
108+
</div>
91109
</div>
92110
</Provider>
93111
);

0 commit comments

Comments
 (0)