Skip to content

Commit c434dc4

Browse files
author
Ives van Hoorne
committed
Massive refactor
1 parent fe90c1e commit c434dc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1760
-1067
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/cra-files/*.*

First_Concept.sketch

-240 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"html-loader": "^0.4.4",
4545
"html-webpack-plugin": "^2.24.1",
4646
"http-proxy-middleware": "^0.17.3",
47-
"jest": "^19.0.2",
47+
"jest": "21",
4848
"json-loader": "0.5.4",
4949
"object-assign": "^4.1.1",
5050
"opn": "4.0.2",
@@ -123,7 +123,7 @@
123123
"build": "NODE_ENV=production node scripts/build.js && gulp",
124124
"test": "jest --env=jsdom",
125125
"test:watch": "jest --watch --env=jsdom",
126-
"lint:app": "eslint src/app",
126+
"lint:app": "eslint src/app && flow-bin",
127127
"lint:embed": "eslint src/embed"
128128
},
129129
"jest": {

src/app/components/buttons/Button.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Link } from 'react-router-dom';
3-
import styled, { keyframes } from 'styled-components';
3+
import styled, { css, keyframes } from 'styled-components';
44

55
import theme from 'common/theme';
66

@@ -24,41 +24,40 @@ const backward = keyframes`
2424
100%{background-position:0% 50%}
2525
`;
2626

27-
const styles = props =>
28-
`
27+
const styles = css`
2928
transition: 0.3s ease all;
3029
animation-name: ${backward};
3130
animation-duration: 300ms;
3231
animation-timing-function: ease;
3332
3433
border: none;
3534
outline: none;
36-
${getBackgroundColor(props)};
35+
${props => getBackgroundColor(props)};
3736
background-size: 720%;
3837
3938
border-radius: 4px;
4039
4140
font-size: 1.125rem;
4241
text-align: center;
43-
color: ${getColor(props)};
42+
color: ${props => getColor(props)};
4443
font-weight: 300;
45-
${!props.disabled && `box-shadow: 0 3px 3px rgba(0, 0, 0, 0.5);`};
46-
width: ${props.block ? '100%' : 'inherit'};
44+
${props => !props.disabled && `box-shadow: 0 3px 3px rgba(0, 0, 0, 0.5);`};
45+
width: ${props => (props.block ? '100%' : 'inherit')};
4746
48-
${(() => {
47+
${props => () => {
4948
if (props.small) {
5049
return `
5150
padding: 0.5rem 0.75rem;
5251
font-size: 0.875rem;
5352
`;
5453
}
5554
return 'padding: 0.65rem 2.25rem;';
56-
})()}
55+
}}
5756
5857
user-select: none;
5958
text-decoration: none;
6059
61-
${!props.disabled && `
60+
${props => !props.disabled && `
6261
cursor: pointer;
6362
&:hover {
6463
animation-name: ${forward};

src/app/components/buttons/Button.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ describe('Button', () => {
1212
testRender(<Button onClick={() => {}}>Test</Button>);
1313
});
1414

15-
it('renders hrefs', () => {
15+
it('renders to', () => {
1616
testRender(
1717
<MemoryRouter>
1818
<Button to="https://ivesvh.com">Test</Button>
1919
</MemoryRouter>,
2020
);
2121
});
2222

23+
it('renders href', () => {
24+
testRender(<Button href="https://ivesvh.com">Test</Button>);
25+
});
26+
2327
it('renders properties', () => {
2428
testRender(<Button small>Test</Button>);
2529
});

src/app/components/buttons/__snapshots__/Button.test.js.snap

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@ exports[`Button renders 1`] = `
1010

1111
exports[`Button renders disabled 1`] = `
1212
<button
13-
className="iMdJJE"
13+
className="kzKEne"
1414
disabled={true}
1515
>
1616
Test
1717
</button>
1818
`;
1919

20-
exports[`Button renders hrefs 1`] = `
20+
exports[`Button renders href 1`] = `
2121
<a
2222
className="gdCKHU"
2323
href="https://ivesvh.com"
24-
onClick={[Function]}
2524
>
2625
Test
2726
</a>
@@ -43,3 +42,13 @@ exports[`Button renders properties 1`] = `
4342
Test
4443
</button>
4544
`;
45+
46+
exports[`Button renders to 1`] = `
47+
<a
48+
className="gdCKHU"
49+
href="https://ivesvh.com"
50+
onClick={[Function]}
51+
>
52+
Test
53+
</a>
54+
`;

src/app/pages/Sandbox/Editor/Content/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ class EditorPreview extends React.PureComponent {
129129
} = this.props;
130130

131131
const mainModule = modules.find(isMainModule);
132+
if (!mainModule) throw new Error('Cannot find main module');
133+
132134
const { currentModule: currentModuleId } = sandbox;
133135
const currentModule =
134136
modules.find(m => m.id === currentModuleId) || mainModule;
@@ -166,7 +168,7 @@ class EditorPreview extends React.PureComponent {
166168
addError={sandboxActions.addError}
167169
errors={sandbox.errors}
168170
clearErrors={sandboxActions.clearErrors}
169-
isInProjectView={sandbox.isInProjectView}
171+
isInProjectView={sandbox.isInProjectView || true}
170172
externalResources={sandbox.externalResources}
171173
setProjectView={sandboxActions.setProjectView}
172174
preferences={preferences}

src/app/pages/Sandbox/Editor/Workspace/Project/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const ViewCountContainer = styled.div`
3131

3232
type Props = {
3333
id: string,
34-
title: string,
34+
title: ?string,
3535
description: string,
3636
viewCount: number,
3737
likeCount: number,

src/app/pages/Sandbox/Editor/Workspace/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Props = {
3434
sandbox: Sandbox,
3535
sandboxActions: typeof sandboxActionCreators,
3636
preventTransition: boolean,
37-
users: { [key: id]: User },
37+
user: User,
3838
};
3939

4040
const mapDispatchToProps = dispatch => ({
@@ -43,11 +43,15 @@ const mapDispatchToProps = dispatch => ({
4343
const mapStateToProps = createSelector(
4444
modulesFromSandboxNotSavedSelector,
4545
usersSelector,
46-
(preventTransition, users) => ({ preventTransition, users }),
46+
(_, props) => props.sandbox && props.sandbox.author,
47+
(preventTransition, users, author) => ({
48+
preventTransition,
49+
user: users[author],
50+
}),
4751
);
4852
const Workspace = ({
4953
sandbox,
50-
users,
54+
user,
5155
preventTransition,
5256
sandboxActions,
5357
}: Props) => (
@@ -65,7 +69,7 @@ const Workspace = ({
6569
forkedSandbox={sandbox.forkedFromSandbox}
6670
preventTransition={preventTransition}
6771
owned={sandbox.owned}
68-
author={users[sandbox.author]}
72+
author={user}
6973
deleteSandbox={sandboxActions.deleteSandbox}
7074
/>
7175
</WorkspaceItem>

src/app/pages/Sandbox/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type { Sandbox } from 'common/types';
1010

1111
import { sandboxesSelector } from 'app/store/entities/sandboxes/selectors';
1212
import sandboxActionCreators from 'app/store/entities/sandboxes/actions';
13-
import { jwtSelector } from 'app/store/user/selectors';
1413

1514
import Title from 'app/components/text/Title';
1615
import Centered from 'app/components/flex/Centered';
@@ -21,7 +20,6 @@ type Props = {
2120
sandbox: ?Sandbox,
2221
sandboxes: { [id: string]: Sandbox },
2322
sandboxActions: typeof sandboxActionCreators,
24-
hasLogin: boolean,
2523
match: { params: { id: ?string } },
2624
};
2725
type State = {
@@ -37,11 +35,10 @@ const Container = styled.div`
3735
const mapStateToProps = createSelector(
3836
sandboxesSelector,
3937
(_, props) => props.match.params.id,
40-
jwtSelector,
41-
(sandboxes, id, jwt) => {
38+
(sandboxes, id) => {
4239
const sandbox = sandboxes[id];
4340

44-
return { sandbox, sandboxes, hasLogin: !!jwt };
41+
return { sandbox, sandboxes };
4542
},
4643
);
4744
const mapDispatchToProps = dispatch => ({

0 commit comments

Comments
 (0)