Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d19db56
🔨 Add useScript Hook, Refactor Advertisement to use useScript
Saeris May 17, 2019
dba78f5
Correct Comment Link
Saeris May 17, 2019
22cd817
🔨 Add useScript Hook, Refactor Advertisement to use useScript
Saeris May 17, 2019
1c87bff
Merge remote-tracking branch 'origin/code-conventions-refactor' into …
Saeris May 17, 2019
d88957c
🔨 Add mobx-react-lite, Refactor ConnectionNotice to use hooks
Saeris May 17, 2019
a5966a5
Remove analytic for deleting
CompuIves May 18, 2019
3c0bf1a
Just added iOS Touch icons for the PWA (#1936)
twhite96 May 20, 2019
fac7134
[Dashboard] Keep sidebar open when search input is focused (#1937)
abdullahtariq1171 May 20, 2019
5d95e25
Refactor Cube to functional component with hooks (#1939)
MichaelDeBoey May 20, 2019
48c5d5d
Fix modules that declare a global variable
CompuIves May 21, 2019
101f04b
Remove performance statement
CompuIves May 21, 2019
49c8a09
🔨 Add useScript Hook, Refactor Advertisement to use useScript
Saeris May 17, 2019
a4523a0
Correct Comment Link
Saeris May 17, 2019
37edbc4
🔨 Add mobx-react-lite, Refactor ConnectionNotice to use hooks
Saeris May 17, 2019
519b214
🔨 Add useInterval Hook, Refactor Live, SSEDownNotice
Saeris May 21, 2019
a304dac
Merge remote-tracking branch 'origin/code-conventions-refactor' into …
Saeris May 21, 2019
e05aa29
Auto stash before merge of "code-conventions-refactor" and "origin/co…
Saeris May 21, 2019
1212065
🔨 Refactor GitHub Workspace to use hooks
Saeris May 21, 2019
4ca14c6
Update packages/app/src/app/pages/Dashboard/index.js
Saeris May 21, 2019
9afad2b
🔨 Refactor Deployment Workspace to use hooks
Saeris May 22, 2019
fca1605
🔨 Refactor More Workspace to use hooks
Saeris May 22, 2019
2c0a836
🔨 Apply coding conventions to NotOwnedSandboxInfo Workspace
Saeris May 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,15 @@
"contributions": [
"code"
]
},
{
"login": "twhite96",
"name": "Tiffany White",
"avatar_url": "https://avatars0.githubusercontent.com/u/7698292?v=4",
"profile": "https://tiffanywhite.dev",
"contributions": [
"code"
]
}
],
"repoType": "github",
Expand Down
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"__DEV__": true
},
"rules": {
"linebreak-style": 0,
"react/jsx-filename-extension": 0,
"react/sort-comp": 0,
"import/no-extraneous-dependencies": 0,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [CodeSandbox](https://codesandbox.io) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/codesandbox) [![All Contributors](https://img.shields.io/badge/all_contributors-127-orange.svg?style=flat-square)](#contributors) [![CircleCI](https://circleci.com/gh/codesandbox/codesandbox-client.svg?style=svg)](https://circleci.com/gh/codesandbox/codesandbox-client) [![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf)](https://www.browserstack.com/automate/public-build/cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![first-timers-only Friendly](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)
# [CodeSandbox](https://codesandbox.io) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/codesandbox) [![All Contributors](https://img.shields.io/badge/all_contributors-128-orange.svg?style=flat-square)](#contributors) [![CircleCI](https://circleci.com/gh/codesandbox/codesandbox-client.svg?style=svg)](https://circleci.com/gh/codesandbox/codesandbox-client) [![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf)](https://www.browserstack.com/automate/public-build/cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![first-timers-only Friendly](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)

[![Backers on Open Collective](https://opencollective.com/codesandbox/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/codesandbox/sponsors/badge.svg)](#sponsors)

Expand Down Expand Up @@ -60,7 +60,7 @@ Thanks goes to these wonderful people
| [<img src="https://avatars2.githubusercontent.com/u/8518239?v=4" width="100px;"/><br /><sub><b>The Gitter Badger</b></sub>](https://gitter.im)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=gitter-badger "Code") | [<img src="https://avatars2.githubusercontent.com/u/762471?v=4" width="100px;"/><br /><sub><b>Tim Whitbeck</b></sub>](https://github.com/twhitbeck)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=twhitbeck "Code") | [<img src="https://avatars0.githubusercontent.com/u/465125?v=4" width="100px;"/><br /><sub><b>Wei Zhu</b></sub>](http://twitter.com/yesmeck)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=yesmeck "Code") | [<img src="https://avatars2.githubusercontent.com/u/5005153?v=4" width="100px;"/><br /><sub><b>Wil Wilsman</b></sub>](http://wilwilsman.com)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=wwilsman "Code") | [<img src="https://avatars1.githubusercontent.com/u/7959329?v=4" width="100px;"/><br /><sub><b>abnessor aka findoff</b></sub>](https://codepen.io/findoff/)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=findoff "Code") | [<img src="https://avatars1.githubusercontent.com/u/11937539?v=4" width="100px;"/><br /><sub><b>cottom</b></sub>](http://jerry-i.github.io)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=jerry-i "Code") | [<img src="https://avatars3.githubusercontent.com/u/7143133?v=4" width="100px;"/><br /><sub><b>gitname</b></sub>](https://github.com/gitname)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=gitname "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/15030806?v=4" width="100px;"/><br /><sub><b>Bruce Xu</b></sub>](http://www.xulingming.cn)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=jackdon "Code") | [<img src="https://avatars3.githubusercontent.com/u/7316730?v=4" width="100px;"/><br /><sub><b>jess</b></sub>](http://jessachandler.com)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=monkeywithacupcake "Code") | [<img src="https://avatars0.githubusercontent.com/u/8875406?v=4" width="100px;"/><br /><sub><b>Juliette Prétot</b></sub>](https://juliette.sh)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=juliettepretot "Code") | [<img src="https://avatars0.githubusercontent.com/u/25737281?v=4" width="100px;"/><br /><sub><b>Victoria Bergquist</b></sub>](https://twitter.com/vicbergquist)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=vicbergquist "Code") [📖](https://github.com/codesandbox/codesandbox-client/commits?author=vicbergquist "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/9032162?v=4" width="100px;"/><br /><sub><b>Samrith Shankar</b></sub>](https://github.com/samrith-s)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=samrith-s "Code") | [<img src="https://avatars3.githubusercontent.com/u/827497?v=4" width="100px;"/><br /><sub><b>Mahendra Hirapra</b></sub>](https://github.com/tinahir)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=tinahir "Code") | [<img src="https://avatars3.githubusercontent.com/u/17409675?v=4" width="100px;"/><br /><sub><b>Rabin Gaire</b></sub>](http://rabingaire.com.np)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=rabingaire "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/8527474?v=4" width="100px;"/><br /><sub><b>Neville Mehta</b></sub>](https://twitter.com/ask_neville)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=nm123github "Code") | [<img src="https://avatars0.githubusercontent.com/u/1813468?v=4" width="100px;"/><br /><sub><b>Vasiliy</b></sub>](https://github.com/Yeti-or)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=Yeti-or "Code") | [<img src="https://avatars3.githubusercontent.com/u/2793951?v=4" width="100px;"/><br /><sub><b>Romain Lanz</b></sub>](https://slynova.io)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=RomainLanz "Code") | [<img src="https://avatars2.githubusercontent.com/u/1233790?v=4" width="100px;"/><br /><sub><b>LiBe</b></sub>](http://libe.toile-libre.org)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=libetl "Code") | [<img src="https://avatars0.githubusercontent.com/u/5333019?v=4" width="100px;"/><br /><sub><b>Jeremy Bolding</b></sub>](http://thecodechef.github.io)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=thecodechef "Code") | [<img src="https://avatars1.githubusercontent.com/u/9664363?v=4" width="100px;"/><br /><sub><b>Evan Bacon</b></sub>](https://twitter.com/baconbrix)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=EvanBacon "Code") | [<img src="https://avatars3.githubusercontent.com/u/6643991?v=4" width="100px;"/><br /><sub><b>Michaël De Boey</b></sub>](https://michaeldeboey.be)<br />[🐛](https://github.com/codesandbox/codesandbox-client/issues?q=author%3AMichaelDeBoey "Bug reports") [💻](https://github.com/codesandbox/codesandbox-client/commits?author=MichaelDeBoey "Code") [📖](https://github.com/codesandbox/codesandbox-client/commits?author=MichaelDeBoey "Documentation") [🚇](#infra-MichaelDeBoey "Infrastructure (Hosting, Build-Tools, etc)") [🔧](#tool-MichaelDeBoey "Tools") |
| [<img src="https://avatars1.githubusercontent.com/u/14077091?v=4" width="100px;"/><br /><sub><b>gabeeden</b></sub>](https://github.com/gabeeden)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=gabeeden "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/14077091?v=4" width="100px;"/><br /><sub><b>gabeeden</b></sub>](https://github.com/gabeeden)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=gabeeden "Code") | [<img src="https://avatars0.githubusercontent.com/u/7698292?v=4" width="100px;"/><br /><sub><b>Tiffany White</b></sub>](https://tiffanywhite.dev)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=twhite96 "Code") |

<!-- ALL-CONTRIBUTORS-LIST:END -->

Expand Down
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
"memoize-one": "^4.0.0",
"mobx": "^4.0.0",
"mobx-react": "^5.2.3",
"mobx-react-lite": "^1.3.2",
"mobx-state-tree": "^3.3.0",
"moment": "^2.18.1",
"monaco-editor-textmate": "^2.0.0",
Expand Down
Binary file added packages/app/public/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/app/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
"src": "codesandbox-1024.png",
"type": "image/png",
"sizes": "1024x1024"
},
{
"src": "apple-touch-icon",
"type": "image/png",
"sizes": "57x57"
},
{
"src": "apple-touch-icon-152x152",
"type": "image/png",
"sizes": "152x152"
},
{
"src": "apple-touch-icon-180x180.png",
"type": "image/png",
"sizes": "180x180"
}
],
"description": "An online editor tailored for web applications",
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/app/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { useInterval } from './useInterval';
export { useScript } from './useScript';
21 changes: 21 additions & 0 deletions packages/app/src/app/hooks/useInterval.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Based on https://overreacted.io/making-setinterval-declarative-with-react-hooks/
import { useEffect, useRef } from 'react';

export const useInterval = (callback = () => {}, delay: number) => {
const savedCallback: { current: any } = useRef();

useEffect(() => {
savedCallback.current = callback;
}, [callback]);

useEffect(() => {
function tick() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be an arrow function

const tick = () => savedCallback.current();

savedCallback.current();
}
if (delay !== null) {
const id = setInterval(tick, delay);
return () => clearInterval(id);
}
return undefined;
}, [delay]);
};
60 changes: 60 additions & 0 deletions packages/app/src/app/hooks/useScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Based on https://usehooks.com/useScript/
import { useState, useEffect } from 'react';

const cachedScripts = [];

export const useScript = (src: string) => {
const [state, setState] = useState({
loaded: false,
error: false,
});

useEffect(() => {
if (cachedScripts.includes(src)) {
setState({
loaded: true,
error: false,
});
} else {
cachedScripts.push(src);

const script = document.createElement('script');
script.src = src;
script.async = true;

const onScriptLoad = () => {
setState({
loaded: true,
error: false,
});
};

const onScriptError = () => {
const index = cachedScripts.indexOf(src);

if (index >= 0) cachedScripts.splice(index, 1);

script.remove();

setState({
loaded: true,
error: true,
});
};

script.addEventListener('load', onScriptLoad);
script.addEventListener('error', onScriptError);

document.body.appendChild(script);

return () => {
script.removeEventListener('load', onScriptLoad);
script.removeEventListener('error', onScriptError);
};
}

return undefined;
}, [src]);

return [state.loaded, state.error];
};
25 changes: 15 additions & 10 deletions packages/app/src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
logError,
} from '@codesandbox/common/lib/utils/analytics';
import '@codesandbox/common/lib/global.css';

import { Signals, Store } from 'app/store';
import history from 'app/utils/history';
import { client } from 'app/graphql/client';
import registerServiceWorker from '@codesandbox/common/lib/registerServiceWorker';
Expand Down Expand Up @@ -119,16 +119,21 @@ function boot() {
});

try {
const { signals, store } = controller.provide();
render(
<Provider {...controller.provide()}>
<ApolloProvider client={client}>
<ThemeProvider theme={theme}>
<Router history={history}>
<App />
</Router>
</ThemeProvider>
</ApolloProvider>
</Provider>,
<Signals.Provider value={signals}>
<Store.Provider value={store}>
<Provider {...{ signals, store }}>
<ApolloProvider client={client}>
<ThemeProvider theme={theme}>
<Router history={history}>
<App />
</Router>
</ThemeProvider>
</ApolloProvider>
</Provider>
</Store.Provider>
</Signals.Provider>,
rootEl
);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/app/pages/Dashboard/Sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { TEAMS_QUERY } from '../queries';

class Sidebar extends React.Component {
handleSearchFocus = () => {
history.push('/dashboard/search');
history.push('/dashboard/search', { from: 'sandboxSearchFocused' });
};

handleSearchChange = e => {
Expand Down
6 changes: 5 additions & 1 deletion packages/app/src/app/pages/Dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class Dashboard extends React.Component {
} = this.props;
const { showSidebar } = this.state;

history.listen(() => {
history.listen(({ state }) => {
if (Boolean(state) && state.from === 'sandboxSearchFocused') {
return;
}

this.onRouteChange();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { useScript } from 'app/hooks';
import { Container } from './elements';

export const Advertisement = () => {
useScript(`https://codefund.app/properties/24/funder.js`);

return (
<Container>
<div id="codefund" />
</Container>
);
};

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled, { css } from 'styled-components';

export const Container = styled.div`
${({ theme }) => css`
color: ${theme.light
? css`rgba(0, 0, 0, 0.8)`
: css`rgba(255, 255, 255, 0.8)`} !important;
`};
`;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Advertisement } from './Advertisement';
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import { inject, observer } from 'mobx-react';

import { observer } from 'mobx-react-lite';
import { useStore } from 'app/store';
import { Container } from './elements';

function ConnectionNotice({ store }) {
export const ConnectionNotice = observer(() => {
const { connected } = useStore();

return (
!store.connected && (
!connected && (
<Container>
You{"'"}re not connected to the internet. You can still edit, but you
cannot save. We recommend using the {"'"}Download{"'"} function to keep
your changes.
</Container>
)
);
}

export default inject('store')(observer(ConnectionNotice));
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled, { css } from 'styled-components';

export const Container = styled.div`
${({ theme }) => css`
color: ${theme.red};
background-color: ${theme.redBackground};
padding: 1rem;
font-size: 0.75rem;
`}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ConnectionNotice } from './ConnectionNotice';

This file was deleted.

Loading