Skip to content

Commit 1d93c49

Browse files
authored
Merge pull request #993 from outoftime/hamburgler
Move remaining functionality into Hamburger menu
2 parents 9b00652 + 239d811 commit 1d93c49

23 files changed

Lines changed: 317 additions & 449 deletions

locales/en/translation.json

Lines changed: 3 additions & 7 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
},

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/components/Dashboard.jsx

Lines changed: 0 additions & 119 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.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import classnames from 'classnames';
2+
import {noop} from 'lodash/noop';
3+
import {t} from 'i18next';
4+
import PropTypes from 'prop-types';
5+
import React from 'react';
6+
import config from '../../config';
7+
8+
export default function HamburgerMenu({
9+
isExperimental,
10+
isGistExportInProgress,
11+
isOpen,
12+
isUserAuthenticated,
13+
onExportGist,
14+
onExportRepo,
15+
}) {
16+
if (!isOpen) {
17+
return null;
18+
}
19+
20+
21+
return (
22+
<div className="top-bar__menu">
23+
<div
24+
className="top-bar__menu-item"
25+
onClick={isGistExportInProgress ? noop : onExportGist}
26+
>
27+
{t('top-bar.export-gist')}
28+
</div>
29+
<div
30+
className={
31+
classnames(
32+
'top-bar__menu-item',
33+
{u__hidden: !(isUserAuthenticated && isExperimental)},
34+
)
35+
}
36+
onClick={onExportRepo}
37+
>
38+
{t('top-bar.export-repo')}
39+
</div>
40+
<a
41+
className="top-bar__menu-item"
42+
href={config.feedbackUrl}
43+
rel="noopener noreferrer"
44+
target="blank"
45+
>
46+
{t('top-bar.send-feedback')}
47+
</a>
48+
<div className="top-bar__menu-item top-bar__menu-item_icons">
49+
<a
50+
className="u__icon"
51+
href="https://github.com/popcodeorg/popcode"
52+
rel="noopener noreferrer"
53+
target="_blank"
54+
>&#xf09b;</a>
55+
<a
56+
className="u__icon"
57+
href="https://twitter.com/popcodeorg"
58+
rel="noopener noreferrer"
59+
target="_blank"
60+
>&#xf099;</a>
61+
<a
62+
className="u__icon"
63+
href="https://slack.popcode.org/"
64+
rel="noopener noreferrer"
65+
target="_blank"
66+
>&#xf198;</a>
67+
</div>
68+
</div>
69+
);
70+
}
71+
72+
HamburgerMenu.propTypes = {
73+
isExperimental: PropTypes.bool.isRequired,
74+
isGistExportInProgress: PropTypes.bool.isRequired,
75+
isOpen: PropTypes.bool.isRequired,
76+
isUserAuthenticated: PropTypes.bool.isRequired,
77+
onExportGist: PropTypes.func.isRequired,
78+
onExportRepo: PropTypes.func.isRequired,
79+
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import classnames from 'classnames';
2+
import React from 'react';
3+
import PropTypes from 'prop-types';
4+
import HamburgerMenu from './HamburgerMenu';
5+
6+
export default function HamburgerMenuButton({
7+
isExperimental,
8+
isGistExportInProgress,
9+
isOpen,
10+
isUserAuthenticated,
11+
onClick,
12+
onExportGist,
13+
onExportRepo,
14+
}) {
15+
return (
16+
<div
17+
className={classnames(
18+
'top-bar__menu-button',
19+
'top-bar__menu-button_hamburger',
20+
{'top-bar__menu-button_active': isOpen},
21+
)}
22+
onClick={onClick}
23+
>
24+
<span className="u__icon top-bar__hamburger">&#xf0c9;</span>
25+
<HamburgerMenu
26+
isExperimental={isExperimental}
27+
isGistExportInProgress={isGistExportInProgress}
28+
isOpen={isOpen}
29+
isUserAuthenticated={isUserAuthenticated}
30+
onExportGist={onExportGist}
31+
onExportRepo={onExportRepo}
32+
/>
33+
</div>
34+
);
35+
}
36+
37+
HamburgerMenuButton.propTypes = {
38+
isExperimental: PropTypes.bool.isRequired,
39+
isGistExportInProgress: PropTypes.bool.isRequired,
40+
isOpen: PropTypes.bool.isRequired,
41+
isUserAuthenticated: PropTypes.bool.isRequired,
42+
onClick: PropTypes.func.isRequired,
43+
onExportGist: PropTypes.func.isRequired,
44+
onExportRepo: PropTypes.func.isRequired,
45+
};

0 commit comments

Comments
 (0)