Skip to content

Commit 8b5cb74

Browse files
committed
🚧 Extract SandboxOptionsMenu
Extracted menu to it's own component so that it can be used in both ShowcaseCard and FeaturedSandbox
1 parent 3e7f2fa commit 8b5cb74

File tree

6 files changed

+58
-39
lines changed

6 files changed

+58
-39
lines changed
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import React from "react"
2-
import { Container, HeroImage } from "./elements"
1+
import React from 'react';
2+
// import { SandboxOptionsMenu } from "../SandboxOptionsMenu";
3+
import { Container, HeroImage } from './elements';
34

45
interface IFeaturedSandboxProps {
5-
heroImage: string
6+
heroImage: string;
67
}
78

89
export const FeaturedSandbox: React.FC<IFeaturedSandboxProps> = ({
9-
heroImage
10-
}) => { // eslint-disable-line
11-
// TODO:
12-
// - Make Hero Image a Live Sandbox Preview?
10+
heroImage,
11+
}) => {
12+
// eslint-disable-line
13+
// TODO:
14+
// - Make Hero Image a Live Sandbox Preview?
1315
return (
1416
<Container>
1517
<HeroImage src={heroImage} />
1618
</Container>
17-
)
18-
}
19+
);
20+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import MdMoreHoriz from 'react-icons/md/more-horiz';
3+
import { MenuItem, Separator } from '@codesandbox/common/lib/components';
4+
import { Menu } from './elements';
5+
6+
interface ISandboxOptionsMenuProps {}
7+
8+
// eslint-disable-next-line
9+
export const SandboxOptionsMenu: React.FC<ISandboxOptionsMenuProps> = () => {
10+
// TODO:
11+
// - Add Handlers for each Menu Item
12+
13+
return (
14+
<Menu label={<MdMoreHoriz />} aria-label="Sandbox Options">
15+
<MenuItem>Pin Sandbox</MenuItem>
16+
<Separator />
17+
<MenuItem>Open Sandbox</MenuItem>
18+
<Separator />
19+
<MenuItem>Fork Sandbox</MenuItem>
20+
<Separator />
21+
<MenuItem disabled>Hide Sandbox</MenuItem>
22+
<Separator />
23+
<MenuItem danger>Move to Trash</MenuItem>
24+
</Menu>
25+
);
26+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import styled from 'styled-components';
2+
import { Menu as BaseMenu } from '@codesandbox/common/lib/components';
3+
4+
export const Menu = styled(BaseMenu)`
5+
flex: 0 0 auto;
6+
7+
svg {
8+
color: #757575;
9+
font-size: 32px;
10+
11+
&:hover,
12+
&:focus {
13+
color: #fff;
14+
}
15+
}
16+
`;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { SandboxOptionsMenu } from './SandboxOptionsMenu';

‎packages/app/src/app/pages/Profile/ShowcaseCard/ShowcaseCard.tsx‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ import { LightIcons } from '@codesandbox/template-icons';
33
import GoHeart from 'react-icons/go/heart';
44
import GoEye from 'react-icons/go/eye';
55
import GoRepoForked from 'react-icons/go/repo-forked';
6-
import MdMoreHoriz from 'react-icons/md/more-horiz';
7-
import { Link, MenuItem, Separator } from '@codesandbox/common/lib/components';
6+
import { Link } from '@codesandbox/common/lib/components';
7+
import { SandboxOptionsMenu } from '../SandboxOptionsMenu';
88
import { abbreviateNumber } from './abbreviateNumber';
99
import {
1010
Container,
1111
Preview,
1212
SandboxInfo,
1313
TitleRow,
1414
Title,
15-
Menu,
1615
Description,
1716
Statistics,
1817
Action,
@@ -48,7 +47,6 @@ export const ShowcaseCard: React.FC<IShowcaseCardProps> = ({
4847
}) => {
4948
// TODO:
5049
// - Add handler for Liking/Unliking the sandbox.
51-
// - Add handles for all options menu buttons (Pin, Open, Fork, Hide, Trash)
5250
return (
5351
<Container>
5452
<Link to={`/s/${id}`}>
@@ -57,17 +55,7 @@ export const ShowcaseCard: React.FC<IShowcaseCardProps> = ({
5755
<SandboxInfo>
5856
<TitleRow>
5957
<Title>{title}</Title>
60-
<Menu label={<MdMoreHoriz />} aria-label="Sandbox Options">
61-
<MenuItem>Pin Sandbox</MenuItem>
62-
<Separator />
63-
<MenuItem>Open Sandbox</MenuItem>
64-
<Separator />
65-
<MenuItem>Fork Sandbox</MenuItem>
66-
<Separator />
67-
<MenuItem disabled>Hide Sandbox</MenuItem>
68-
<Separator />
69-
<MenuItem danger>Move to Trash</MenuItem>
70-
</Menu>
58+
<SandboxOptionsMenu />
7159
</TitleRow>
7260
<Description>{description}</Description>
7361
<Statistics>

‎packages/app/src/app/pages/Profile/ShowcaseCard/elements.ts‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styled, { css } from 'styled-components';
22
import { Button } from 'reakit/Button';
3-
import { Link, Menu as BaseMenu } from '@codesandbox/common/lib/components';
3+
import { Link } from '@codesandbox/common/lib/components';
44

55
export const Container = styled.div`
66
min-width: 303px;
@@ -30,20 +30,6 @@ export const Title = styled.h1`
3030
font-weight: 500;
3131
`;
3232

33-
export const Menu = styled(BaseMenu)`
34-
flex: 0 0 auto;
35-
36-
svg {
37-
color: #757575;
38-
font-size: 32px;
39-
40-
&:hover,
41-
&:focus {
42-
color: #fff;
43-
}
44-
}
45-
`;
46-
4733
export const Description = styled.p`
4834
color: #999;
4935
font-family: Inter;

0 commit comments

Comments
 (0)