Skip to content

Commit 723ca2a

Browse files
Tolga MizrakciTolga Mizrakci
authored andcommitted
focus component working waiting to merge with Christian
1 parent 3001cc6 commit 723ca2a

File tree

9 files changed

+138
-16
lines changed

9 files changed

+138
-16
lines changed

main.js

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

10+
require('electron-reload')(__dirname);
11+
1012
// const isDev = true;
1113
const isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
1214

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"cli-spinner": "^0.2.8",
8686
"commander": "^2.17.1",
8787
"electron": "^2.0.7",
88+
"electron-reload": "^1.4.0",
8889
"enzyme": "^3.4.1",
8990
"konva": "^2.1.7",
9091
"localforage": "^1.7.2",

src/actionTypes/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const ADD_COMPONENT = 'ADD_COMPONENT';
33
export const ADD_CHILD = 'ADD_CHILD';
44
export const UPDATE_COMPONENT = 'UPDATE_COMPONENT';
55
export const DELETE_COMPONENT = 'DELETE_COMPONENT';
6+
export const CHANGE_FOCUS_COMPONENT = 'CHANGE_FOCUS_COMPONENT';
67
export const UPDATE_CHILDREN = 'UPDATE_CHILDREN';
78
export const REASSIGN_PARENT = 'REASSIGN_PARENT';
89
export const SET_SELECTABLE_PARENTS = 'SET_SELECTABLE_PARENTS';

src/actions/components.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ADD_CHILD,
55
UPDATE_COMPONENT,
66
DELETE_COMPONENT,
7+
CHANGE_FOCUS_COMPONENT,
78
UPDATE_CHILDREN,
89
REASSIGN_PARENT,
910
SET_SELECTABLE_PARENTS,
@@ -97,6 +98,10 @@ export const updateComponent = ({
9798
dispatch({ type: SET_SELECTABLE_PARENTS });
9899
};
99100

101+
export const changeFocusComponent = ({ title }) => (dispatch) => {
102+
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title } });
103+
};
104+
100105
// export const exportFiles = ({ components, path }) => (dispatch) => {
101106
// dispatch({
102107
// type: EXPORT_FILES,

src/components/LeftColExpansionPanel.jsx

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Fragment } from 'react';
2-
import PropTypes from 'prop-types';
2+
// import PropTypes from 'prop-types';
33
import { withStyles } from '@material-ui/core/styles';
44
// import ExpansionPanel from '@material-ui/core/ExpansionPanel';
55
// import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
@@ -14,18 +14,32 @@ import ListItemText from '@material-ui/core/ListItemText';
1414
import IconButton from '@material-ui/core/IconButton';
1515
import Grid from '@material-ui/core/Grid';
1616
import AddIcon from '@material-ui/icons/Add';
17+
import { openExpansionPanel } from '../utils/componentReducer.util';
18+
import { changeFocusChild } from '../actions/components';
1719

1820
const LeftColExpansionPanel = (props) => {
1921
const {
2022
index, classes, focusComponent, component, deleteComponent, addChild,
21-
} = props;
23+
changeFocusComponent } = props;
2224
const { title, id, color } = component;
2325

2426
return (
2527
<div className={classes.root}>
26-
<Grid item xs={12} md={6}>
27-
<List>
28-
<ListItem button component="a">
28+
<Grid item xs={12} md={6} style={{color: 'red'}}>
29+
<List
30+
style={{color: 'red'}}
31+
>
32+
<ListItem button component="a"
33+
// style={
34+
// if (components.find(comp => comp.title === focusComponent.title))
35+
// }
36+
style={{color: 'red'}}
37+
onClick={()=> {
38+
console.log({ title })
39+
changeFocusComponent({ title })
40+
41+
}}
42+
>
2943
<ListItemText
3044
disableTypography
3145
className={classes.light}
@@ -44,6 +58,7 @@ const LeftColExpansionPanel = (props) => {
4458
onClick={() => {
4559
console.log(title);
4660
addChild( { title } );
61+
changeFocusChild( { title } );
4762
}}
4863
/>
4964
</IconButton>
@@ -90,15 +105,15 @@ export default withStyles(styles)(LeftColExpansionPanel);
90105
</div>
91106
*/
92107

93-
LeftColExpansionPanel.propTypes = {
94-
classes: PropTypes.object.isRequired,
95-
component: PropTypes.object,
96-
index: PropTypes.number,
97-
focusComponent: PropTypes.object.isRequired,
98-
onExpansionPanelChange: PropTypes.func,
99-
updateComponent: PropTypes.func,
100-
deleteComponent: PropTypes.func,
101-
};
108+
// LeftColExpansionPanel.propTypes = {
109+
// classes: PropTypes.object.isRequired,
110+
// component: PropTypes.object,
111+
// index: PropTypes.number,
112+
// focusComponent: PropTypes.object.isRequired,
113+
// onExpansionPanelChange: PropTypes.func,
114+
// updateComponent: PropTypes.func,
115+
// deleteComponent: PropTypes.func,
116+
// };
102117

103118
function styles(theme) {
104119
return {

src/containers/LeftContainer.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const mapDispatchToProps = dispatch => ({
3131
// openExpansionPanel: component => dispatch(actions.openExpansionPanel(component)),
3232
// deleteAllData: () => dispatch(actions.deleteAllData()),
3333
addChild: ({ title }) => dispatch(actions.addChild({ title })),
34+
changeFocusComponent: ({ title }) => dispatch(actions.changeFocusComponent({ title })),
35+
changeFocusChild: ({ title }) => dispatch(actions.changeFocusChild({ title })),
3436
});
3537

3638
class LeftContainer extends Component {
@@ -46,6 +48,7 @@ class LeftContainer extends Component {
4648

4749
handleAddComponent = () => {
4850
this.props.addComponent({ title: this.state.componentName });
51+
this.props.changeFocusChild({ title: this.state.componentName })
4952
this.setState({
5053
componentName: '',
5154
});
@@ -60,6 +63,7 @@ class LeftContainer extends Component {
6063
totalComponents,
6164
classes,
6265
addChild,
66+
changeFocusComponent,
6367
} = this.props;
6468
const { componentName } = this.state;
6569

@@ -72,6 +76,7 @@ class LeftContainer extends Component {
7276
component={component}
7377
focusComponent={focusComponent}
7478
addChild={addChild}
79+
changeFocusComponent={changeFocusComponent}
7580
/>
7681
));
7782

src/reducers/componentReducer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ADD_CHILD,
55
UPDATE_COMPONENT,
66
DELETE_COMPONENT,
7+
CHANGE_FOCUS_COMPONENT,
78
UPDATE_CHILDREN,
89
REASSIGN_PARENT,
910
SET_SELECTABLE_PARENTS,
@@ -29,6 +30,7 @@ import {
2930
addChild,
3031
updateComponent,
3132
deleteComponent,
33+
changeFocusComponent,
3234
updateChildren,
3335
reassignParent,
3436
setSelectableP,
@@ -114,6 +116,8 @@ const componentReducer = (state = initialApplicationState, action) => {
114116
return updateComponent(state, action.payload);
115117
case DELETE_COMPONENT:
116118
return deleteComponent(state, action.payload);
119+
case CHANGE_FOCUS_COMPONENT:
120+
return changeFocusComponent(state, action.payload);
117121
case UPDATE_CHILDREN:
118122
return updateChildren(state, action.payload);
119123
case REASSIGN_PARENT:

src/utils/componentReducer.util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ export const deleteComponent = (state, { index, id }) => {
163163
};
164164
};
165165

166+
export const changeFocusComponent = (state, { title }) => {
167+
168+
let focusComp = state.components.filter((comp) => {if (comp.title === title) return comp})[0]
169+
170+
return {
171+
...state,
172+
focusComponent: focusComp,
173+
};
174+
};
175+
166176
// Add or remove children
167177
export const updateChildren = ((state, { parentIds, childId }) => {
168178
const components = state.components.map((component) => {

yarn.lock

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ async-each@^1.0.0:
687687
version "1.0.1"
688688
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d"
689689

690+
async-each@^1.0.1:
691+
version "1.0.3"
692+
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf"
693+
integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==
694+
690695
async-exit-hook@^2.0.1:
691696
version "2.0.1"
692697
resolved "https://registry.yarnpkg.com/async-exit-hook/-/async-exit-hook-2.0.1.tgz#8bd8b024b0ec9b1c01cccb9af9db29bd717dfaf3"
@@ -1618,7 +1623,7 @@ braces@^1.8.2:
16181623
preserve "^0.2.0"
16191624
repeat-element "^1.1.2"
16201625

1621-
braces@^2.3.0, braces@^2.3.1:
1626+
braces@^2.3.0, braces@^2.3.1, braces@^2.3.2:
16221627
version "2.3.2"
16231628
resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729"
16241629
dependencies:
@@ -1979,6 +1984,25 @@ chokidar@^2.0.2:
19791984
optionalDependencies:
19801985
fsevents "^1.2.2"
19811986

1987+
chokidar@^2.0.4:
1988+
version "2.1.5"
1989+
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.5.tgz#0ae8434d962281a5f56c72869e79cb6d9d86ad4d"
1990+
integrity sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A==
1991+
dependencies:
1992+
anymatch "^2.0.0"
1993+
async-each "^1.0.1"
1994+
braces "^2.3.2"
1995+
glob-parent "^3.1.0"
1996+
inherits "^2.0.3"
1997+
is-binary-path "^1.0.0"
1998+
is-glob "^4.0.0"
1999+
normalize-path "^3.0.0"
2000+
path-is-absolute "^1.0.0"
2001+
readdirp "^2.2.1"
2002+
upath "^1.1.1"
2003+
optionalDependencies:
2004+
fsevents "^1.2.7"
2005+
19822006
chownr@^1.0.1:
19832007
version "1.0.1"
19842008
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181"
@@ -2946,6 +2970,13 @@ [email protected]:
29462970
lazy-val "^1.0.3"
29472971
mime "^2.3.1"
29482972

2973+
electron-reload@^1.4.0:
2974+
version "1.4.0"
2975+
resolved "https://registry.yarnpkg.com/electron-reload/-/electron-reload-1.4.0.tgz#00154268c936fa17b496fdb1728434c747e1d29a"
2976+
integrity sha512-pluNocZ9LqIeKmUzUSEHa+vT1+dG5923zXez4iwEhWqC2hydALPKvu+kJJzkdYRJv5z15S8waDthyrMyKd5MCQ==
2977+
dependencies:
2978+
chokidar "^2.0.4"
2979+
29492980
electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.47, electron-to-chromium@^1.3.57:
29502981
version "1.3.58"
29512982
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.58.tgz#8267a4000014e93986d9d18c65a8b4022ca75188"
@@ -3734,6 +3765,14 @@ fsevents@^1.2.2, fsevents@^1.2.3:
37343765
nan "^2.9.2"
37353766
node-pre-gyp "^0.10.0"
37363767

3768+
fsevents@^1.2.7:
3769+
version "1.2.8"
3770+
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.8.tgz#57ea5320f762cd4696e5e8e87120eccc8b11cacf"
3771+
integrity sha512-tPvHgPGB7m40CZ68xqFGkKuzN+RnpGmSV+hgeKxhRpbxdqKXUFJGC3yonBOLzQBcJyGpdZFDfCsdOC2KFsXzeA==
3772+
dependencies:
3773+
nan "^2.12.1"
3774+
node-pre-gyp "^0.12.0"
3775+
37373776
fstream@^1.0.0, fstream@^1.0.2:
37383777
version "1.0.11"
37393778
resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171"
@@ -5624,7 +5663,7 @@ micromatch@^2.3.11:
56245663
parse-glob "^3.0.4"
56255664
regex-cache "^0.4.2"
56265665

5627-
micromatch@^3.0.4, micromatch@^3.1.4, micromatch@^3.1.8, micromatch@^3.1.9:
5666+
micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8, micromatch@^3.1.9:
56285667
version "3.1.10"
56295668
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
56305669
dependencies:
@@ -5784,6 +5823,11 @@ nan@^2.10.0, nan@^2.3.2, nan@^2.4.0, nan@^2.9.2:
57845823
version "2.10.0"
57855824
resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
57865825

5826+
nan@^2.12.1:
5827+
version "2.13.2"
5828+
resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7"
5829+
integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==
5830+
57875831
nanomatch@^1.2.9:
57885832
version "1.2.13"
57895833
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@@ -5927,6 +5971,22 @@ node-pre-gyp@^0.10.0:
59275971
semver "^5.3.0"
59285972
tar "^4"
59295973

5974+
node-pre-gyp@^0.12.0:
5975+
version "0.12.0"
5976+
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz#39ba4bb1439da030295f899e3b520b7785766149"
5977+
integrity sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==
5978+
dependencies:
5979+
detect-libc "^1.0.2"
5980+
mkdirp "^0.5.1"
5981+
needle "^2.2.1"
5982+
nopt "^4.0.1"
5983+
npm-packlist "^1.1.6"
5984+
npmlog "^4.0.2"
5985+
rc "^1.2.7"
5986+
rimraf "^2.6.1"
5987+
semver "^5.3.0"
5988+
tar "^4"
5989+
59305990
node-releases@^1.0.0-alpha.11:
59315991
version "1.0.0-alpha.11"
59325992
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.0.0-alpha.11.tgz#73c810acc2e5b741a17ddfbb39dfca9ab9359d8a"
@@ -5992,6 +6052,11 @@ normalize-path@^2.0.1, normalize-path@^2.1.1:
59926052
dependencies:
59936053
remove-trailing-separator "^1.0.1"
59946054

6055+
normalize-path@^3.0.0:
6056+
version "3.0.0"
6057+
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
6058+
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
6059+
59956060
normalize-range@^0.1.2:
59966061
version "0.1.2"
59976062
resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942"
@@ -7241,6 +7306,15 @@ readdirp@^2.0.0:
72417306
readable-stream "^2.0.2"
72427307
set-immediate-shim "^1.0.1"
72437308

7309+
readdirp@^2.2.1:
7310+
version "2.2.1"
7311+
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525"
7312+
integrity sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==
7313+
dependencies:
7314+
graceful-fs "^4.1.11"
7315+
micromatch "^3.1.10"
7316+
readable-stream "^2.0.2"
7317+
72447318
realpath-native@^1.0.0:
72457319
version "1.0.1"
72467320
resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.0.1.tgz#07f40a0cce8f8261e2e8b7ebebf5c95965d7b633"
@@ -8453,6 +8527,11 @@ upath@^1.0.5:
84538527
version "1.1.0"
84548528
resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.0.tgz#35256597e46a581db4793d0ce47fa9aebfc9fabd"
84558529

8530+
upath@^1.1.1:
8531+
version "1.1.2"
8532+
resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.2.tgz#3db658600edaeeccbe6db5e684d67ee8c2acd068"
8533+
integrity sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==
8534+
84568535
update-notifier@^2.5.0:
84578536
version "2.5.0"
84588537
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.5.0.tgz#d0744593e13f161e406acb1d9408b72cad08aff6"

0 commit comments

Comments
 (0)