Skip to content

Commit 6735419

Browse files
committed
Merge branch 'master' of https://github.com/popcodeorg/popcode
2 parents 475929a + 3320a6e commit 6735419

39 files changed

Lines changed: 894 additions & 494 deletions

locales/en/translation.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
{
22
"top-bar": {
33
"create-snapshot": "Snapshot",
4+
"export-gist": "Export Gist",
5+
"export-repo": "Export Repo",
46
"libraries": "Libraries",
57
"load-project": "My Projects",
68
"new-project": "New Project",
9+
"send-feedback": "Send Feedback",
710
"session": {
811
"log-in-prompt": "Log in to save",
912
"log-out-prompt": "Log out"
1013
}
1114
},
12-
"dashboard": {
13-
"menu": {
14-
"export-gist": "Export Gist",
15-
"send-feedback": "Send Feedback",
16-
"export-repo": "Export Repo"
17-
}
18-
},
1915
"editors": {
2016
"help-text": "Type in your $t(languages.{{language}}) code here."
2117
},
@@ -51,7 +47,6 @@
5147
},
5248
"workspace": {
5349
"confirmations": {
54-
"unload-unsaved": "If you leave the page, you will lose your work. To save your work, you must log in using your GitHub account.",
5550
"anonymous-gist-export": "Are you sure you want to export this gist anonymously? If you sign in before exporting, the gist will be added to your GitHub account."
5651
},
5752
"loading": "Loading…",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
"PrettyCSS": "^0.3.13",
101101
"ajv": "^5.2.2",
102102
"array-to-sentence": "^1.1.0",
103-
"base64-js": "^1.0.2",
104103
"bowser": "^1.4.5",
105104
"brace": "^0.10.0",
106105
"bugsnag-js": "^3.0.1",
@@ -141,11 +140,12 @@
141140
"redux-logger": "^3.0.6",
142141
"redux-saga": "^0.15.3",
143142
"redux-saga-debounce-effect": "https://github.com/madewithlove/redux-saga-debounce-effect.git#v0.2.2",
143+
"remark": "^8.0.0",
144+
"remark-react": "^4.0.0",
144145
"reselect": "^3.0.1",
145146
"rxjs": "^5.0.2",
146147
"slowparse": "^1.1.4",
147148
"stylelint": "^8.0.0",
148-
"text-encoding": "^0.6.0",
149149
"uuid": "^3.1.0",
150150
"void-elements": "^3.1.0"
151151
},

src/actions/clients.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ export const repoExportError = createAction('REPO_EXPORT_ERROR');
1818
export const repoExportDisplayed = createAction('REPO_EXPORT_DISPLAYED');
1919
export const repoExportNotDisplayed =
2020
createAction('REPO_EXPORT_NOT_DISPLAYED');
21+
export const projectRestoredFromLastSession =
22+
createAction('PROJECT_RESTORED_FROM_LAST_SESSION');

src/actions/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
toggleLibrary,
1717
hideComponent,
1818
unhideComponent,
19+
toggleComponent,
1920
updateProjectSource,
2021
} from './projects';
2122

@@ -44,10 +45,6 @@ import {
4445
userLoggedOut,
4546
} from './user';
4647

47-
function toggleDashboard() {
48-
return {type: 'DASHBOARD_TOGGLED'};
49-
}
50-
5148
export {
5249
createProject,
5350
createSnapshot,
@@ -59,7 +56,7 @@ export {
5956
addRuntimeError,
6057
hideComponent,
6158
unhideComponent,
62-
toggleDashboard,
59+
toggleComponent,
6360
focusLine,
6461
editorFocusedRequestedLine,
6562
dragRowDivider,

src/actions/projects.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export const unhideComponent = createAction(
3636
(_projectKey, _componentName, timestamp = Date.now()) => ({timestamp}),
3737
);
3838

39+
export const toggleComponent = createAction(
40+
'TOGGLE_COMPONENT',
41+
(projectKey, componentName) => ({projectKey, componentName}),
42+
(_projectKey, _componentName, timestamp = Date.now()) => ({timestamp}),
43+
);
44+
3945
export const gistImported = createAction(
4046
'GIST_IMPORTED',
4147
(projectKey, gistData) => ({projectKey, gistData}),

src/clients/github.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ function buildGistFromProject(project) {
108108
language: 'JavaScript',
109109
};
110110
}
111+
if (trim(project.instructions)) {
112+
files['README.md'] = {
113+
content: project.instructions,
114+
language: 'Markdown',
115+
};
116+
}
111117
if (project.enabledLibraries.length || project.hiddenUIComponents.length) {
112118
files['popcode.json'] = {
113119
content: createPopcodeJson(project),

src/clients/localStorage.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const PROJECT_STORAGE_KEY = 'last-closed-session-project-state';
2+
const GRACE_PERIOD = 5 * 60 * 1000;
3+
4+
export function dehydrateProject(project) {
5+
localStorage.setItem(PROJECT_STORAGE_KEY, JSON.stringify({
6+
dehydratedAt: Date.now(),
7+
project,
8+
}));
9+
}
10+
11+
export function rehydrateProject() {
12+
const dehydrated = localStorage.getItem(PROJECT_STORAGE_KEY);
13+
localStorage.removeItem(PROJECT_STORAGE_KEY);
14+
if (dehydrated) {
15+
const rehydrated = JSON.parse(dehydrated);
16+
if (Date.now() - rehydrated.dehydratedAt <= GRACE_PERIOD) {
17+
return rehydrated.project;
18+
}
19+
}
20+
return null;
21+
}

src/components/Dashboard.jsx

Lines changed: 0 additions & 112 deletions
This file was deleted.

src/components/Instructions.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import remark from 'remark';
4+
import remarkReact from 'remark-react';
5+
import classnames from 'classnames';
6+
7+
export default function Instructions({instructions, isOpen}) {
8+
if (!instructions || !isOpen) {
9+
return null;
10+
}
11+
12+
return (
13+
<div
14+
className={classnames(
15+
'layout__instructions',
16+
'instructions',
17+
'u__flex-container',
18+
'u__flex-container_column',
19+
)}
20+
>
21+
{remark().use(remarkReact).processSync(instructions).contents}
22+
</div>
23+
);
24+
}
25+
26+
Instructions.propTypes = {
27+
instructions: PropTypes.string.isRequired,
28+
isOpen: PropTypes.bool.isRequired,
29+
};

src/components/Sidebar.jsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)