Skip to content

Commit 71b1e9d

Browse files
finished ts changes to util files
1 parent 0e4c8af commit 71b1e9d

13 files changed

+616
-253
lines changed

src/actions/components.js

Lines changed: 97 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,28 @@ import {
2727
DELETE_ALL_DATA,
2828
CHANGE_IMAGE_PATH,
2929
UPDATE_HTML_ATTR,
30-
UPDATE_CHILDREN_SORT,
31-
} from '../actionTypes/index';
30+
UPDATE_CHILDREN_SORT
31+
} from "../actionTypes/index";
3232

33-
import { loadState } from '../localStorage';
33+
import { loadState } from "../localStorage";
3434

35-
import createFiles from '../utils/createFiles.util';
36-
import createApplicationUtil from '../utils/createApplication.util';
35+
import createFiles from "../utils/createFiles.util.ts";
36+
import createApplicationUtil from "../utils/createApplication.util.ts";
3737

3838
export const loadInitData = () => dispatch => {
3939
loadState().then(data =>
4040
dispatch({
4141
type: LOAD_INIT_DATA,
4242
payload: {
43+
<<<<<<< HEAD
4344
data: data ? data.workspace : {},
4445
},
4546
}),
47+
=======
48+
data: data ? data.workspace : {}
49+
}
50+
})
51+
>>>>>>> fcd32cb... finished ts changes to util files
4652
);
4753
};
4854

@@ -77,22 +83,32 @@ export const deleteChild = ({}) => dispatch => {
7783
dispatch({ type: DELETE_CHILD, payload: {} });
7884
};
7985

86+
<<<<<<< HEAD
8087
export const deleteComponent = ({ componentId, stateComponents }) => dispatch => {
88+
=======
89+
export const deleteComponent = ({
90+
componentId,
91+
stateComponents
92+
}) => dispatch => {
93+
>>>>>>> fcd32cb... finished ts changes to util files
8194
// find all places where the "to be delted" is a child and do what u gotta do
82-
stateComponents.forEach((parent) => {
83-
parent.childrenArray.filter(child => child.childComponentId === componentId).forEach((child) => {
84-
dispatch({
85-
type: DELETE_CHILD,
86-
payload: {
87-
parentId: parent.id,
88-
childId: child.childId,
89-
calledFromDeleteComponent: true,
90-
},
95+
stateComponents.forEach(parent => {
96+
parent.childrenArray
97+
.filter(child => child.childComponentId === componentId)
98+
.forEach(child => {
99+
dispatch({
100+
type: DELETE_CHILD,
101+
payload: {
102+
parentId: parent.id,
103+
childId: child.childId,
104+
calledFromDeleteComponent: true
105+
}
106+
});
91107
});
92108
});
93109

94110
// change focus to APp
95-
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: 'App' } });
111+
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: "App" } });
96112
// after taking care of the children delete the component
97113
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
98114
};
@@ -134,65 +150,108 @@ export const changeFocusComponent = ({ title }) => dispatch => {
134150

135151
// make sure childId is being sent in
136152
<<<<<<< HEAD
153+
<<<<<<< HEAD
137154
export const changeFocusChild = ({ title, childId }) => dispatch => {
138155
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { title, childId } });
139156
=======
140157
export const changeFocusChild = ({ childId }) => (dispatch) => {
158+
=======
159+
export const changeFocusChild = ({ childId }) => dispatch => {
160+
>>>>>>> fcd32cb... finished ts changes to util files
141161
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { childId } });
142162
>>>>>>> c532596... reducer cleanup, working version
143163
};
144164

165+
<<<<<<< HEAD
145166
export const changeComponentFocusChild = ({ componentId, childId }) => dispatch => {
167+
=======
168+
export const changeComponentFocusChild = ({
169+
componentId,
170+
childId
171+
}) => dispatch => {
172+
>>>>>>> fcd32cb... finished ts changes to util files
146173
dispatch({
147174
type: CHANGE_COMPONENT_FOCUS_CHILD,
148-
payload: { componentId, childId },
175+
payload: { componentId, childId }
149176
});
150177
};
151178

179+
<<<<<<< HEAD
152180
export const exportFiles = ({ components, path, appName, exportAppBool }) => dispatch => {
181+
=======
182+
export const exportFiles = ({
183+
components,
184+
path,
185+
appName,
186+
exportAppBool
187+
}) => dispatch => {
188+
>>>>>>> fcd32cb... finished ts changes to util files
153189
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
154190
dispatch({
155-
type: EXPORT_FILES,
191+
type: EXPORT_FILES
156192
});
157193

158194
createFiles(components, path, appName, exportAppBool)
159195
.then(dir =>
160196
dispatch({
161197
type: EXPORT_FILES_SUCCESS,
198+
<<<<<<< HEAD
162199
payload: { status: true, dir: dir[0] },
163200
}),
201+
=======
202+
payload: { status: true, dir: dir[0] }
203+
})
204+
>>>>>>> fcd32cb... finished ts changes to util files
164205
)
165206
.catch(err =>
166207
dispatch({
167208
type: EXPORT_FILES_ERROR,
209+
<<<<<<< HEAD
168210
payload: { status: true, err },
169211
}),
212+
=======
213+
payload: { status: true, err }
214+
})
215+
>>>>>>> fcd32cb... finished ts changes to util files
170216
);
171217
};
172218

173219
export const handleClose = () => ({
174220
type: HANDLE_CLOSE,
175-
payload: false,
221+
payload: false
176222
});
177223

224+
<<<<<<< HEAD
178225
export const handleTransform = (componentId, childId, { x, y, width, height }) => ({
226+
=======
227+
export const handleTransform = (
228+
componentId,
229+
childId,
230+
{ x, y, width, height }
231+
) => ({
232+
>>>>>>> fcd32cb... finished ts changes to util files
179233
type: HANDLE_TRANSFORM,
180234
payload: {
181235
componentId,
182236
childId,
183237
x,
184238
y,
185239
width,
186-
height,
187-
},
240+
height
241+
}
188242
});
189243

190244
export const createApplication = ({
191245
path,
192246
components = [],
193247
genOption,
248+
<<<<<<< HEAD
194249
appName = 'reactype_app',
195250
exportAppBool,
251+
=======
252+
appName = "reactype_app",
253+
exportAppBool
254+
>>>>>>> fcd32cb... finished ts changes to util files
196255
}) => dispatch => {
197256
if (genOption === 0) {
198257
exportAppBool = false;
@@ -201,48 +260,53 @@ export const createApplication = ({
201260
appName,
202261
path,
203262
components,
204-
exportAppBool,
205-
}),
263+
exportAppBool
264+
})
206265
);
207266
} else if (genOption) {
208267
dispatch({
209-
type: CREATE_APPLICATION,
268+
type: CREATE_APPLICATION
210269
});
211270
createApplicationUtil({
212271
path,
213272
appName,
214273
genOption,
215-
exportAppBool,
274+
exportAppBool
216275
})
217276
.then(() => {
218277
dispatch({
219-
type: CREATE_APPLICATION_SUCCESS,
278+
type: CREATE_APPLICATION_SUCCESS
220279
});
221280
dispatch(
222281
exportFiles({
223282
appName,
224283
path,
225284
components,
226-
exportAppBool,
227-
}),
285+
exportAppBool
286+
})
228287
);
229288
})
230289
.catch(err =>
231290
dispatch({
232291
type: CREATE_APPLICATION_ERROR,
292+
<<<<<<< HEAD
233293
payload: { status: true, err },
234294
}),
295+
=======
296+
payload: { status: true, err }
297+
})
298+
>>>>>>> fcd32cb... finished ts changes to util files
235299
);
236300
}
237301
};
238302

239303
export const openExpansionPanel = component => ({
240304
type: OPEN_EXPANSION_PANEL,
241-
payload: { component },
305+
payload: { component }
242306
});
243307

244308
export const deleteAllData = () => ({
245-
type: DELETE_ALL_DATA,
309+
type: DELETE_ALL_DATA
246310
});
247311

248312
export const deleteProp = propId => dispatch => {
@@ -251,19 +315,19 @@ export const deleteProp = propId => dispatch => {
251315

252316
export const addProp = prop => ({
253317
type: ADD_PROP,
254-
payload: { ...prop },
318+
payload: { ...prop }
255319
});
256320

257321
export const updateHtmlAttr = ({ attr, value }) => dispatch => {
258322
dispatch({
259323
type: UPDATE_HTML_ATTR,
260-
payload: { attr, value },
324+
payload: { attr, value }
261325
});
262326
};
263327

264-
export const updateChildrenSort = ({ newChildrenArray }) => (dispatch) => {
328+
export const updateChildrenSort = ({ newChildrenArray }) => dispatch => {
265329
dispatch({
266330
type: UPDATE_CHILDREN_SORT,
267-
payload: { newChildrenArray },
331+
payload: { newChildrenArray }
268332
});
269333
};

src/components/CodePreview.tsx

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { Component, Fragment } from 'react';
2-
import { withStyles } from '@material-ui/core/styles';
3-
import { format } from 'prettier';
4-
import componentRender from '../utils/componentRender.util';
5-
import {ComponentInt,ComponentsInt} from '../utils/interfaces'
6-
import SortChildren from './SortChildren.jsx'
1+
import React, { Component, Fragment } from "react";
2+
import { withStyles } from "@material-ui/core/styles";
3+
import { format } from "prettier";
4+
import componentRender from "../utils/componentRender.util.ts";
5+
import { ComponentInt, ComponentsInt } from "../utils/interfaces";
6+
import SortChildren from "./SortChildren.jsx";
77

88
type Props = {
99
focusComponent: ComponentInt;
@@ -12,33 +12,33 @@ type Props = {
1212

1313
class CodePreview extends Component<Props> {
1414
render(): JSX.Element {
15-
const focusComponent : ComponentInt = this.props.focusComponent;
16-
const components : ComponentsInt = this.props.components;
17-
18-
return (
19-
<Fragment>
20-
<SortChildren/>
21-
<div
22-
style={{
23-
width: '500px',
24-
height: '290px',
25-
direction: 'rtl',
26-
paddingLeft: '20px',
27-
color: '#D3D3D3',
28-
fontSize: 16,
29-
overflow: 'auto',
30-
}}
31-
>
32-
<pre style={{ direction: 'ltr' }}>
33-
{format(componentRender(focusComponent, components), {
34-
singleQuote: true,
35-
trailingComma: 'es5',
36-
bracketSpacing: true,
37-
jsxBracketSameLine: true,
38-
parser: 'typescript',
39-
})}
40-
</pre>
41-
</div>
15+
const focusComponent: ComponentInt = this.props.focusComponent;
16+
const components: ComponentsInt = this.props.components;
17+
18+
return (
19+
<Fragment>
20+
<SortChildren />
21+
<div
22+
style={{
23+
width: "500px",
24+
height: "290px",
25+
direction: "rtl",
26+
paddingLeft: "20px",
27+
color: "#D3D3D3",
28+
fontSize: 16,
29+
overflow: "auto"
30+
}}
31+
>
32+
<pre style={{ direction: "ltr" }}>
33+
{format(componentRender(focusComponent, components), {
34+
singleQuote: true,
35+
trailingComma: "es5",
36+
bracketSpacing: true,
37+
jsxBracketSameLine: true,
38+
parser: "typescript"
39+
})}
40+
</pre>
41+
</div>
4242
</Fragment>
4343
);
4444
}

src/containers/MainContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '../actions/components';
2020
import KonvaStage from '../components/KonvaStage.jsx';
2121
import MainContainerHeader from '../components/MainContainerHeader.jsx';
22-
import createModal from '../utils/createModal.util';
22+
import createModal from '../utils/createModal.util.tsx';
2323

2424
const IPC = require('electron').ipcRenderer;
2525

src/utils/Interfaces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface PropInt {
66
type: string;
77
}
88

9-
interface Position {
9+
export interface PositionInt {
1010
x: number;
1111
y: number;
1212
width: number;
@@ -19,7 +19,7 @@ export interface ChildInt {
1919
childType: string;
2020
childComponentId: number;
2121
componentName: string;
22-
position: Position;
22+
position: PositionInt;
2323
color: string | null; // maybe optional instead, look up null vs undefined
2424
htmlElement: string | null; // maybe should be optional instead
2525
HTMLInfo: object; // replace with HTMLinfo specifics
@@ -34,7 +34,7 @@ export interface ComponentInt {
3434
color: string;
3535
props: PropInt[];
3636
nextPropId: number;
37-
position: Position;
37+
position: PositionInt;
3838
childrenArray: ChildInt[];
3939
nextChildId: number;
4040
focusChildId: number;

0 commit comments

Comments
 (0)