Skip to content

Commit f9c6435

Browse files
committed
add help overlay
1 parent ad11ec5 commit f9c6435

File tree

8 files changed

+101
-1
lines changed

8 files changed

+101
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"codemirror": "^4.13.0",
1313
"frylord": "^0.7.1",
1414
"holovisor": "^0.2.0",
15-
"iggins": "^0.3.0",
15+
"iggins": "^0.4.0",
1616
"irken": "^0.8.0",
1717
"lodash": "^3.9.1",
1818
"react": "^0.13.1",

src/constants/overlay-states.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const overlayStates = {
44
NO_OVERLAY: 'NO_OVERLAY',
5+
HELP_OVERLAY: 'HELP_OVERLAY',
56
SAVE_OVERLAY: 'SAVE_OVERLAY',
67
DOWNLOAD_OVERLAY: 'DOWNLOAD_OVERLAY',
78
PROJECTS_OVERLAY: 'PROJECTS_OVERLAY',

src/creators/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const creators = {
88
showDownloadOverlay: require('./show-download-overlay'),
99
showProjectsOverlay: require('./show-projects-overlay'),
1010
showSaveOverlay: require('./show-save-overlay'),
11+
showHelpOverlay: require('./show-help-overlay'),
1112
hideOverlay: require('./hide-overlay'),
1213
// terminal creators
1314
rxOn: require('./rx-on'),

src/creators/show-help-overlay.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const {
4+
SHOW_OVERLAY
5+
} = require('../constants/action-types');
6+
7+
const {
8+
HELP_OVERLAY
9+
} = require('../constants/overlay-states');
10+
11+
function showHelpOverlay(){
12+
return {
13+
type: SHOW_OVERLAY,
14+
payload: {
15+
state: HELP_OVERLAY
16+
}
17+
};
18+
}
19+
20+
module.exports = showHelpOverlay;

src/plugins/handlers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ function handlers(app, opts, done){
225225
store.dispatch(creators.showDeleteProjectOverlay());
226226
}
227227

228+
function showHelpOverlay(){
229+
store.dispatch(creators.showHelpOverlay());
230+
}
231+
228232
function showSaveOverlay(){
229233
store.dispatch(creators.showSaveOverlay());
230234
}
@@ -572,6 +576,7 @@ function handlers(app, opts, done){
572576
deleteProject,
573577
deleteProjectConfirm,
574578
// overlay methods
579+
showHelpOverlay,
575580
showSaveOverlay,
576581
showDownloadOverlay,
577582
showProjectsOverlay,

src/plugins/keyboard-shortcuts.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function keyboardShortcuts(app, opts, done){
1414
const { keypress, handlers } = app;
1515

1616
const {
17+
F1,
1718
F3,
1819
F6,
1920
F7,
@@ -36,6 +37,7 @@ function keyboardShortcuts(app, opts, done){
3637
} = keypress;
3738

3839
const {
40+
showHelpOverlay,
3941
newFile,
4042
saveFile,
4143
hideOverlay,
@@ -81,6 +83,11 @@ function keyboardShortcuts(app, opts, done){
8183
hideOverlay();
8284
});
8385

86+
keypress(F1, function(evt){
87+
evt.preventDefault();
88+
showHelpOverlay();
89+
});
90+
8491
keypress(F3, function(evt){
8592
evt.preventDefault();
8693
findNext();

src/plugins/overlays.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const React = require('react');
44

5+
const HelpOverlay = require('../views/help-overlay');
56
const SaveOverlay = require('../views/save-overlay');
67
const ProjectOverlay = require('../views/project-overlay');
78
const DownloadOverlay = require('../views/download-overlay');
@@ -12,6 +13,7 @@ const store = require('../store');
1213

1314
const {
1415
NO_OVERLAY,
16+
HELP_OVERLAY,
1517
SAVE_OVERLAY,
1618
DOWNLOAD_OVERLAY,
1719
PROJECTS_OVERLAY,
@@ -35,6 +37,9 @@ function overlays(app, opts, done){
3537
const { overlayState } = store.getState();
3638

3739
switch(overlayState){
40+
case HELP_OVERLAY:
41+
renderOverlay(<HelpOverlay workspace={workspace} handlers={handlers} />);
42+
break;
3843
case SAVE_OVERLAY:
3944
renderOverlay(<SaveOverlay workspace={workspace} handlers={handlers} />);
4045
break;

src/views/help-overlay.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use strict';
2+
3+
const React = require('react');
4+
const { createContainer } = require('sovereign');
5+
const Button = require('react-material/components/Button');
6+
7+
const Overlay = require('../components/overlay');
8+
const OverlayTitle = require('../components/overlay-title');
9+
const OverlayFooter = require('../components/overlay-footer');
10+
11+
const helpStyle = {
12+
position: 'relative'
13+
};
14+
15+
const helpLink = 'http://www.parallax.com/go/PBASICHelp';
16+
17+
class HelpOverlay extends React.Component {
18+
19+
constructor(...args){
20+
super(...args);
21+
}
22+
23+
render(){
24+
const {
25+
handlers
26+
} = this.props;
27+
28+
const {
29+
hideOverlay
30+
} = handlers;
31+
32+
return (
33+
<Overlay>
34+
<OverlayTitle>Help</OverlayTitle>
35+
<div style={helpStyle}>
36+
For help with PBASIC go here: <a href={helpLink} target="_blank">{helpLink}</a>
37+
</div>
38+
<OverlayFooter>
39+
<Button onClick={hideOverlay}>OK</Button>
40+
</OverlayFooter>
41+
</Overlay>
42+
);
43+
}
44+
}
45+
46+
module.exports = createContainer(HelpOverlay, {
47+
getStores({ workspace }){
48+
return {
49+
workspace
50+
};
51+
},
52+
53+
getPropsFromStores({ workspace }){
54+
const { cwd, projects } = workspace.getState();
55+
56+
return {
57+
cwd,
58+
projects
59+
};
60+
}
61+
});

0 commit comments

Comments
 (0)