Skip to content

Commit ba36089

Browse files
Merge pull request #26 from tolgamizrakci/development
childcompid merged with canvas resizing fix
2 parents 264f825 + 837d84d commit ba36089

File tree

3 files changed

+162
-145
lines changed

3 files changed

+162
-145
lines changed

src/components/KonvaStage.jsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import React, { Component, createRef, Fragment } from 'react';
1+
import React, { Component, createRef, Fragment } from "react";
22
// import PropTypes from 'prop-types';
3-
import {
4-
Stage, Layer, Group, Label, Text,
5-
} from 'react-konva';
6-
import TransformerComponent from './TransformerComponent.jsx';
7-
import Rectangle from './Rectangle.jsx';
3+
import { Stage, Layer, Group, Label, Text } from "react-konva";
4+
import TransformerComponent from "./TransformerComponent.jsx";
5+
import Rectangle from "./Rectangle.jsx";
86

97
class KonvaStage extends Component {
108
state = {
119
x: undefined,
12-
y: undefined,
10+
y: undefined
1311
};
1412

1513
constructor(props) {
@@ -18,21 +16,22 @@ class KonvaStage extends Component {
1816
this.group = createRef();
1917
}
2018

21-
handleStageMouseDown = (e) => {
19+
handleStageMouseDown = e => {
2220
// // clicked on stage - clear selection
2321
if (e.target === e.target.getStage()) {
2422
// add functionality for allowing no focusChild
2523
return;
2624
}
2725
// // clicked on transformer - do nothing
28-
const clickedOnTransformer = e.target.getParent().className === 'Transformer';
26+
const clickedOnTransformer =
27+
e.target.getParent().className === "Transformer";
2928
if (clickedOnTransformer) {
3029
return;
3130
}
3231

3332
// find clicked rect by its name
3433
const rectChildId = e.target.attrs.childId;
35-
console.log('e.target : ', rectChildId);
34+
console.log("e.target : ", rectChildId);
3635
this.props.changeFocusChild({ childId: rectChildId });
3736
};
3837

@@ -50,13 +49,13 @@ class KonvaStage extends Component {
5049
scaleY,
5150
focusComponent,
5251
focusChild,
53-
changeFocusChild,
52+
changeFocusChild
5453
} = this.props;
5554
const { selectedShapeName } = this.state;
5655

5756
return (
5857
<Stage
59-
ref={(node) => {
58+
ref={node => {
6059
this.stage = node;
6160
}}
6261
onMouseDown={this.handleStageMouseDown}

src/containers/LeftContainer.jsx

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,62 @@
1-
import React, { Component } from 'react';
2-
import { connect } from 'react-redux';
3-
import { compose } from 'redux';
1+
import React, { Component } from "react";
2+
import { connect } from "react-redux";
3+
import { compose } from "redux";
44
// import PropTypes from 'prop-types';
5-
import FormControl from '@material-ui/core/FormControl';
6-
import TextField from '@material-ui/core/TextField';
7-
import Button from '@material-ui/core/Button';
8-
import AddIcon from '@material-ui/icons/Add';
9-
import Grid from '@material-ui/core/Grid';
10-
import { withStyles } from '@material-ui/core/styles';
11-
import LeftColExpansionPanel from '../components/LeftColExpansionPanel.jsx';
5+
import FormControl from "@material-ui/core/FormControl";
6+
import TextField from "@material-ui/core/TextField";
7+
import Button from "@material-ui/core/Button";
8+
import AddIcon from "@material-ui/icons/Add";
9+
import Grid from "@material-ui/core/Grid";
10+
import { withStyles } from "@material-ui/core/styles";
11+
import LeftColExpansionPanel from "../components/LeftColExpansionPanel.jsx";
1212
// import createModal from '../utils/createModal.util';
13-
import * as actions from '../actions/components';
13+
import * as actions from "../actions/components";
1414

1515
const mapDispatchToProps = dispatch => ({
1616
addComponent: ({ title }) => dispatch(actions.addComponent({ title })),
1717
updateComponent: ({
18-
id, index, newParentId = null, color = null, stateful = null,
19-
}) => dispatch(
20-
actions.updateComponent({
21-
id,
22-
index,
23-
newParentId,
24-
color,
25-
stateful,
26-
}),
27-
),
28-
deleteComponent: ({ index, id, parentIds }) => dispatch(actions.deleteComponent({ index, id, parentIds })),
18+
id,
19+
index,
20+
newParentId = null,
21+
color = null,
22+
stateful = null
23+
}) =>
24+
dispatch(
25+
actions.updateComponent({
26+
id,
27+
index,
28+
newParentId,
29+
color,
30+
stateful
31+
})
32+
),
33+
// deleteComponent: ({ index, id, parentIds }) => dispatch(actions.deleteComponent({ index, id, parentIds })),
2934
// moveToBottom: componentId => dispatch(actions.moveToBottom(componentId)),
3035
// moveToTop: componentId => dispatch(actions.moveToTop(componentId)),
3136
// openExpansionPanel: component => dispatch(actions.openExpansionPanel(component)),
3237
// deleteAllData: () => dispatch(actions.deleteAllData()),
3338
addChild: ({ title }) => dispatch(actions.addChild({ title })),
34-
changeFocusComponent: ({ title }) => dispatch(actions.changeFocusComponent({ title })),
35-
changeFocusChild: ({ title, childId }) => dispatch(actions.changeFocusChild({ title, childId })),
39+
changeFocusComponent: ({ title }) =>
40+
dispatch(actions.changeFocusComponent({ title })),
41+
changeFocusChild: ({ title, childId }) =>
42+
dispatch(actions.changeFocusChild({ title, childId }))
3643
});
3744

3845
class LeftContainer extends Component {
3946
state = {
40-
componentName: '',
47+
componentName: ""
4148
};
4249

43-
handleChange = (event) => {
50+
handleChange = event => {
4451
this.setState({
45-
[event.target.name]: event.target.value,
52+
[event.target.name]: event.target.value
4653
});
4754
};
4855

4956
handleAddComponent = () => {
5057
this.props.addComponent({ title: this.state.componentName });
5158
this.setState({
52-
componentName: '',
59+
componentName: ""
5360
});
5461
};
5562

@@ -63,7 +70,7 @@ class LeftContainer extends Component {
6370
classes,
6471
addChild,
6572
changeFocusComponent,
66-
changeFocusChild,
73+
changeFocusChild
6774
} = this.props;
6875
const { componentName } = this.state;
6976

@@ -92,8 +99,8 @@ class LeftContainer extends Component {
9299
margin="normal"
93100
autoFocus
94101
onChange={this.handleChange}
95-
onKeyPress={(ev) => {
96-
if (ev.key === 'Enter') {
102+
onKeyPress={ev => {
103+
if (ev.key === "Enter") {
97104
// Do code here
98105
this.handleAddComponent();
99106
ev.preventDefault();
@@ -103,10 +110,10 @@ class LeftContainer extends Component {
103110
name="componentName"
104111
className={classes.light}
105112
InputProps={{
106-
className: classes.input,
113+
className: classes.input
107114
}}
108115
InputLabelProps={{
109-
className: classes.input,
116+
className: classes.input
110117
}}
111118
/>
112119
</Grid>
@@ -134,8 +141,8 @@ export default compose(
134141
withStyles(styles),
135142
connect(
136143
null,
137-
mapDispatchToProps,
138-
),
144+
mapDispatchToProps
145+
)
139146
)(LeftContainer);
140147

141148
// LeftContainer.propTypes = {
@@ -155,40 +162,40 @@ export default compose(
155162
function styles() {
156163
return {
157164
cssLabel: {
158-
color: 'white',
165+
color: "white",
159166

160-
'&$cssFocused': {
161-
color: 'green',
162-
},
167+
"&$cssFocused": {
168+
color: "green"
169+
}
163170
},
164171
cssFocused: {},
165172
input: {
166-
color: '#fff',
167-
opacity: '0.7',
168-
marginBottom: '10px',
173+
color: "#fff",
174+
opacity: "0.7",
175+
marginBottom: "10px"
169176
},
170177
underline: {
171-
color: 'white',
172-
'&::before': {
173-
color: 'white',
174-
},
178+
color: "white",
179+
"&::before": {
180+
color: "white"
181+
}
175182
},
176183
button: {
177-
color: '#fff',
184+
color: "#fff",
178185

179-
'&:disabled': {
180-
color: 'grey',
181-
},
186+
"&:disabled": {
187+
color: "grey"
188+
}
182189
},
183190
clearButton: {
184-
top: '96%',
185-
position: 'sticky!important',
186-
zIndex: '1',
191+
top: "96%",
192+
position: "sticky!important",
193+
zIndex: "1",
187194

188-
'&:disabled': {
189-
color: 'grey',
190-
backgroundColor: '#424242',
191-
},
192-
},
195+
"&:disabled": {
196+
color: "grey",
197+
backgroundColor: "#424242"
198+
}
199+
}
193200
};
194201
}

0 commit comments

Comments
 (0)