Skip to content

Commit 1e9ba05

Browse files
authored
Merge pull request #33 from tonyito/mvp
Added functionality to edit component name
2 parents 8505b24 + 7b150f7 commit 1e9ba05

File tree

12 files changed

+356
-186
lines changed

12 files changed

+356
-186
lines changed

main.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const {
66
Menu,
77
shell,
88
dialog,
9-
ipcMain
9+
ipcMain,
10+
globalShortcut
1011
} = require('electron');
1112

1213
// Uncomment below for hot reloading during development
@@ -41,6 +42,10 @@ function openFile() {
4142
mainWindow.webContents.send('new-file', file);
4243
}
4344

45+
function escape() {
46+
mainWindow.webContents.send('escape');
47+
}
48+
4449
//functions to replace the default behavior of undo and redo
4550
function undo() {
4651
mainWindow.webContents.send('undo');
@@ -262,6 +267,9 @@ app.on('ready', () => {
262267
} else {
263268
createWindow();
264269
}
270+
globalShortcut.register('Escape', () => {
271+
escape();
272+
})
265273
});
266274

267275
// Quit when all windows are closed.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"dependencies": {
9393
"@material-ui/core": "^4.2.1",
9494
"@material-ui/icons": "^4.0.1",
95-
"@material-ui/styles": "^4.9.0",
95+
"@material-ui/styles": "^4.9.6",
9696
"@types/prettier": "^1.19.0",
9797
"@types/react": "^16.8.14",
9898
"@types/react-dom": "^16.8.4",
@@ -104,6 +104,7 @@
104104
"cli-spinner": "^0.2.8",
105105
"commander": "^2.17.1",
106106
"concurrently": "^5.1.0",
107+
"csstype": "^2.6.9",
107108
"d3": "^5.9.2",
108109
"electron-reload": "^1.4.0",
109110
"enzyme": "^3.4.1",
@@ -129,7 +130,6 @@
129130
},
130131
"devDependencies": {
131132
"@babel/preset-typescript": "^7.3.3",
132-
"@material-ui/styles": "^4.9.6",
133133
"awesome-typescript-loader": "^5.2.1",
134134
"babel-core": "^6.26.3",
135135
"babel-eslint": "^8.2.6",

src/actionTypes/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ export const TOGGLE_STATE: string = 'TOGGLE_STATE';
3333
export const TOGGLE_CLASS: string = 'TOGGLE_CLASS';
3434
export const CHANGE_TUTORIAL: string = 'CHANGE_TUTORIAL';
3535
export const UNDO: string = 'UNDO';
36-
export const REDO: string = 'REDO';
36+
export const REDO: string = 'REDO';
37+
export const EDIT_MODE: string = 'EDIT_MODE';
38+
export const EDIT_COMPONENT: string = 'EDIT_COMPONENT';

src/actions/components.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import {
3636
CHANGE_TUTORIAL,
3737
UNDO,
3838
REDO,
39+
EDIT_MODE,
40+
EDIT_COMPONENT
3941
} from '../actionTypes/index';
4042

4143
import { loadState } from '../localStorage'; //this is a warning from 'localStorage' being a .js file instead of .ts. Convert to .ts to remove this warning.
@@ -273,24 +275,23 @@ export const deleteProp = (propId: number) => (
273275
dispatch({ type: DELETE_PROP, payload: propId });
274276
};
275277

276-
export const toggleComponentState = (id: string) => (
278+
export const toggleComponentState = ({ id }: { id: number }) => (
277279
dispatch: (arg: Action) => void
278280
) => {
279-
dispatch({ type: TOGGLE_STATE, payload: id });
281+
dispatch({ type: TOGGLE_STATE, payload: { id } });
280282
};
281283

282-
export const toggleComponentClass = (id: string) => (
284+
export const toggleComponentClass = ({ id }: { id: number }) => (
283285
dispatch: (arg: Action) => void
284286
) => {
285-
dispatch({ type: TOGGLE_CLASS, payload: id });
287+
dispatch({ type: TOGGLE_CLASS, payload: { id } });
286288
};
287289

288290
export const addProp = (prop: PropInt) => ({
289291
type: ADD_PROP,
290292
payload: { ...prop },
291293
});
292294

293-
294295
//action creators for undo and redo
295296
export const undo = () => ({
296297
type: UNDO,
@@ -300,6 +301,19 @@ export const redo = () => ({
300301
type: REDO,
301302
});
302303

304+
export const toggleEditMode = ({ id }: { id: number }) => (
305+
dispatch: (arg: Action) => void
306+
) => {
307+
dispatch({ type: EDIT_MODE, payload: { id } });
308+
};
309+
310+
export const editComponent = ({ id, title }: { id: number, title: string }) => (
311+
dispatch: (arg: Action) => void
312+
) => {
313+
dispatch({ type: EDIT_COMPONENT , payload: { id, title } });
314+
};
315+
316+
303317
export const updateHtmlAttr = ({
304318
attr,
305319
value,

0 commit comments

Comments
 (0)