Skip to content

Commit 6d28623

Browse files
authored
Merge pull request #17 from diegovazquezny/wizard
Wizard
2 parents 4739257 + 0e7615d commit 6d28623

21 files changed

+449
-21
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: 29 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" }
@@ -196,7 +220,11 @@ var MenuBuilder = function (mainWindow, appName) {
196220
"https://github.com/open-source-labs/ReacType"
197221
);
198222
},
199-
},
223+
},
224+
{
225+
label: "Tutorial",
226+
click: () => openTutorial()
227+
}
200228
],
201229
},
202230
];

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: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import NativeSelect from '@material-ui/core/NativeSelect';
1111
import FormControl from '@material-ui/core/FormControl';
1212
import { styleContext } from '../../containers/AppContainer';
1313

14-
1514
const BottomTabs = () => {
1615
// state that controls which tab the user is on
1716
const [state, dispatch] = useContext(StateContext);
@@ -63,11 +62,11 @@ const BottomTabs = () => {
6362
value={theme}
6463
onChange={changeTheme}
6564
>
66-
<option value={'monokai'}>Monokai</option>
67-
<option value={'github'}>Github</option>
68-
<option value={'solarized_dark'}>Solarized Dark</option>
69-
<option value={'terminal'}>Terminal</option>
70-
<option value={'solarized_light'}>Solarized Light</option>
65+
<option style ={{backgroundColor: '#252526'}} value={'monokai'}>Monokai</option>
66+
<option style ={{backgroundColor: '#252526'}} value={'github'}>Github</option>
67+
<option style ={{backgroundColor: '#252526'}} value={'solarized_dark'}>Solarized Dark</option>
68+
<option style ={{backgroundColor: '#252526'}} value={'terminal'}>Terminal</option>
69+
<option style ={{backgroundColor: '#252526'}} value={'solarized_light'}>Solarized Light</option>
7170
</NativeSelect>
7271
</div>
7372
</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: 12 additions & 2 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,6 +163,16 @@ 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"
168178
style={{ ...style.button, marginLeft: '15%' }}
@@ -174,7 +184,7 @@ const ProjectManager = () => {
174184
: setStyle({});
175185
}}
176186
>
177-
Change Darkness Mode
187+
Change Lighting
178188
</Button>
179189

180190
<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/index.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +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 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';
919

1020
import {
1121
HashRouter as Router,
1222
Route,
1323
Redirect,
14-
Switch
24+
Switch,
1525
} from 'react-router-dom';
1626

1727
const PrivateRoute = ({ component: Component, ...rest }) => (
1828
<Route
1929
{...rest}
2030
render={props => {
21-
//console.log(props);
2231
return Cookies.get('ssid') || window.localStorage.getItem('ssid') ? (
2332
<Component {...props} />
2433
) : (
@@ -34,10 +43,18 @@ ReactDOM.render(
3443
<Switch>
3544
<Route exact path="/login" component={SignIn} />
3645
<Route exact path="/signup" component={SignUp} />
37-
<PrivateRoute path="/" component={App} />
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}/>
3857
</Switch>
3958
</Router>,
4059
document.getElementById('app')
41-
);
42-
43-
// 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+

app/src/tutorial/Customization.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 Customization: React.FC<RouteComponentProps> = () => {
12+
return (
13+
<div>
14+
Customization
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(Customization);
26+

0 commit comments

Comments
 (0)