Skip to content

Commit c9aacf1

Browse files
authored
menu finally supports dividers (codesandbox#4031)
1 parent 436b247 commit c9aacf1

File tree

3 files changed

+17
-0
lines changed
  • packages
    • app/src/app
    • components/src/components/Menu

3 files changed

+17
-0
lines changed

packages/app/src/app/overmind/namespaces/dashboard/actions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export const setTrashSandboxes: Action<{
3737
export const setActiveTeam: Action<{
3838
id: string;
3939
}> = ({ state, effects }, { id }) => {
40+
// ignore if its already selected
41+
if (id === state.dashboard.activeTeam) return;
42+
4043
state.dashboard.activeTeam = id;
4144
effects.browser.storage.set(TEAM_ID_LOCAL_STORAGE, id);
4245
state.dashboard.sandboxes = {

packages/app/src/app/pages/NewDashboard/Components/SandboxCard/Menu.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const MenuOptions = ({ sandbox, isTemplate, onRename }) => {
4444
>
4545
Open sandbox in new tab
4646
</Menu.Item>
47+
<Menu.Divider />
4748
<Menu.Item
4849
onSelect={() => {
4950
effects.browser.copyToClipboard(`https://codesandbox.io${url}`);
@@ -68,6 +69,7 @@ export const MenuOptions = ({ sandbox, isTemplate, onRename }) => {
6869
>
6970
Export {isTemplate ? 'template' : 'sandbox'}
7071
</Menu.Item>
72+
<Menu.Divider />
7173
<Menu.Item onSelect={() => onRename()}>Rename sandbox</Menu.Item>
7274
{isTemplate ? (
7375
<Menu.Item
@@ -86,6 +88,7 @@ export const MenuOptions = ({ sandbox, isTemplate, onRename }) => {
8688
Make sandbox a template
8789
</Menu.Item>
8890
)}
91+
<Menu.Divider />
8992
{isTemplate ? (
9093
<Menu.Item onSelect={() => {}}>Delete template</Menu.Item>
9194
) : (

packages/components/src/components/Menu/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ const PortalStyles = createGlobalStyle(
5959
// override reach ui styles
6060
font: 'inherit',
6161
},
62+
'[data-component=MenuDivider]': {
63+
margin: 0,
64+
border: 'none',
65+
borderBottom: '1px solid',
66+
borderColor: 'menuList.border',
67+
},
6268
}),
6369
styledcss`
6470
[data-reach-menu-list][data-trigger=MenuButton] {
@@ -126,10 +132,15 @@ const MenuItem = props => (
126132
<Element as={ReachMenu.MenuItem} data-component="MenuItem" {...props} />
127133
);
128134

135+
const MenuDivider = props => (
136+
<Element as="hr" data-component="MenuDivider" {...props} />
137+
);
138+
129139
Menu.Button = MenuButton;
130140
Menu.IconButton = MenuIconButton;
131141
Menu.List = MenuList;
132142
Menu.Item = MenuItem;
143+
Menu.Divider = MenuDivider;
133144

134145
export const isMenuClicked = event => {
135146
// don't trigger comment if you click on the menu

0 commit comments

Comments
 (0)