Skip to content

Commit fe3131e

Browse files
authored
Merge branch 'master' into components-button
2 parents 45d1830 + 3da3a36 commit fe3131e

File tree

17 files changed

+639
-2463
lines changed

17 files changed

+639
-2463
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,15 @@
15031503
"contributions": [
15041504
"doc"
15051505
]
1506+
},
1507+
{
1508+
"login": "soorajshankar",
1509+
"name": "soorajshankar",
1510+
"avatar_url": "https://avatars2.githubusercontent.com/u/8408875?v=4",
1511+
"profile": "https://github.com/soorajshankar",
1512+
"contributions": [
1513+
"code"
1514+
]
15061515
}
15071516
],
15081517
"contributorsPerLine": 7,

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ commands:
197197
$BROWSER_STACK_KEY || true'
198198
background: true
199199
- run:
200-
command: npm run chromatic --exit-zero-on-changes
200+
command: yarn chromatic
201201
- run:
202202
name: Test Integrations
203203
command: |

README.md

Lines changed: 205 additions & 204 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,10 @@ export const toggleEditorPreviewLayout: Action = ({ state, effects }) => {
571571
effects.vscode.resetLayout();
572572
};
573573

574-
export const previewActionReceived: Action<{
575-
action: any;
576-
}> = ({ state, effects, actions }, { action }) => {
574+
export const previewActionReceived: Action<any> = (
575+
{ actions, effects, state },
576+
action
577+
) => {
577578
switch (action.action) {
578579
case 'notification':
579580
effects.notificationToast.add({

packages/app/src/app/pages/Sandbox/Editor/Content/Preview/index.tsx

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,55 @@
1+
import { ServerContainerStatus } from '@codesandbox/common/lib/types';
12
import BasePreview from '@codesandbox/common/lib/components/Preview';
23
import RunOnClick from '@codesandbox/common/lib/components/RunOnClick';
4+
import React, { FunctionComponent, useState } from 'react';
5+
36
import { useOvermind } from 'app/overmind';
4-
// @flow
5-
import React, { FC, useState } from 'react';
67

78
type Props = {
89
hidden?: boolean;
10+
options: {
11+
url?: string;
12+
};
913
runOnClick?: boolean;
10-
options: { url?: string };
1114
};
12-
13-
const PreviewComponent: FC<Props> = props => {
14-
const { state, actions, effects } = useOvermind();
15-
const [running, setRunning] = useState(!props.runOnClick);
15+
export const Preview: FunctionComponent<Props> = ({
16+
hidden,
17+
options,
18+
runOnClick,
19+
}) => {
20+
const {
21+
actions: {
22+
editor: { errorsCleared, previewActionReceived, projectViewToggled },
23+
},
24+
effects: {
25+
preview: { initializePreview },
26+
},
27+
state: {
28+
editor: {
29+
currentModule,
30+
currentSandbox,
31+
initialPath,
32+
isInProjectView,
33+
isResizing,
34+
previewWindowVisible,
35+
},
36+
preferences: { settings },
37+
server: { containerStatus, error, hasUnrecoverableError },
38+
},
39+
} = useOvermind();
40+
const [running, setRunning] = useState(!runOnClick);
1641

1742
/**
1843
* Responsible for showing a message when something is happening with SSE. Only used
1944
* for server sandboxes right now, but we can extend it in the future. It would require
2045
* a better design if we want to use it for more though.
2146
*/
22-
function getOverlayMessage() {
23-
const { containerStatus, error, hasUnrecoverableError } = state.server;
24-
25-
if (containerStatus === 'hibernated') {
47+
const getOverlayMessage = () => {
48+
if (containerStatus === ServerContainerStatus.HIBERNATED) {
2649
return 'The container has been hibernated because of inactivity, you can start it by refreshing the browser.';
2750
}
2851

29-
if (containerStatus === 'stopped') {
52+
if (containerStatus === ServerContainerStatus.STOPPED) {
3053
return 'Restarting the sandbox...';
3154
}
3255

@@ -35,37 +58,28 @@ const PreviewComponent: FC<Props> = props => {
3558
}
3659

3760
return undefined;
38-
}
39-
40-
const { options } = props;
41-
42-
const completelyHidden = !state.editor.previewWindowVisible;
61+
};
4362

4463
return running ? (
4564
<BasePreview
46-
onMount={effects.preview.initializePreview}
47-
sandbox={state.editor.currentSandbox}
48-
privacy={state.editor.currentSandbox.privacy}
49-
previewSecret={state.editor.currentSandbox.previewSecret}
50-
currentModule={state.editor.currentModule}
51-
settings={state.preferences.settings}
52-
initialPath={state.editor.initialPath}
53-
url={options.url}
54-
isInProjectView={state.editor.isInProjectView}
55-
onClearErrors={() => actions.editor.errorsCleared()}
56-
onAction={action => actions.editor.previewActionReceived({ action })}
57-
hide={props.hidden}
58-
noPreview={completelyHidden}
59-
onToggleProjectView={() => actions.editor.projectViewToggled()}
60-
isResizing={state.editor.isResizing}
65+
currentModule={currentModule}
66+
hide={hidden}
67+
initialPath={initialPath}
68+
isInProjectView={isInProjectView}
69+
isResizing={isResizing}
70+
onAction={action => previewActionReceived(action)}
71+
onClearErrors={() => errorsCleared()}
72+
onMount={initializePreview}
73+
noPreview={!previewWindowVisible}
74+
onToggleProjectView={() => projectViewToggled()}
6175
overlayMessage={getOverlayMessage()}
76+
previewSecret={currentSandbox.previewSecret}
77+
privacy={currentSandbox.privacy}
78+
sandbox={currentSandbox}
79+
settings={settings}
80+
url={options.url}
6281
/>
6382
) : (
64-
<RunOnClick
65-
onClick={() => {
66-
setRunning(true);
67-
}}
68-
/>
83+
<RunOnClick onClick={() => setRunning(true)} />
6984
);
7085
};
71-
export const Preview = PreviewComponent;

packages/common/src/design-language/theme.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ const theme = {
77
fontWeights,
88

99
// we use a 4 point grid
10+
// 0 - 0
11+
// 1 - 4
12+
// 2 - 8
13+
// 3 - 12
14+
// 4 - 16
15+
// 5 - 24
16+
// 6 - 28
17+
// 7 - 32
18+
// 8 - 36
19+
// 9 - 40
1020
space: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40],
1121
sizes: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40],
1222

0 commit comments

Comments
 (0)