Skip to content

Commit a380e33

Browse files
authored
add zeit warning (codesandbox#2165)
* add zeit warning * add link to docs * add warning back
1 parent d1d845c commit a380e33

File tree

7 files changed

+59
-4
lines changed

7 files changed

+59
-4
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Zeit/DeployButton/DeployButton.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,30 @@ import React from 'react';
22

33
import { DeploymentIntegration } from 'app/components/DeploymentIntegration';
44
import NowLogo from 'app/components/NowLogo';
5-
import { useSignals } from 'app/store';
5+
import { useSignals, useStore } from 'app/store';
66

77
import { DeployButtonContainer } from '../../elements';
88

9+
import { Overlay, CreateFile } from './elements';
10+
911
export const DeployButton = ({ isOpen, toggle }) => {
1012
const {
13+
files,
1114
deployment: { deploySandboxClicked },
1215
} = useSignals();
16+
const { editor } = useStore();
17+
const nowFile = editor.currentSandbox.modules
18+
.toJSON()
19+
.filter(file => file.title === 'now.json');
20+
21+
const createFile = () => {
22+
files.moduleCreated({
23+
title: 'now.json',
24+
code: JSON.stringify({
25+
version: 2,
26+
}),
27+
});
28+
};
1329

1430
return (
1531
<DeployButtonContainer>
@@ -21,6 +37,29 @@ export const DeployButton = ({ isOpen, toggle }) => {
2137
open={isOpen}
2238
toggle={toggle}
2339
>
40+
{!nowFile.length && (
41+
<Overlay>
42+
It seems you don{"'"}t have{' '}
43+
<a
44+
href="https://zeit.co/docs/v2/deployments/configuration"
45+
target="_blank"
46+
rel="noreferrer noopener"
47+
>
48+
now.json
49+
</a>{' '}
50+
file. Please create{' '}
51+
<CreateFile onClick={createFile}>one</CreateFile> to be able to
52+
deploy to{' '}
53+
<a
54+
href="https://zeit.co/now"
55+
target="_blank"
56+
rel="noreferrer noopener"
57+
>
58+
<span>ZEIT Now</span>
59+
</a>
60+
.
61+
</Overlay>
62+
)}
2463
Deploy your sandbox on{' '}
2564
<a href="https://zeit.co/now" rel="noreferrer noopener" target="_blank">
2665
<span>ZEIT Now</span>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import styled from 'styled-components';
2+
3+
export const Overlay = styled.div`
4+
position: absolute;
5+
background: rgba(0, 0, 0, 1);
6+
max-width: 80%;
7+
`;
8+
9+
export const CreateFile = styled.button`
10+
padding: 0;
11+
margin: 0;
12+
background: transparent;
13+
color: ${props => props.theme.link};
14+
border: none;
15+
`;

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Zeit/Zeit.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const Zeit = observer(() => {
1717
} = useStore();
1818

1919
const [isVisible, setVisible] = useState(false);
20-
2120
return integrations.zeit ? (
2221
<Wrapper loading={deploying}>
2322
<DeployButton

packages/common/src/__snapshots__/theme.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Object {
1717
"gray": [Function],
1818
"green": [Function],
1919
"lightText": [Function],
20+
"link": [Function],
2021
"new": Object {
2122
"bg": [Function],
2223
"description": [Function],

packages/common/src/theme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const theme = {
8080
dangerBackground: '#DC3545',
8181
sidebar: '#191d1f',
8282
placeholder: '#B8B9BA',
83+
link: '#40a9f3',
8384
}),
8485
vscodeTheme: codesandbox,
8586

packages/dynamic-pages/pages/user-sandboxes/_elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const NavigationLink = styled.a`
2727
content: '';
2828
margin-top: 8px;
2929
display: block;
30-
background: #40a9f3;
30+
background: ${props => props.theme.link};
3131
height: 2px;
3232
box-sizing: border-box;
3333
width: 0%;

packages/homepage/src/pages/legal/_elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const NavigationLink = styled(Link)`
3030
content: '';
3131
margin-top: 8px;
3232
display: block;
33-
background: #40a9f3;
33+
background: ${props => props.theme.link};
3434
height: 2px;
3535
box-sizing: border-box;
3636
width: 0%;

0 commit comments

Comments
 (0)