Skip to content

Commit fc0e743

Browse files
tutorial menu link working
1 parent 699da0b commit fc0e743

22 files changed

+439
-32
lines changed

app/electron/main.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ async function createWindow() {
7878
// disables remote module. critical for ensuring that rendering process doesn't have access to node functionality
7979
enableRemoteModule: false,
8080
// path of preload script. preload is how the renderer page will have access to electron functionality
81-
preload: path.join(__dirname, 'preload.js')
81+
preload: path.join(__dirname, 'preload.js'),
82+
nativeWindowOpen: true
8283
}
8384
});
8485

@@ -397,4 +398,45 @@ ipcMain.on('github', event => {
397398
});
398399
});
399400

401+
ipcMain.on('tutorial', event => {
402+
// create new browserwindow object with size, title, security options
403+
const tutorial = new BrowserWindow({
404+
width: 800,
405+
height: 600,
406+
title: 'Tutorial',
407+
webPreferences: {
408+
nodeIntegration: false,
409+
nodeIntegrationInWorker: false,
410+
nodeIntegrationInSubFrames: false,
411+
contextIsolation: true,
412+
enableRemoteModule: false,
413+
zoomFactor: 1.0
414+
}
415+
});
416+
// redirects to relevant server endpoint
417+
//github.loadURL(`${serverUrl}/github`);
418+
// show window
419+
tutorial.show();
420+
// if final callback is reached and we get a redirect from server back to our app, close oauth window
421+
// github.webContents.on('will-redirect', (e, callbackUrl) => {
422+
// let redirectUrl = 'app://rse/';
423+
// if (isDev) {
424+
// redirectUrl = 'http://localhost:8080/';
425+
// }
426+
// if (callbackUrl === redirectUrl) {
427+
// dialog.showMessageBox({
428+
// type: 'info',
429+
// title: 'ReacType',
430+
// icon: resolve('app/src/public/icons/png/256x256.png'),
431+
// message: 'Github Oauth Successful!'
432+
// });
433+
// github.close();
434+
// }
435+
// });
436+
});
437+
438+
439+
440+
441+
400442
//module.exports = dialog;

app/electron/menu.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const { Menu } = require("electron");
2+
const { BrowserWindow } = require('electron');
3+
const fs = require('fs');
4+
const path = require('path');
25
const isMac = process.platform === "darwin";
6+
const port = 5000;
7+
const tutorialRoute = `http://localhost:${port}/tutorial`;
38

49
// Create a template for a menu and create menu using that template
510
var MenuBuilder = function (mainWindow, appName) {
@@ -8,6 +13,25 @@ var MenuBuilder = function (mainWindow, appName) {
813
// https://www.electronjs.org/docs/api/menu-item
914
// you can also create custom menu items with their own "on click" functionality if you need to
1015
// different roles are available between mac and windows
16+
17+
const openTutorial = () => {
18+
const tutorial = new BrowserWindow({
19+
width: 800,
20+
height: 600,
21+
title: 'Tutorial',
22+
webPreferences: {
23+
nodeIntegration: false,
24+
nodeIntegrationInWorker: false,
25+
nodeIntegrationInSubFrames: false,
26+
contextIsolation: true,
27+
enableRemoteModule: false,
28+
zoomFactor: 1.0
29+
}
30+
});
31+
tutorial.loadURL(`http://localhost:8080/#/tutorial`);
32+
tutorial.show();
33+
}
34+
1135
let defaultTemplate = function () {
1236
return [
1337
// { role: "appMenu" }
@@ -199,7 +223,7 @@ var MenuBuilder = function (mainWindow, appName) {
199223
},
200224
{
201225
label: "Tutorial",
202-
click:
226+
click: () => openTutorial()
203227
}
204228
],
205229
},

app/electron/preload.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const {
1111
setCookie,
1212
getCookie,
1313
delCookie,
14-
github
14+
github,
15+
tutorial
1516
} = require('./preloadFunctions/cookies');
1617

1718
// Expose protected methods that allow the renderer process to use select node methods
@@ -34,5 +35,6 @@ contextBridge.exposeInMainWorld('api', {
3435
setCookie,
3536
getCookie,
3637
delCookie,
37-
github
38+
github,
39+
tutorial
3840
});

app/electron/preloadFunctions/cookies.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ const github = () => {
1818
return ipcRenderer.send('github');
1919
};
2020

21-
module.exports = { setCookie, getCookie, delCookie, github };
21+
const tutorial = () => {
22+
return ipcRenderer.send('tutorial');
23+
};
24+
25+
module.exports = { setCookie, getCookie, delCookie, github, tutorial };

app/src/components/bottom/BottomTabs.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Tree from '../../tree/TreeChart';
99
import { emitKeypressEvents } from 'readline';
1010
import NativeSelect from '@material-ui/core/NativeSelect';
1111
import FormControl from '@material-ui/core/FormControl';
12+
import { styleContext } from '../../containers/AppContainer';
1213

1314
const BottomTabs = () => {
1415
// state that controls which tab the user is on
@@ -17,7 +18,8 @@ const BottomTabs = () => {
1718
const classes = useStyles();
1819
treeWrapper: HTMLDivElement;
1920
const [theme, setTheme] = useState('monokai');
20-
21+
const { style } = useContext(styleContext);
22+
2123
// method changes the
2224
const handleChange = (event: React.ChangeEvent, value: number) => {
2325
setTab(value);
@@ -31,7 +33,7 @@ const BottomTabs = () => {
3133
};
3234

3335
return (
34-
<div className={classes.root}>
36+
<div className={classes.root} style={style}>
3537
<Box display="flex" justifyContent="space-between">
3638
<Tabs
3739
value={tab}
@@ -61,11 +63,11 @@ const BottomTabs = () => {
6163
value={theme}
6264
onChange={changeTheme}
6365
>
64-
<option value={'monokai'}>Monokai</option>
65-
<option value={'github'}>Github</option>
66-
<option value={'solarized_dark'}>Solarized Dark</option>
67-
<option value={'terminal'}>Terminal</option>
68-
<option value={'solarized_light'}>Solarized Light</option>
66+
<option style ={{backgroundColor: '#252526'}} value={'monokai'}>Monokai</option>
67+
<option style ={{backgroundColor: '#252526'}} value={'github'}>Github</option>
68+
<option style ={{backgroundColor: '#252526'}} value={'solarized_dark'}>Solarized Dark</option>
69+
<option style ={{backgroundColor: '#252526'}} value={'terminal'}>Terminal</option>
70+
<option style ={{backgroundColor: '#252526'}} value={'solarized_light'}>Solarized Light</option>
6971
</NativeSelect>
7072
</div>
7173
</FormControl>

app/src/components/login/SignIn.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
226226
className={classes.submit}
227227
onClick={() => {
228228
// messages the main proces to open new window for github oauth
229+
console.log('open github')
229230
window.api.github();
230231
}}
231232
>

app/src/components/login/SignUp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
292292
onClick={e => handleSignUp(e)}
293293
>
294294
Sign Up
295-
</Button>
295+
</Button>+
296296
<Grid container justify="flex-end">
297297
<Grid item>
298298
<RouteLink to={`/login`} className="nav_link">

app/src/components/right/ProjectManager.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Button from '@material-ui/core/Button';
1111
import MenuItem from '@material-ui/core/MenuItem';
1212
import Select from '@material-ui/core/Select';
1313
import FormControl from '@material-ui/core/FormControl';
14-
import { useHistory, withRouter } from 'react-router-dom';
14+
import { useHistory, withRouter, Link as RouteLink } from 'react-router-dom';
1515

1616
import exportProject from '../../utils/exportProject.util';
1717

@@ -163,17 +163,28 @@ const ProjectManager = () => {
163163

164164
return (
165165
<div>
166+
<RouteLink to={'/tutorial'} style={{textDecoration: 'none'}}>
167+
<Button
168+
color="primary"
169+
style={{ ...style.button, marginLeft: '15%', textDecoration: 'none' }}
170+
variant="outlined"
171+
className={classes.button}
172+
>
173+
Tutorial
174+
</Button>
175+
</RouteLink>
166176
<Button
167177
color="primary"
168-
style={{ marginLeft: '15%' }}
178+
style={{ ...style.button, marginLeft: '15%' }}
179+
variant="outlined"
169180
className={classes.button}
170181
onClick={() => {
171182
!style.backgroundColor
172-
? setStyle({ backgroundColor: '#00001a', color: 'red' })
183+
? setStyle({ backgroundColor: '#00001a' })
173184
: setStyle({});
174185
}}
175186
>
176-
Change Darkness Mode
187+
Change Lighting
177188
</Button>
178189

179190
<div className={classes.projectManagerWrapper}>

app/src/containers/AppContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import RightContainer from './RightContainer';
77
import { theme1 } from '../public/styles/theme';
88
import { makeStyles } from '@material-ui/core/styles';
99

10-
export const styleContext = createContext({});
10+
export const styleContext = createContext({
11+
style: null,
12+
setStyle: null
13+
});
1114
// console.log('styleContext: ', styleContext);
1215

1316
const AppContainer = () => {

app/src/containers/MainContainer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import React, { Component } from 'react';
1+
import React, { useContext } from 'react';
22
import BottomPanel from '../components/bottom/BottomPanel';
33
import CanvasContainer from '../components/main/CanvasContainer';
4+
import { styleContext } from './AppContainer';
45

5-
const MainContainer = ({ style }) => {
6+
const MainContainer = () => {
7+
const { style } = useContext(styleContext);
68
return (
79
<div className="main-container" style={style}>
810
<div className="main">

app/src/index.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,28 @@ import Cookies from 'js-cookie';
66

77
import SignIn from './components/login/SignIn.tsx';
88
import SignUp from './components/login/SignUp.tsx';
9-
import Wizard from './wizard/Wizard.tsx';
9+
import Tutorial from './tutorial/Tutorial.tsx';
10+
import Pages from './tutorial/Pages.tsx';
11+
import Customization from './tutorial/Customization.tsx';
12+
import Canvas from './tutorial/Canvas.tsx';
13+
import Styling from './tutorial/Styling.tsx';
14+
import RouteLinks from './tutorial/RouteLinks.tsx';
15+
import ReusableComponents from './tutorial/ReusableComponents.tsx';
16+
import ComponentTree from './tutorial/ComponentTree.tsx';
17+
import HtmlElements from './tutorial/HtmlElements.tsx';
18+
import CodePreview from './tutorial/CodePreview.tsx';
1019

1120
import {
1221
HashRouter as Router,
1322
Route,
1423
Redirect,
15-
Switch
24+
Switch,
1625
} from 'react-router-dom';
1726

1827
const PrivateRoute = ({ component: Component, ...rest }) => (
1928
<Route
2029
{...rest}
2130
render={props => {
22-
//console.log(props);
2331
return Cookies.get('ssid') || window.localStorage.getItem('ssid') ? (
2432
<Component {...props} />
2533
) : (
@@ -35,11 +43,18 @@ ReactDOM.render(
3543
<Switch>
3644
<Route exact path="/login" component={SignIn} />
3745
<Route exact path="/signup" component={SignUp} />
38-
<PrivateRoute path="/" component={App} />
39-
<PrivateRoute path="/wizard" component={Wizard} />
46+
<PrivateRoute exact path="/" component={App} />
47+
<Route exact path="/tutorial" component={Tutorial}/>
48+
<Route exact path="/pages" component={Pages}/>
49+
<Route exact path="/links" component={RouteLinks}/>
50+
<Route exact path="/code-preview" component={CodePreview}/>
51+
<Route exact path="/reusable-components" component={ReusableComponents}/>
52+
<Route exact path="/component-tree" component={ComponentTree}/>
53+
<Route exact path="/html-elements" component={HtmlElements}/>
54+
<Route exact path="/styling" component={Styling}/>
55+
<Route exact path="/customization" component={Customization}/>
56+
<Route exact path="/canvas" component={Canvas}/>
4057
</Switch>
4158
</Router>,
4259
document.getElementById('app')
43-
);
44-
45-
// ReactDOM.render(<App></App>, document.getElementById('app'));
60+
);

app/src/tutorial/Canvas.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import { Link, withRouter, RouteComponentProps } from 'react-router-dom';
3+
4+
// import Grid from '@material-ui/core/Grid';
5+
6+
// import ComponentPanel from '../components/left/ComponentPanel';
7+
// import HTMLPanel from '../components/left/HTMLPanel';
8+
9+
// Left-hand portion of the app, where component options are displayed
10+
11+
const Canvas: React.FC<RouteComponentProps> = () => {
12+
return (
13+
<div>
14+
Canvas
15+
<Link to={`/`}>
16+
<button>Application</button>
17+
</Link>
18+
<Link to={`/tutorial`}>
19+
<button>Tutorial</button>
20+
</Link>
21+
</div>
22+
);
23+
};
24+
25+
export default withRouter(Canvas);
26+

app/src/tutorial/CodePreview.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import { Link, withRouter, RouteComponentProps } from 'react-router-dom';
3+
4+
// import Grid from '@material-ui/core/Grid';
5+
6+
// import ComponentPanel from '../components/left/ComponentPanel';
7+
// import HTMLPanel from '../components/left/HTMLPanel';
8+
9+
// Left-hand portion of the app, where component options are displayed
10+
11+
const CodePreview: React.FC<RouteComponentProps> = () => {
12+
return (
13+
<div>
14+
CodePreview
15+
<Link to={`/`}>
16+
<button>Application</button>
17+
</Link>
18+
<Link to={`/tutorial`}>
19+
<button>Tutorial</button>
20+
</Link>
21+
</div>
22+
);
23+
};
24+
25+
export default withRouter(CodePreview);
26+

app/src/tutorial/ComponentTree.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import { Link, withRouter, RouteComponentProps } from 'react-router-dom';
3+
4+
// import Grid from '@material-ui/core/Grid';
5+
6+
// import ComponentPanel from '../components/left/ComponentPanel';
7+
// import HTMLPanel from '../components/left/HTMLPanel';
8+
9+
// Left-hand portion of the app, where component options are displayed
10+
11+
const ComponentTree: React.FC<RouteComponentProps> = () => {
12+
return (
13+
<div>
14+
ComponentTree
15+
<Link to={`/`}>
16+
<button>Application</button>
17+
</Link>
18+
<Link to={`/tutorial`}>
19+
<button>Tutorial</button>
20+
</Link>
21+
</div>
22+
);
23+
};
24+
25+
export default withRouter(ComponentTree);
26+

0 commit comments

Comments
 (0)