Skip to content

Commit 1d6dce6

Browse files
Merge pull request #64 from ChristianEdwardPadilla/development
Props styling changes, fixed export modal, bad color removed
2 parents 8a20462 + 9fe7240 commit 1d6dce6

File tree

10 files changed

+90
-76
lines changed

10 files changed

+90
-76
lines changed

src/actionTypes/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ export const ADD_PROP = 'ADD_PROP';
2626
export const DELETE_ALL_DATA = 'DELETE_ALL_DATA';
2727
export const CHANGE_IMAGE_PATH = 'CHANGE_IMAGE_PATH';
2828
export const UPDATE_HTML_ATTR = 'UPDATE_HTML_ATTR';
29-
export const GENERATE_COMPONENT_TREE = 'GENERATE_COMPONENT_TREE';

src/components/KonvaStage.tsx

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@ class KonvaStage extends Component {
1010
this.state = {
1111
stageWidth: 1000,
1212
stageHeight: 1000,
13-
blockSnapSize: 5,
13+
blockSnapSize: 10,
1414
grid: [],
1515
gridStroke: 1,
1616
};
1717
}
1818

19-
componentDidMount() {
20-
this.checkSize();
21-
// here we should add listener for "container" resize
22-
// take a look here https://developers.google.com/web/updates/2016/10/resizeobserver
23-
// for simplicity I will just listen window resize
24-
window.addEventListener('resize', this.checkSize);
25-
this.createGrid();
26-
}
27-
2819
getDirectChildrenCopy(focusComponent) {
2920
const component = this.props.components.find(comp => comp.id === focusComponent.id);
3021

@@ -49,36 +40,19 @@ class KonvaStage extends Component {
4940
return childrenArrCopy;
5041
}
5142

52-
// cloneDeep(value) {
53-
// let result;
54-
55-
// if (Array.isArray(value)) {
56-
// result = [];
57-
// value.forEach((elm) => {
58-
// if (typeof elm === 'object') {
59-
// result.push(this.cloneDeep(elm));
60-
// } else {
61-
// result.push(elm);
62-
// }
63-
// });
64-
// return result;
65-
// }
66-
// if (typeof value === 'object' && value !== null) {
67-
// result = {};
68-
// Object.keys(value).forEach((key) => {
69-
// if (typeof value[key] === 'object') {
70-
// result[key] = this.cloneDeep(value[key]);
71-
// } else {
72-
// result[key] = value[key];
73-
// }
74-
// });
75-
// return result;
76-
// }
77-
// return value;
78-
// }
43+
componentDidMount() {
44+
this.checkSize();
45+
// here we should add listener for "container" resize
46+
// take a look here https://developers.google.com/web/updates/2016/10/resizeobserver
47+
// for simplicity I will just listen window resize
48+
window.addEventListener('resize', this.checkSize);
49+
this.container.addEventListener('keydown', this.handleKeyDown);
50+
this.createGrid();
51+
}
7952

8053
componentWillUnmount() {
8154
window.removeEventListener('resize', this.checkSize);
55+
this.container.removeEventListener('keydown', this.handleKeyDown);
8256
}
8357

8458
checkSize = () => {
@@ -90,6 +64,12 @@ class KonvaStage extends Component {
9064
});
9165
};
9266

67+
handleKeyDown = e => {
68+
if (e.key === 'Delete' || e.key === 'Backspace') {
69+
this.props.deleteChild({});
70+
}
71+
};
72+
9373
handleStageMouseDown = e => {
9474
// // clicked on stage - clear selection
9575
if (e.target === e.target.getStage()) {
@@ -157,12 +137,13 @@ class KonvaStage extends Component {
157137
return (
158138
<div
159139
style={{
160-
width: '100%',
161-
height: '100%',
140+
width: '95%',
141+
height: '95%',
162142
}}
163143
ref={node => {
164144
this.container = node;
165145
}}
146+
tabIndex="0" // required for keydown event to be heard by this.container
166147
>
167148
<Button
168149
onClick={deleteChild}

src/components/Props.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Props extends Component {
109109
state = {
110110
propKey: '',
111111
propValue: '',
112-
propRequired: false,
112+
propRequired: true,
113113
propType: '',
114114
};
115115

@@ -153,7 +153,7 @@ class Props extends Component {
153153
this.setState({
154154
propKey: '',
155155
propValue: '',
156-
propRequired: false,
156+
propRequired: true,
157157
propType: '',
158158
});
159159
};
@@ -243,7 +243,7 @@ class Props extends Component {
243243
checked={this.state.propRequired}
244244
onChange={this.togglePropRequired}
245245
value="propRequired"
246-
color="secondary"
246+
color="primary"
247247
id="propRequired"
248248
/>
249249
</div>
@@ -253,7 +253,7 @@ class Props extends Component {
253253
color="primary"
254254
aria-label="Add"
255255
type="submit"
256-
disabled={!this.state.propKey || !this.state.propType}
256+
// disabled={!this.state.propKey || !this.state.propType}
257257
variant="contained"
258258
size="large"
259259
>

src/components/Rectangle.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React, { Component, Fragment } from 'react';
22
import { Rect, Group, Label, Text } from 'react-konva';
33
import TransformerComponent from './TransformerComponent.jsx';
44
import GrandchildRectangle from './GrandchildRectangle.jsx';
@@ -81,9 +81,17 @@ class Rectangle extends Component {
8181
width={width}
8282
height={height}
8383
onDragEnd={event => this.handleDrag(componentId, childId, event.target, blockSnapSize)}
84+
ref={node => {
85+
this.group = node;
86+
}}
87+
tabIndex="0" // required for keypress event to be heard by this.group
8488
>
8589
<Rect
8690
// a Konva Rect is generated for each child of the focusComponent (including the pseudochild, representing the focusComponent itself)
91+
ref={node => {
92+
this.rect = node;
93+
}}
94+
tabIndex="0" // required for keypress event to be heard by this.group
8795
name={`${childId}`}
8896
className={'childRect'}
8997
x={0}
@@ -116,7 +124,7 @@ class Rectangle extends Component {
116124
fill={childId === '-1' ? this.getComponentColor(childComponentId) : '#000000'}
117125
fontSize={childId === '-1' ? 15 : 10}
118126
x={4}
119-
y={childId === '-1' ? -15 : 5}
127+
y={childId === '-1' ? -20 : -12}
120128
/>
121129
</Label>
122130
{// for all children other than the pseudoChild, find their component's children array and recursively render the children found there

src/components/RightTabs.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class RightTabs extends Component {
180180
<Tree
181181
data={[this.findChildren(focusComponent, components, tree)]}
182182
// data={[this.generateComponentTree(focusComponent.id, components)]}
183-
separation={{ siblings: 0.2, nonSiblings: 0.3 }}
184-
transitionDuration={350}
183+
separation={{ siblings: 0.3, nonSiblings: 0.3 }}
184+
transitionDuration={0}
185185
translate={this.state.translate}
186186
styles={{
187187
nodes: {

src/components/SimpleModal.jsx

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,52 @@ const SimpleModal = (props) => {
4646
onClose={closeModal}
4747
open={open}
4848
>
49-
<div style={{
50-
top: '50%',
51-
left: '50%',
52-
transform: 'translate(-50%, -50%)',
53-
}} className={classes.paper}>
49+
<div
50+
style={{
51+
top: '50%',
52+
left: '50%',
53+
transform: 'translate(-50%, -50%)',
54+
}}
55+
className={classes.paper}
56+
>
5457
<Icon
5558
onClick={closeModal}
56-
className='closeIcon'
59+
className="closeIcon"
5760
style={{
5861
position: 'absolute',
5962
top: '2%',
6063
right: '1%',
6164
fontSize: '17px',
6265
fontWeight: 'bold',
6366
}}
64-
>close</Icon>
67+
>
68+
close
69+
</Icon>
6570
<Typography variant="title" id="modal-title">
6671
{message}
6772
</Typography>
73+
<div>{children}</div>
6874
<div>
69-
{children}
70-
</div>
71-
<div>
72-
{
73-
secBtnLabel ? <Button variant='extendedFab' color="secondary" className={classes.button} onClick={secBtnAction}>
75+
{secBtnLabel ? (
76+
<Button
77+
variant="extendedFab"
78+
color="secondary"
79+
className={classes.button}
80+
onClick={secBtnAction}
81+
>
7482
{secBtnLabel}
75-
</Button> : null
76-
}
77-
{
78-
primBtnLabel ? <Button variant='extendedFab' color="primary" className={classes.button} onClick={primBtnAction}>
83+
</Button>
84+
) : null}
85+
{primBtnLabel ? (
86+
<Button
87+
variant="extendedFab"
88+
color="primary"
89+
className={classes.button}
90+
onClick={primBtnAction}
91+
>
7992
{primBtnLabel}
80-
</Button> : null
81-
}
93+
</Button>
94+
) : null}
8295
</div>
8396
</div>
8497
</Modal>

src/containers/MainContainer.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ class MainContainer extends Component {
115115
// IPC.send('update-file');
116116
// };
117117

118+
// deleteImage = () => {
119+
// this.props.changeImagePath('');
120+
// this.setState({ image: '' });
121+
// };
122+
123+
closeModal = () => this.setState({ modal: null });
124+
125+
chooseAppDir = () => IPC.send('choose_app_dir');
126+
118127
// showImageDeleteModal = () => {
119128
// const { closeModal, deleteImage } = this;
120129
// this.setState({
@@ -149,6 +158,7 @@ class MainContainer extends Component {
149158
};
150159

151160
showGenerateAppModal = () => {
161+
console.log('clicked on export button');
152162
const { closeModal, chooseGenOptions } = this;
153163
const { genOptions } = this.state;
154164
const children = (

src/public/styles/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,7 @@ div.rst__rowContents {
269269
.rst__rowLabel {
270270
padding-right: 5px;
271271
}
272+
273+
.closeIcon:hover {
274+
cursor: pointer;
275+
}

src/utils/colors.util.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@ const colors = [
44
'#E8A87C',
55
'#C38D9E',
66
'#41B3A3',
7-
'#2F2FA2',
7+
'#D12FA2',
88
'#F64C72',
99
'#DAAD86',
1010
'#8EE4AF',
1111
'#5CDB95',
12-
'#7395AE',
13-
'#501B1D',
14-
'#190061',
12+
'#7395AE', // light grey
13+
'#b90061',
1514
'#AFD275',
1615
'#45A29E',
1716
'#D79922',
18-
'#C5CBE3',
17+
'#C5CBE3', // lightish grey
1918
'#FFCB9A',
2019
'#E98074',
2120
'#8860D0',
2221
'#5AB9EA',
2322
'#5860E9',
2423
'#84CEEB',
25-
'#F8E9A1',
2624
'#61892F',
2725
];
2826

src/utils/componentReducer.util.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ export const addChild = (state, { title, childType = '', HTMLInfo = {} }) => {
124124
const newPosition =
125125
childType === 'COMP'
126126
? {
127-
x: view.position.x + view.nextChildId * 5, // new children are offset by 5px, x and y
128-
y: view.position.y + view.nextChildId * 5,
127+
x: view.position.x + view.nextChildId * 16, // new children are offset by 5px, x and y
128+
y: view.position.y + view.nextChildId * 16,
129129
width: parentComponent.position.width * 0.9, // new children have an initial position of their CLASS (maybe don't need 90%)
130130
height: parentComponent.position.height * 0.9,
131131
}
132132
: {
133-
x: view.position.x + view.nextChildId * 5,
134-
y: view.position.y + view.nextChildId * 5,
133+
x: view.position.x + view.nextChildId * 16,
134+
y: view.position.y + view.nextChildId * 16,
135135
width: htmlElemPosition.width,
136136
height: htmlElemPosition.height,
137137
};
@@ -194,6 +194,7 @@ export const deleteChild = (
194194
return state;
195195
}
196196
if (!calledFromDeleteComponent && childId === '-1') {
197+
window.alert('Cannot delete root child of a component');
197198
return state;
198199
}
199200
// make a DEEP copy of the parent component (the one thats about to loose a child)

0 commit comments

Comments
 (0)