Skip to content

Commit 2a26d99

Browse files
Merge pull request #46 from spincycle01/master
current export functionality exists and better load with Electron. Canvas currently working
2 parents b37ba20 + f04183b commit 2a26d99

File tree

10 files changed

+383
-149
lines changed

10 files changed

+383
-149
lines changed

index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/usr/bin/env node
2-
const util = require('util');
3-
const program = require('commander');
4-
const execFile = util.promisify(require('child_process').execFile);
5-
const { Spinner } = require('cli-spinner');
2+
// const util = require('util');
3+
// const program = require('commander');
4+
// const execFile = util.promisify(require('child_process').execFile);
5+
// const { Spinner } = require('cli-spinner');
66

7-
const spinner = new Spinner('running app... %s');
8-
spinner.setSpinnerString('|/-\\');
7+
// const spinner = new Spinner('running app... %s');
8+
// spinner.setSpinnerString('|/-\\');
99

10-
program
11-
.version('1.0.0', '-v, --version, -V')
12-
.description('An application for prototyping React application.');
10+
// program
11+
// .version('1.0.0', '-v, --version, -V')
12+
// .description('An application for prototyping React application.');
1313

14-
program
15-
.command('start')
16-
.description('Start-up reactype app')
17-
.action(() => {
18-
spinner.start();
19-
execFile('npm', ['start']).catch(err => console.log(err));
20-
});
14+
// program
15+
// .command('start')
16+
// .description('Start-up reactype app')
17+
// .action(() => {
18+
// spinner.start();
19+
// execFile('npm', ['start']).catch(err => console.log(err));
20+
// });
2121

2222
program.parse(process.argv);

main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
ipcMain,
88
} = require('electron');
99

10+
1011
require('electron-reload')(__dirname);
1112

1213
// const isDev = true;
@@ -34,6 +35,11 @@ function openFile() {
3435
mainWindow.webContents.send('new-file', file);
3536
}
3637

38+
// export files
39+
function exportComponents() {
40+
console.log('hi from exportComponents');
41+
}
42+
3743
// Choose directory
3844
ipcMain.on('choose_app_dir', (event) => {
3945
const directory = dialog.showOpenDialog(mainWindow, {
@@ -60,10 +66,15 @@ const createWindow = () => {
6066
mainWindow = new BrowserWindow({
6167
width,
6268
height,
69+
show: false,
6370
});
6471

6572
// and load the index.html of the app.
6673
mainWindow.loadURL(`file://${__dirname}/build/index.html`);
74+
// load page once window is loaded
75+
mainWindow.once('ready-to-show', () => {
76+
mainWindow.show();
77+
});
6778

6879
const template = [{
6980
label: 'File',
@@ -73,6 +84,13 @@ const createWindow = () => {
7384
click() {
7485
openFile();
7586
},
87+
},
88+
{
89+
label: 'Export Components',
90+
accelerator: process.platform === 'darwin' ? 'Cmd+E' : 'Ctrl+Shift+E',
91+
click() {
92+
exportComponents();
93+
},
7694
}],
7795
},
7896
{

src/actions/components.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import {
3030

3131
import { loadState } from "../localStorage";
3232

33-
// import createFiles from '../utils/createFiles.util';
34-
// import createApplicationUtil from '../utils/createApplication.util';
33+
import createFiles from '../utils/createFiles.util';
34+
import createApplicationUtil from '../utils/createApplication.util'
3535

3636
export const loadInitData = () => dispatch => {
3737
loadState().then(data =>
@@ -157,21 +157,21 @@ export const changeComponentFocusChild = ({
157157
});
158158
};
159159

160-
// export const exportFiles = ({ components, path }) => (dispatch) => {
161-
// dispatch({
162-
// type: EXPORT_FILES,
163-
// });
160+
export const exportFiles = ({ components, path }) => (dispatch) => {
161+
dispatch({
162+
type: EXPORT_FILES,
163+
});
164164

165-
// createFiles(components, path)
166-
// .then(dir => dispatch({
167-
// type: EXPORT_FILES_SUCCESS,
168-
// payload: { status: true, dir: dir[0] },
169-
// }))
170-
// .catch(err => dispatch({
171-
// type: EXPORT_FILES_ERROR,
172-
// payload: { status: true, err },
173-
// }));
174-
// };
165+
createFiles(components, path)
166+
.then(dir => dispatch({
167+
type: EXPORT_FILES_SUCCESS,
168+
payload: { status: true, dir: dir[0] },
169+
}))
170+
.catch(err => dispatch({
171+
type: EXPORT_FILES_ERROR,
172+
payload: { status: true, err },
173+
}));
174+
};
175175

176176
export const handleClose = () => ({
177177
type: HANDLE_CLOSE,
@@ -194,30 +194,30 @@ export const handleTransform = (
194194
}
195195
});
196196

197-
// export const createApplication = ({
198-
// path, components = [], genOption, appName = 'proto_app', repoUrl,
199-
// }) => (dispatch) => {
200-
// if (genOption === 0) {
201-
// dispatch(exportFiles({ path, components }));
202-
// } else if (genOption) {
203-
// dispatch({
204-
// type: CREATE_APPLICATION,
205-
// });
206-
// createApplicationUtil({
207-
// path, appName, genOption, repoUrl,
208-
// })
209-
// .then(() => {
210-
// dispatch({
211-
// type: CREATE_APPLICATION_SUCCESS,
212-
// });
213-
// dispatch(exportFiles({ path: `${path}/${appName}`, components }));
214-
// })
215-
// .catch(err => dispatch({
216-
// type: CREATE_APPLICATION_ERROR,
217-
// payload: { status: true, err },
218-
// }));
219-
// }
220-
// };
197+
export const createApplication = ({
198+
path, components = [], genOption, appName = 'proto_app', repoUrl,
199+
}) => (dispatch) => {
200+
if (genOption === 0) {
201+
dispatch(exportFiles({ path, components }));
202+
} else if (genOption) {
203+
dispatch({
204+
type: CREATE_APPLICATION,
205+
});
206+
createApplicationUtil({
207+
path, appName, genOption, repoUrl,
208+
})
209+
.then(() => {
210+
dispatch({
211+
type: CREATE_APPLICATION_SUCCESS,
212+
});
213+
dispatch(exportFiles({ path: `${path}/${appName}`, components }));
214+
})
215+
.catch(err => dispatch({
216+
type: CREATE_APPLICATION_ERROR,
217+
payload: { status: true, err },
218+
}));
219+
}
220+
};
221221

222222
export const openExpansionPanel = component => ({
223223
type: OPEN_EXPANSION_PANEL,

src/components/MainContainerHeader.jsx

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
2+
// import PropTypes from 'prop-types';
33
import Button from '@material-ui/core/Button';
44
import ZoomInIcon from '@material-ui/icons/ZoomIn';
55
import ZoomOutIcon from '@material-ui/icons/ZoomOut';
@@ -46,10 +46,9 @@ const styles = () => ({
4646
},
4747
});
4848

49+
4950
const MainContainerHeader = (props) => {
5051
const {
51-
increaseHeight,
52-
decreaseHeight,
5352
classes,
5453
image,
5554
showImageDeleteModal,
@@ -62,32 +61,6 @@ const MainContainerHeader = (props) => {
6261

6362
return (
6463
<div className="main-header">
65-
<div className="main-header-buttons" style={{ marginRight: 'auto' }}>
66-
<Tooltip title="zoom in">
67-
<div>
68-
<Button
69-
disabled={!image}
70-
color="default"
71-
className={classes.button}
72-
onClick={increaseHeight}
73-
>
74-
<ZoomInIcon className={classes.light} />
75-
</Button>
76-
</div>
77-
</Tooltip>
78-
<Tooltip title="zoom out">
79-
<div>
80-
<Button
81-
disabled={!image}
82-
color="default"
83-
className={classes.button}
84-
onClick={decreaseHeight}
85-
>
86-
<ZoomOutIcon className={classes.light} />
87-
</Button>
88-
</div>
89-
</Tooltip>
90-
</div>
9164
<div className="main-header-buttons">
9265
<Tooltip title="remove image">
9366
<div>
@@ -120,32 +93,23 @@ const MainContainerHeader = (props) => {
12093
</Button>
12194
</div>
12295
</Tooltip>
123-
<div>
124-
<Button color="default" className={classes.button} onClick={() => collapseColumn()}>
125-
{rightColumnOpen ? (
126-
<KeyboardArrowRightIcon className={classes.light} />
127-
) : (
128-
<KeyboardArrowLeftIcon className={classes.light} />
129-
)}
130-
</Button>
131-
</div>
13296
</div>
13397
</div>
13498
);
13599
};
136100

137-
MainContainerHeader.propTypes = {
138-
image: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
139-
classes: PropTypes.object.isRequired,
140-
increaseHeight: PropTypes.func.isRequired,
141-
decreaseHeight: PropTypes.func.isRequired,
142-
showImageDeleteModal: PropTypes.func.isRequired,
143-
updateImage: PropTypes.func.isRequired,
144-
showGenerateAppModal: PropTypes.func.isRequired,
145-
totalComponents: PropTypes.number.isRequired,
146-
collapseColumn: PropTypes.func.isRequired,
147-
rightColumnOpen: PropTypes.bool.isRequired,
148-
toggleClass: PropTypes.bool.isRequired,
149-
};
101+
// MainContainerHeader.propTypes = {
102+
// image: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
103+
// classes: PropTypes.object.isRequired,
104+
// increaseHeight: PropTypes.func.isRequired,
105+
// decreaseHeight: PropTypes.func.isRequired,
106+
// showImageDeleteModal: PropTypes.func.isRequired,
107+
// updateImage: PropTypes.func.isRequired,
108+
// showGenerateAppModal: PropTypes.func.isRequired,
109+
// totalComponents: PropTypes.number.isRequired,
110+
// collapseColumn: PropTypes.func.isRequired,
111+
// rightColumnOpen: PropTypes.bool.isRequired,
112+
// toggleClass: PropTypes.bool.isRequired,
113+
// };
150114

151115
export default withStyles(styles)(MainContainerHeader);

src/components/SimpleModal.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ const SimpleModal = (props) => {
8686
);
8787
};
8888

89-
SimpleModal.propTypes = {
90-
open: PropTypes.bool.isRequired,
91-
classes: PropTypes.object.isRequired,
92-
secBtnAction: PropTypes.func,
93-
closeModal: PropTypes.func.isRequired,
94-
primBtnAction: PropTypes.func,
95-
children: PropTypes.object,
96-
message: PropTypes.string,
97-
primBtnLabel: PropTypes.string,
98-
secBtnLabel: PropTypes.string,
99-
};
89+
// SimpleModal.propTypes = {
90+
// open: PropTypes.bool.isRequired,
91+
// classes: PropTypes.object.isRequired,
92+
// secBtnAction: PropTypes.func,
93+
// closeModal: PropTypes.func.isRequired,
94+
// primBtnAction: PropTypes.func,
95+
// children: PropTypes.object,
96+
// message: PropTypes.string,
97+
// primBtnLabel: PropTypes.string,
98+
// secBtnLabel: PropTypes.string,
99+
// };
100100

101101
export default withStyles(styles)(SimpleModal);

src/containers/LeftContainer.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class LeftContainer extends Component {
138138
/>
139139
));
140140

141+
141142
return (
142143
<div className="column left">
143144
<Grid container spacing={16} alignItems="baseline" align="stretch">

0 commit comments

Comments
 (0)