Skip to content

Commit 31cd74e

Browse files
siddharthkpCompuIves
authored andcommitted
Embed redesign - release 1 (codesandbox#2791)
* create new vscode theme for new redesign * remove dead code * tiny polish for missing tab styles * copy sidebar border * Fix bad merge * Get tokens + styled-system going [skip ci] * get sidebar sections in [skip ci] * add stats to sandbox info * linter oh linter * drone is confused, i need a commit * get the border right * who knew dot object mutates object! * sync the sidebar border color * [WIP] [skip ci] get sandboxed version working in app * sync font size scale with dannys * fix stats design * add hover styles for section with icon * get the right icons to work * lint ignore ts import * make the linter happy-ish * delete old file tree whoop! * add dependencies * remove old open in sandbox link * bring the app back * Fix usage of filetree in share modal * use line height 24 * bring back legacy filetree for share modal * compat mode for header * sync theme with danny * fix file tree icon alignment * reduce header height * add border to header back * match selection background for editor * customise tab borders * Make tabs respect vscode theme * add tabs border for embed * hide title when sidebar already shows it * add Open sandbox button * Redesign icons in header * hack hover styles for Tab * make open sandbox margin adjustable * Fix bad merge * lol remove debug statement!!
1 parent 09bab3a commit 31cd74e

File tree

38 files changed

+2705
-328
lines changed

38 files changed

+2705
-328
lines changed

packages/app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"@codesandbox/template-icons": "^1.0.1",
7474
"@emmetio/codemirror-plugin": "^0.3.5",
7575
"@sentry/webpack-plugin": "^1.8.0",
76+
"@styled-system/css": "^5.0.23",
7677
"@svgr/core": "^2.4.1",
7778
"@typeform/embed": "^0.12.0",
7879
"@types/rc-slider": "^8.6.5",
@@ -107,6 +108,7 @@
107108
"date-fns": "^2.4.1",
108109
"date-fns-tz": "^1.0.7",
109110
"debug": "^2.6.8",
111+
"dot-object": "^1.9.0",
110112
"downshift": "^1.0.0-rc.14",
111113
"eslint-plugin-react-hooks": "1.6.0",
112114
"eslint-plugin-vue": "^4.2.2",

packages/app/src/app/pages/Sandbox/Editor/Content/Tabs/Tab/elements.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export const Container = styled.div<{
1111
justify-content: center;
1212
align-items: center;
1313
line-height: 1;
14-
height: calc(100% - 1px);
14+
height: 100%;
1515
font-size: 0.875rem;
1616
cursor: pointer;
1717
18-
border-bottom: 1px solid transparent;
18+
border-bottom: 1px solid ${props => props.theme['tab.border']};
1919
2020
padding: 0 1rem;
2121
padding-left: 0.75rem;
@@ -42,7 +42,7 @@ export const Container = styled.div<{
4242
css`
4343
background-color: ${props.theme['tab.activeBackground'] ||
4444
props.theme.background2};
45-
border-color: ${props.theme.secondary};
45+
border-color: ${props.theme['tab.activeBorder']};
4646
color: ${props.theme['tab.activeForeground'] ||
4747
props.theme['editor.foreground'] ||
4848
'white'};

packages/app/src/app/pages/common/Modals/ShareModal/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { inject, observer } from 'app/componentConnectors';
3-
import Files from 'embed/components/Files';
3+
import Files from 'embed/components/legacy/Files';
44
import QRCode from 'qrcode.react';
55
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
66
import track from '@codesandbox/common/lib/utils/analytics';

packages/app/src/embed/components/App/elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ export const Moving = styled.div`
3333
left: 250px;
3434
transform: inherit;
3535
box-shadow: none;
36-
border-left: 1px solid ${props => props.theme.background4};
36+
border-left: 1px solid ${props => props.theme.colors.sideBar.border};
3737
}
3838
`;

packages/app/src/embed/components/App/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { SubTitle } from 'app/components/SubTitle';
1616
import Header from '../Header';
1717
import Content from '../Content';
1818
import Sidebar from '../Sidebar';
19+
import EditorLink from '../EditorLink';
1920
import { Container, Fullscreen, Moving } from './elements';
2021

2122
// Okay, this looks veeeery strange, we need this because Webpack has a bug currently
@@ -403,11 +404,17 @@ export default class App extends React.PureComponent<
403404
return (
404405
<Fullscreen sidebarOpen={this.state.sidebarOpen}>
405406
{sandbox && (
406-
<Sidebar
407-
setCurrentModule={this.setCurrentModule}
408-
currentModule={this.getCurrentModuleFromPath(sandbox).id}
409-
sandbox={sandbox}
410-
/>
407+
<>
408+
<Sidebar
409+
setCurrentModule={this.setCurrentModule}
410+
currentModule={this.getCurrentModuleFromPath(sandbox).id}
411+
sandbox={sandbox}
412+
/>
413+
<EditorLink
414+
sandbox={sandbox}
415+
previewVisible={this.state.showPreview}
416+
/>
417+
</>
411418
)}
412419
<Moving sidebarOpen={this.state.sidebarOpen}>{this.content()}</Moving>
413420
</Fullscreen>

packages/app/src/embed/components/Content/elements.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import styled from 'styled-components';
33
export const Container = styled.div`
44
display: flex;
55
position: relative;
6-
background-color: ${props => props.theme.background2};
7-
height: calc(100% - 2.5rem);
6+
background-color: ${props => props.theme['editor.background']};
7+
/* compatibility mode for the redesign, the header is smaller now*/
8+
height: calc(100% - 32px);
89
`;
910

1011
export const Tabs = styled.div`
1112
display: flex;
1213
height: 35px;
1314
min-height: 35px;
14-
background-color: rgba(0, 0, 0, 0.3);
15+
background-color: ${props => props.theme['tab.inactiveBackground']};
16+
/* shadow instead of border to align with the border of the child tab */
17+
box-shadow: inset 0px -1px 0 ${props => props.theme['sideBar.border']};
1518
overflow-x: auto;
1619
font-size: 0.875rem;
1720
@@ -21,6 +24,13 @@ export const Tabs = styled.div`
2124
&::-webkit-scrollbar {
2225
height: 2px; // Safari and Chrome
2326
}
27+
28+
/* override children, bad but vscode doesnt support
29+
tab.hoverForeground :shrug:
30+
*/
31+
> div:hover > div {
32+
color: white !important;
33+
}
2434
`;
2535

2636
export const Split = styled.div<{
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
// @flow
2-
import styled, { css } from 'styled-components';
1+
import styled from 'styled-components';
2+
import css from '@styled-system/css';
33

4-
export const Text = styled.span`
5-
color: white;
6-
${({ small }) =>
7-
small &&
8-
css`
9-
@media (max-width: 620px) {
10-
display: none;
11-
}
12-
`};
13-
`;
4+
export const Button = styled.a(props =>
5+
css({
6+
position: 'absolute',
7+
bottom: props.previewVisible ? 32 + 16 : 16,
8+
right: 16,
9+
zIndex: 99,
1410

15-
export const EditText = styled.a`
16-
text-decoration: none;
17-
display: flex;
18-
align-items: center;
19-
color: white;
11+
fontSize: 3,
12+
lineHeight: '32px',
13+
fontWeight: 'medium',
14+
border: '1px solid',
15+
borderColor: 'grays.500',
16+
color: 'white',
17+
backgroundColor: 'grays.700',
18+
borderRadius: 4,
19+
paddingX: 3,
20+
textDecoration: 'none',
2021

21-
svg {
22-
margin-left: 0.5rem;
23-
}
24-
`;
22+
':hover': {
23+
backgroundColor: 'grays.500',
24+
},
25+
})
26+
);

packages/app/src/embed/components/EditorLink/index.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
// @flow
2-
31
import React from 'react';
4-
import type { Sandbox } from '@codesandbox/common/lib/types';
5-
6-
import Logo from '@codesandbox/common/lib/components/Logo';
7-
82
import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator';
93

10-
import { Text, EditText } from './elements';
4+
import { Button } from './elements';
115

12-
function EditorLink({ sandbox, small }: { sandbox: Sandbox, small?: boolean }) {
6+
function EditorLink({ sandbox, previewVisible }) {
137
return (
14-
<EditText
15-
small={small}
8+
<Button
9+
id="openinsandbox"
1610
target="_blank"
1711
rel="noopener noreferrer"
1812
href={`${sandboxUrl(sandbox)}?from-embed`}
13+
previewVisible={previewVisible}
1914
>
20-
<Text small={small}>Open In CodeSandbox</Text>
21-
<Logo />
22-
</EditText>
15+
Open Sandbox
16+
</Button>
2317
);
2418
}
2519

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,30 @@
1-
// @flow
2-
import styled, { css } from 'styled-components';
3-
import MenuIconSVG from 'react-icons/lib/md/menu';
4-
import { Button as RealButton } from '@codesandbox/common/lib/components/Button';
1+
import styled from 'styled-components';
2+
import css from '@styled-system/css';
3+
4+
import {
5+
MenuIconSVG,
6+
HeartIconSVG,
7+
LinkIconSVG,
8+
PreviewViewIconSVG,
9+
EditorViewIconSVG,
10+
SplitViewIconSVG,
11+
} from './icons';
512

613
import { SIDEBAR_SHOW_SCREEN_SIZE } from '../../util/constants';
714

8-
export const CodeSandboxButton = styled(RealButton)`
9-
display: flex;
10-
justify-content: center;
11-
align-items: center;
12-
width: 147px;
13-
padding: 0.4em 0.7em;
14-
15-
@media (max-width: 510px) {
16-
padding: 0.2em;
17-
background-color: transparent;
18-
border-color: transparent;
19-
20-
width: auto;
21-
font-size: 1.4rem;
22-
}
23-
`;
24-
2515
export const Container = styled.div`
2616
position: relative;
2717
display: flex;
2818
flex-direction: row;
2919
align-items: center;
30-
height: 3rem;
20+
3121
padding: 0 1rem;
3222
box-sizing: border-box;
33-
border-bottom: 1px solid ${props => props.theme.background.darken(0.3)};
34-
background-color: ${props => props.theme.background};
35-
`;
23+
background-color: ${props => props.theme['editor.background']};
3624
37-
export const MenuIcon = styled(MenuIconSVG)`
38-
font-size: 2rem;
39-
color: rgba(255, 255, 255, 0.7);
40-
margin-right: 1rem;
41-
cursor: pointer;
42-
z-index: 10;
25+
/* compatibility mode for the redesign */
26+
height: calc(32px + 1px);
27+
border-bottom: 1px solid ${props => props.theme['sideBar.border']};
4328
`;
4429

4530
export const LeftAligned = styled.div`
@@ -82,6 +67,13 @@ export const Title = styled.div`
8267
overflow: hidden;
8368
flex: 1;
8469
70+
/* compatibility mode for the redesign */
71+
font-size: 13px;
72+
73+
@media (min-width: ${SIDEBAR_SHOW_SCREEN_SIZE}px) {
74+
display: none;
75+
}
76+
8577
@media (max-width: 450px) {
8678
display: none;
8779
}
@@ -94,51 +86,60 @@ export const OnlyShowWideText = styled.span`
9486
}
9587
`;
9688

97-
export const Button = styled.button`
98-
display: flex;
99-
align-items: center;
100-
font-family: Roboto;
101-
transition: 0.3s ease all;
102-
background-color: transparent;
103-
border: transparent;
104-
font-size: 0.875rem;
105-
font-weight: 500;
106-
107-
color: ${props => props.color || 'rgb(64, 169, 243)'};
108-
border-radius: 4px;
109-
margin-right: 0.75rem;
110-
padding: 0.4rem 0.4rem;
111-
text-decoration: none;
112-
cursor: pointer;
113-
114-
svg {
115-
margin-right: 0.1rem;
116-
}
117-
118-
&:hover {
119-
background-color: ${props => props.color || 'rgb(64, 169, 243)'};
120-
color: ${props =>
121-
props.invertedHover ? props.theme.background2 : 'white'};
122-
}
123-
124-
${props =>
125-
props.hideSmall &&
126-
css`
127-
@media (max-width: ${props.hideSmall}px) {
128-
display: none;
129-
}
130-
`};
131-
132-
@media (max-width: 486px) {
133-
height: 100%;
134-
border: 0;
135-
margin-right: -1rem;
136-
&:last-child {
137-
margin-right: -1rem;
138-
}
139-
padding: 0 1rem;
140-
border-radius: 0;
141-
font-size: 1.5rem;
142-
background-color: transparent;
143-
}
144-
`;
89+
export const Button = styled.button(
90+
css({
91+
// reset button properties
92+
background: 'transparent',
93+
border: 'none',
94+
95+
color: 'grays.400',
96+
97+
height: '100%',
98+
display: 'flex',
99+
alignItems: 'center',
100+
101+
paddingX: 2,
102+
cursor: 'pointer',
103+
104+
'&:hover': {
105+
svg: {
106+
color: 'white',
107+
},
108+
},
109+
})
110+
);
111+
112+
export const MenuIcon = styled(MenuIconSVG)(
113+
css({
114+
color: 'grays.400',
115+
marginRight: 2,
116+
cursor: 'pointer',
117+
zIndex: 10,
118+
})
119+
);
120+
121+
export const LinkIcon = styled(LinkIconSVG)(css({}));
122+
123+
export const HeartIcon = styled(HeartIconSVG)(props =>
124+
css({
125+
color: props.liked ? 'reds.300' : 'grays.400',
126+
})
127+
);
128+
129+
const ModeStyleStyles = props =>
130+
css({
131+
color: props.active ? 'white' : 'grays.400',
132+
borderRadius: 2,
133+
cursor: 'pointer',
134+
marginX: 1,
135+
':hover': {
136+
color: 'white',
137+
},
138+
path: {
139+
transition: theme => 'fill ' + theme.speed[2],
140+
},
141+
});
142+
143+
export const EditorViewIcon = styled(EditorViewIconSVG)(ModeStyleStyles);
144+
export const SplitViewIcon = styled(SplitViewIconSVG)(ModeStyleStyles);
145+
export const PreviewViewIcon = styled(PreviewViewIconSVG)(ModeStyleStyles);

0 commit comments

Comments
 (0)