Skip to content

Commit 305e500

Browse files
authored
Make tabs on new sandbox modal (codesandbox#1423)
<!-- Is it a Bug fix, feature, docs update, ... --> **What kind of change does this PR introduce?** Adds tabs to the new sandbox modal since we are getting too many templates <!-- You can also link to an open issue here --> **What is the current behavior?** Currently ut's a long modal <!-- if this is a feature change --> **What is the new behavior?** Tabs for popular, client, server and preset templates <img width="1320" alt="screenshot 2019-01-03 at 22 54 02" src="https://user-images.githubusercontent.com/1051509/50664276-cb3bdb80-0fac-11e9-9830-7766cbd828d8.png">
1 parent 89d4f0a commit 305e500

File tree

15 files changed

+243
-184
lines changed

15 files changed

+243
-184
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build:embed": "lerna run build:embed --scope app --stream && gulp",
1010
"build:clean": "lerna run build:clean --scope app --scope homepage && rimraf www",
1111
"build:deps": "lerna run build:dev --scope codesandbox-api && lerna run build:dev --scope @codesandbox/common && lerna run build:dev --scope vscode-textmate --scope codesandbox-browserfs --scope node-services && lerna run build:dev --scope sse-hooks",
12+
"build:common": "lerna run build:dev --scope @codesandbox/common --stream",
1213
"build:dynamic": "lerna run build --scope dynamic-pages --stream",
1314
"start": "yarn build:deps && lerna run start --scope app --stream",
1415
"start:fast": "lerna run start --scope app --stream",

packages/app/src/app/pages/Dashboard/Content/CreateNewSandbox/Modal/Template/elements.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,12 @@ export const Container = styled.div`
55
display: inline-block;
66
padding: 1em;
77
color: white;
8-
9-
width: 100%;
108
border: 2px solid rgba(0, 0, 0, 0.3);
119
background-color: rgba(0, 0, 0, 0.2);
1210
border-radius: 4px;
1311
display: flex;
1412
align-items: center;
15-
margin-bottom: 1em;
1613
cursor: pointer;
17-
18-
@media (min-width: 768px) {
19-
width: ${props => props.width}px;
20-
margin-right: 1em;
21-
22-
&:last-child {
23-
margin-right: 0;
24-
}
25-
}
26-
2714
outline: none;
2815
2916
${props =>

packages/app/src/app/pages/Dashboard/Content/CreateNewSandbox/Modal/Template/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import getIcon from '@codesandbox/common/lib/templates/icons';
44
import { ENTER } from '@codesandbox/common/lib/utils/keycodes';
55
import { Container, IconContainer, Title, SubTitle } from './elements';
66

7-
export default ({ template, subtitle, width, selectTemplate, small }) => {
7+
export default ({ template, subtitle, selectTemplate, small }) => {
88
const Icon = getIcon(template.name);
99

1010
const select = () => selectTemplate(template);
@@ -15,7 +15,6 @@ export default ({ template, subtitle, width, selectTemplate, small }) => {
1515
<Container
1616
onClick={select}
1717
color={template.color}
18-
width={width}
1918
onKeyDown={e => {
2019
if (e.keyCode === ENTER) {
2120
select();
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import * as templates from '@codesandbox/common/lib/templates';
2+
import { sortBy } from 'lodash-es';
3+
4+
const usedTemplates = sortBy(
5+
Object.keys(templates)
6+
.filter(x => x !== 'default')
7+
.map(t => templates[t])
8+
.filter(t => t.showOnHomePage),
9+
'niceName'
10+
);
11+
12+
const presets = [
13+
{
14+
...templates.react,
15+
variantName: templates.react.niceName,
16+
niceName: 'React + TS',
17+
shortid: 'react-ts',
18+
},
19+
{
20+
...templates.parcel,
21+
variantName: templates.parcel.niceName,
22+
niceName: 'Vanilla + TS',
23+
shortid: 'vanilla-ts',
24+
},
25+
];
26+
27+
export default [
28+
{
29+
name: 'Popular Templates',
30+
types: [
31+
{
32+
name: 'Client Templates',
33+
templates: usedTemplates.filter(t => t.popular && !t.isServer),
34+
},
35+
{
36+
name: 'Server Templates',
37+
templates: usedTemplates.filter(t => t.popular && t.isServer),
38+
},
39+
{
40+
name: 'Presets',
41+
templates: presets,
42+
},
43+
],
44+
},
45+
{
46+
name: 'Client Templates',
47+
templates: usedTemplates.filter(t => !t.isServer),
48+
},
49+
{
50+
name: 'Server Templates',
51+
templates: usedTemplates.filter(t => t.isServer),
52+
},
53+
{
54+
name: 'Presets',
55+
templates: presets,
56+
},
57+
];

packages/app/src/app/pages/Dashboard/Content/CreateNewSandbox/Modal/elements.js

Lines changed: 98 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ export const Container = styled.main`
88
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
99
color: ${props =>
1010
props.theme.light ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)'};
11-
border-radius: 4px;
11+
border-radius: 0 0 4px 4px;
1212
padding: 2rem;
1313
width: 100%;
1414
box-sizing: border-box;
15+
position: relative;
1516
1617
${props =>
1718
props.closing &&
@@ -35,9 +36,6 @@ export const Container = styled.main`
3536
`;
3637

3738
export const InnerContainer = styled.div`
38-
transition: 0.15s ease opacity;
39-
${delayEffect(0.3)};
40-
4139
${props =>
4240
(props.closing || props.forking) &&
4341
css`
@@ -47,30 +45,28 @@ export const InnerContainer = styled.div`
4745
`};
4846
`;
4947

50-
export const Title = styled.h2`
51-
font-weight: 600;
52-
text-transform: uppercase;
53-
font-size: 0.875rem;
54-
color: rgba(255, 255, 255, 0.5);
55-
margin-bottom: 1rem;
56-
margin-top: 1rem;
48+
export const Templates = styled.div`
49+
display: grid;
50+
grid-template-columns: 1fr 1fr;
51+
grid-gap: 1rem;
5752
58-
&:first-child {
59-
margin-top: 0;
53+
@media (min-width: 768px) {
54+
grid-template-columns: repeat(4, 1fr);
6055
}
6156
`;
6257

63-
export const Templates = styled.div`
58+
export const ImportChoices = styled.div`
59+
margin-top: 2.5em;
6460
display: flex;
6561
align-items: center;
66-
67-
@media (max-width: 870px) {
68-
flex-wrap: wrap;
69-
}
62+
justify-content: space-between;
63+
${delayEffect(0.1)};
7064
`;
7165

72-
export const ImportChoices = styled(Templates)`
73-
justify-content: space-between;
66+
export const Tab = styled.section`
67+
display: ${props => (props.visible ? 'block' : 'none')};
68+
transition: 0.15s ease opacity;
69+
${delayEffect(0.1)};
7470
`;
7571

7672
export const ImportChoice = styled.a`
@@ -92,3 +88,85 @@ export const ImportChoice = styled.a`
9288
color: rgba(255, 255, 255, 1);
9389
}
9490
`;
91+
92+
const activeStyles = css`
93+
color: white;
94+
padding-bottom: 0;
95+
padding-top: 0;
96+
outline: none;
97+
98+
&:after {
99+
width: 110%;
100+
101+
@media screen and (max-width: 500px) {
102+
width: 100%;
103+
}
104+
}
105+
`;
106+
107+
export const Button = styled.button`
108+
background: transparent;
109+
font-family: 'Roboto', sans-serif;
110+
border: none;
111+
margin: 0;
112+
font-weight: 600;
113+
text-transform: uppercase;
114+
font-size: 0.875rem;
115+
color: ${props => (props.selected ? 'white' : 'rgba(255, 255, 255, 0.5)')};
116+
padding: 0 20px;
117+
transition: 0.15s ease all;
118+
position: relative;
119+
cursor: pointer;
120+
${delayEffect(0.1)};
121+
122+
&:after {
123+
content: '';
124+
margin-top: 22px;
125+
display: block;
126+
position: relative;
127+
background: #40a9f3;
128+
height: 2px;
129+
box-sizing: border-box;
130+
width: 0%;
131+
margin-left: -5%;
132+
transition: all 200ms ease;
133+
134+
@media screen and (max-width: 500px) {
135+
margin-left: 0%;
136+
}
137+
}
138+
139+
${props =>
140+
props.selected &&
141+
css`
142+
${activeStyles};
143+
`};
144+
145+
&:hover {
146+
${activeStyles};
147+
}
148+
`;
149+
150+
export const TabContainer = styled.div`
151+
width: 100%;
152+
border-radius: 4px 4px 0 0;
153+
display: flex;
154+
background: #1b1d1f;
155+
height: 62px;
156+
box-sizing: border-box;
157+
padding: 0 2rem;
158+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
159+
`;
160+
161+
export const Title = styled.h2`
162+
grid-column: 1/-1;
163+
font-weight: 600;
164+
text-transform: uppercase;
165+
font-size: 0.875rem;
166+
color: rgba(255, 255, 255, 0.5);
167+
margin-bottom: 0;
168+
margin-top: 1rem;
169+
&:first-child {
170+
margin-top: 0;
171+
}
172+
`;

0 commit comments

Comments
 (0)