Skip to content

Commit 9653b40

Browse files
Merge pull request #13 from tolgamizrakci/development
Development
2 parents 0db08b3 + 3001cc6 commit 9653b40

14 files changed

+97
-66
lines changed

src/actions/components.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import {
2727

2828
import { loadState } from '../localStorage';
2929

30-
import createFiles from '../utils/createFiles.util';
31-
import createApplicationUtil from '../utils/createApplication.util';
30+
// import createFiles from '../utils/createFiles.util';
31+
// import createApplicationUtil from '../utils/createApplication.util';
3232

3333
export const loadInitData = () => (dispatch) => {
3434
loadState()
@@ -60,7 +60,7 @@ export const parentReassignment = (({ index, id, parentIds }) => ({
6060

6161
export const addComponent = ({ title }) => (dispatch) => {
6262
dispatch({ type: ADD_COMPONENT, payload: { title } });
63-
dispatch({ type: SET_SELECTABLE_PARENTS });
63+
// dispatch({ type: SET_SELECTABLE_PARENTS });
6464
};
6565

6666
export const addChild = ({ title }) => (dispatch) => {
@@ -167,10 +167,10 @@ export const toggleDragging = status => ({
167167
// payload: componentId,
168168
// });
169169

170-
// export const openExpansionPanel = component => ({
171-
// type: OPEN_EXPANSION_PANEL,
172-
// payload: { component },
173-
// });
170+
export const openExpansionPanel = component => ({
171+
type: OPEN_EXPANSION_PANEL,
172+
payload: { component },
173+
});
174174

175175
// export const deleteAllData = () => ({
176176
// type: DELETE_ALL_DATA,

src/components/App.tsx renamed to src/components/App.jsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ import React, { Component } from 'react';
22
import '../public/styles/style.css';
33
import { MuiThemeProvider } from '@material-ui/core/styles';
44
import theme from './theme';
5-
import AppContainer from '../containers/AppContainer.tsx';
5+
import AppContainer from '../containers/AppContainer.jsx';
66

7-
interface Adam {
8-
goodguy: boolean;
9-
haswine: boolean;
10-
}
7+
// interface Adam {
8+
// goodguy: boolean;
9+
// haswine: boolean;
10+
// }
1111

1212
class App extends Component {
1313
render() {
14-
const adamInstance: Adam = {
15-
goodguy: true,
16-
haswine: false,
17-
};
18-
console.log(adamInstance);
14+
// const adamInstance: Adam = {
15+
// goodguy: true,
16+
// haswine: false,
17+
// };
1918
return (
2019
<MuiThemeProvider theme={theme}>
2120
<div className="app">

src/components/KonvaStage.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React, { Component, createRef } from 'react';
33
import {
44
Stage, Layer, Image, Group,
55
} from 'react-konva';
6-
import TransformerComponent from './TransformerComponent.tsx';
7-
import Rectangle from './Rectangle.tsx';
6+
import TransformerComponent from './TransformerComponent.jsx';
7+
import Rectangle from './Rectangle.jsx';
88

99

1010
class KonvaStage extends Component {

src/components/LeftColExpansionPanel.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const LeftColExpansionPanel = (props) => {
4343
style={{ color, float: 'right' }}
4444
onClick={() => {
4545
console.log(title);
46-
addChild(title);
46+
addChild( { title } );
4747
}}
4848
/>
4949
</IconButton>

src/components/Rectangle.tsx renamed to src/components/Rectangle.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import { Rect } from 'react-konva';
3-
import PropTypes from 'prop-types';
3+
// import PropTypes from 'prop-types';
44

55
class Rectangle extends Component {
66
extractPositionInfo(componentId, target) {
@@ -40,16 +40,16 @@ class Rectangle extends Component {
4040
}
4141
}
4242

43-
Rectangle.propTypes = {
44-
// title: PropTypes.string.isRequired,
45-
color: PropTypes.string.isRequired,
46-
handleTransform: PropTypes.func.isRequired,
47-
x: PropTypes.number,
48-
y: PropTypes.number,
49-
height: PropTypes.number,
50-
width: PropTypes.number,
51-
componentId: PropTypes.string.isRequired,
52-
draggable: PropTypes.bool.isRequired,
53-
};
43+
// Rectangle.propTypes = {
44+
// // title: PropTypes.string.isRequired,
45+
// color: PropTypes.string.isRequired,
46+
// handleTransform: PropTypes.func.isRequired,
47+
// x: PropTypes.number,
48+
// y: PropTypes.number,
49+
// height: PropTypes.number,
50+
// width: PropTypes.number,
51+
// componentId: PropTypes.string.isRequired,
52+
// draggable: PropTypes.bool.isRequired,
53+
// };
5454

5555
export default Rectangle;

src/components/TransformerComponent.tsx renamed to src/components/TransformerComponent.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import { Transformer } from 'react-konva';
3-
import PropTypes from 'prop-types';
3+
// import PropTypes from 'prop-types';
44

55
export default class TransformerComponent extends Component {
66
componentDidMount() {
@@ -40,6 +40,6 @@ export default class TransformerComponent extends Component {
4040
}
4141
}
4242

43-
TransformerComponent.propTypes = {
44-
focusComponent: PropTypes.object,
45-
};
43+
// TransformerComponent.propTypes = {
44+
// focusComponent: PropTypes.object,
45+
// };

src/components/__tests__/App.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
// import '../../setupTests';
33
import { shallow } from 'enzyme';
4-
import App from '../App.tsx';
4+
import App from '../App.jsx';
55
import AppContainer from '../../containers/AppContainer.jsx';
66

77
it('contains a AppContainer', () => {

src/containers/AppContainer.tsx renamed to src/containers/AppContainer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { connect } from 'react-redux';
44
import { MuiThemeProvider } from '@material-ui/core/styles';
55
import LinearProgress from '@material-ui/core/LinearProgress';
66
import LeftContainer from './LeftContainer.jsx';
7-
import MainContainer from './MainContainer.tsx';
8-
import RightContainer from './RightContainer.tsx';
7+
import MainContainer from './MainContainer.jsx';
8+
import RightContainer from './RightContainer.jsx';
99
import convertIdsToObjs from '../utils/convertIdsToObjs.util';
1010
import theme from '../components/theme';
1111
import { loadInitData } from '../actions/components';
File renamed without changes.
File renamed without changes.

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'babel-polyfill';
22
import React from 'react';
33
import ReactDOM from 'react-dom';
44
import { Provider } from 'react-redux';
5-
import App from './components/App.tsx';
5+
import App from './components/App.jsx';
66
import store from './store';
77

88
ReactDOM.render(

src/reducers/componentReducer.ts renamed to src/reducers/componentReducer.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ import {
4545
deleteProp,
4646
} from '../utils/componentReducer.util';
4747

48-
interface Child {
49-
childId: number;
50-
componentRef: number; // references the component this child instance belongs to
51-
position: object;
52-
}
48+
// interface Child {
49+
// childId: number;
50+
// componentRef: number; // references the component this child instance belongs to
51+
// position: object;
52+
// }
5353

54-
interface Component {
55-
componentId: number;
56-
title: string;
57-
childrenArray: Child[];
58-
nextChildId: number;
59-
focusChild: Component;
60-
}
54+
// interface Component {
55+
// componentId: number;
56+
// title: string;
57+
// childrenArray: Child[];
58+
// nextChildId: number;
59+
// focusChild: Component;
60+
// }
6161

6262
const appComponent = {
6363
id: '1',

src/reducers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { combineReducers } from 'redux';
22

3-
import componentReducer from './componentReducer.ts';
3+
import componentReducer from './componentReducer.js';
44

55
const reducers = combineReducers({
66
workspace: componentReducer,

src/utils/componentReducer.util.js

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,23 @@ const initialComponentState = {
1919
width: 50,
2020
height: 50,
2121
},
22+
23+
childrenArray: [],
24+
nextChildId: 1,
25+
focusChild: null,
2226
};
2327

28+
const initialChildState = {
29+
childId: 0,
30+
componentName: null,
31+
position: {
32+
x: 110,
33+
y: 120,
34+
width: 50,
35+
height: 50,
36+
}
37+
}
38+
2439
export const addComponent = (state, { title }) => {
2540
const strippedTitle = title
2641
.replace(/[a-z]+/gi,
@@ -50,32 +65,49 @@ export const addComponent = (state, { title }) => {
5065
};
5166
};
5267

68+
// get title (aka the class associated with the new child)
69+
// get the focus component (aka the component were adding the child to)
70+
5371
export const addChild = (state, { title }) => {
5472
const strippedTitle = title
5573
.replace(/[a-z]+/gi,
5674
word => word[0].toUpperCase() + word.slice(1))
5775
.replace(/[-_\s0-9\W]+/gi, '');
58-
const newComponent = {
59-
...initialComponentState,
60-
title: strippedTitle,
61-
id: state.nextId.toString(),
62-
color: getColor(),
76+
77+
let view = state.components.filter((comp) => {if (comp.title === state.focusComponent.title) return comp})[0];
78+
79+
console.log(view)
80+
81+
const newChild = {
82+
childId: view.nextChildId.toString(),
83+
componentName: strippedTitle,
84+
position: {
85+
x: 110,
86+
y: 120,
87+
width: 50,
88+
height: 50,
89+
}
90+
};
91+
92+
const compsChildrenArr = [
93+
...view.childrenArray,
94+
newChild
95+
]
96+
97+
const component = {
98+
...view,
99+
childrenArray: compsChildrenArr,
100+
nextChildId: view.nextChildId + 1,
63101
};
64102

65103
const components = [
66-
...state.components,
67-
newComponent,
104+
...state.components.filter((comp) => {if (comp.title !== view.title) return comp}),
105+
component,
68106
];
69107

70-
const totalComponents = state.totalComponents + 1;
71-
const nextId = state.nextId + 1;
72-
73108
return {
74109
...state,
75-
totalComponents,
76-
nextId,
77110
components,
78-
focusComponent: newComponent,
79111
};
80112
};
81113

0 commit comments

Comments
 (0)