Skip to content

Commit 83cd5b3

Browse files
committed
Typing fixes
1 parent 99bfece commit 83cd5b3

File tree

6 files changed

+62
-76
lines changed

6 files changed

+62
-76
lines changed

src/actionTypes/index.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/actionTypes/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export const LOAD_INIT_DATA: string = 'LOAD_INIT_DATA';
2+
export const ADD_COMPONENT: string = 'ADD_COMPONENT';
3+
export const ADD_CHILD: string = 'ADD_CHILD';
4+
export const DELETE_CHILD: string = 'DELETE_CHILD';
5+
export const UPDATE_COMPONENT: string = 'UPDATE_COMPONENT';
6+
export const DELETE_COMPONENT: string = 'DELETE_COMPONENT';
7+
export const CHANGE_FOCUS_COMPONENT: string = 'CHANGE_FOCUS_COMPONENT';
8+
export const CHANGE_COMPONENT_FOCUS_CHILD: string = 'CHANGE_COMPONENT_FOCUS_CHILD';
9+
export const CHANGE_FOCUS_CHILD: string = 'CHANGE_FOCUS_CHILD';
10+
export const UPDATE_CHILDREN: string = 'UPDATE_CHILDREN';
11+
export const REASSIGN_PARENT: string = 'REASSIGN_PARENT';
12+
export const SET_SELECTABLE_PARENTS: string = 'SET_SELECTABLE_PARENTS';
13+
export const EXPORT_FILES: string = 'EXPORT_FILES';
14+
export const EXPORT_FILES_SUCCESS: string = 'EXPORT_FILES_SUCCESS';
15+
export const EXPORT_FILES_ERROR: string = 'EXPORT_FILES_ERROR';
16+
export const HANDLE_CLOSE: string = 'HANDLE_CLOSE';
17+
export const HANDLE_TRANSFORM: string = 'HANDLE_TRANSFORM';
18+
export const CREATE_APPLICATION: string = 'CREATE_APPLICATION';
19+
export const CREATE_APPLICATION_SUCCESS: string = 'CREATE_APPLICATION_SUCCESS';
20+
export const CREATE_APPLICATION_ERROR: string = 'CREATE_APPLICATION_ERROR';
21+
export const MOVE_TO_BOTTOM: string = 'MOVE_TO_BOTTOM';
22+
export const MOVE_TO_TOP: string = 'MOVE_TO_TOP';
23+
export const OPEN_EXPANSION_PANEL: string = 'OPEN_EXPANSION_PANEL';
24+
export const DELETE_PROP: string = 'DELETE_PROP';
25+
export const ADD_PROP: string = 'ADD_PROP';
26+
export const DELETE_ALL_DATA: string = 'DELETE_ALL_DATA';
27+
export const CHANGE_IMAGE_PATH: string = 'CHANGE_IMAGE_PATH';
28+
export const UPDATE_HTML_ATTR: string = 'UPDATE_HTML_ATTR';
29+
export const UPDATE_CHILDREN_SORT: string = 'UPDATE_CHILDREN_SORT';
30+
export const CHANGE_IMAGE_SOURCE: string = 'CHANGE_IMAGE_SOURCE';
31+
export const DELETE_IMAGE: string = 'DELETE_IMAGE';

src/actions/components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
UPDATE_CHILDREN_SORT,
2828
CHANGE_IMAGE_SOURCE,
2929
DELETE_IMAGE
30-
} from '../actionTypes/index.js';
30+
} from '../actionTypes/index.ts';
3131

3232
import { loadState } from '../localStorage';
3333
import createFiles from '../utils/createFiles.util.ts';

src/components/Rectangle.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,11 @@ class Rectangle extends Component<PropsInt, StateInt> {
167167
draggable={false}
168168
fill={null}
169169
shadowBlur={childId === -1 ? 6 : null}
170-
<<<<<<< HEAD
171-
fillPatternImage={this.state.image ? this.state.image : null}
172-
fillPatternScaleX={this.state.image ? width / this.state.image.width : 1}
173-
fillPatternScaleY={this.state.image ? height / this.state.image.height : 1}
174-
=======
175170

176171
fillPatternImage={this.state.image ? this.state.image : null}
177172
fillPatternScaleX={this.state.image ? width / this.state.image.width : 1}
178173
fillPatternScaleY={this.state.image ? height / this.state.image.height : 1}
179174

180-
>>>>>>> e51db579b0759ac9d502e6bfaea52067bd942eb6
181175
_useStrictMode
182176
/>
183177
<Label>

src/containers/LeftContainer.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ interface StateInt {
4141
modal: any;
4242
genOptions: Array<string>;
4343
genOption: number;
44+
imageSource: string;
4445
}
4546

4647
const mapStateToProps = (store: any) => ({
@@ -163,19 +164,9 @@ class LeftContainer extends Component<PropsInt, StateInt> {
163164
this.chooseAppDir();
164165
};
165166

166-
<<<<<<< HEAD
167-
<<<<<<< HEAD
168-
chooseAppDir = () => IPC.send("choose_app_dir");
169-
addImage = () => IPC.send('update-file');
170-
=======
171-
chooseAppDir = () => IPC.send('choose_app_dir');
172-
>>>>>>> 5b06f9594f8f844e2ac13ae8e5c94fa9d71dfd80
173-
=======
174-
175167
chooseAppDir = () => IPC.send("choose_app_dir");
176168
addImage = () => IPC.send('update-file');
177169

178-
>>>>>>> e51db579b0759ac9d502e6bfaea52067bd942eb6
179170

180171
showGenerateAppModal = () => {
181172
const { closeModal, chooseGenOptions } = this;

src/utils/componentReducer.util.ts

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import cloneDeep from './cloneDeep.ts';
55
import { ComponentInt, ApplicationStateInt, ChildrenInt, ChildInt, ComponentsInt, PropInt } from './Interfaces.ts';
66

77

8+
89
const initialComponentState: ComponentInt = {
910
id: 0,
1011
stateful: false,
@@ -60,7 +61,7 @@ export const addComponent = (state: ApplicationStateInt, { title }: { title: str
6061
const totalComponents = state.totalComponents + 1;
6162
const nextId = state.nextId + 1;
6263

63-
const selectableChildren = state.components.map(comp => comp.id).filter(id => id !== newComponent.id);
64+
const selectableChildren = state.components.map((comp: ComponentInt) => comp.id).filter((id: number) => id !== newComponent.id);
6465

6566
const ancestors: Array<number> = [];
6667

@@ -95,14 +96,14 @@ export const addChild = (
9596

9697
// view represents the curretn FOCUSED COMPONENT - this is the component where the child is being added to
9798
// we only add childrent (or do any action) to the focused omconent
98-
const view: ComponentInt = state.components.find(comp => comp.title === state.focusComponent.title);
99+
const view: ComponentInt = state.components.find((comp: ComponentInt) => comp.title === state.focusComponent.title);
99100

100101
// parentComponent is the component this child is generated from (ex. instance of Box has comp of Box)
101102
let parentComponent;
102103

103104
// conditional if adding an HTML component
104105
if (childType === 'COMP') {
105-
parentComponent = state.components.find(comp => comp.title === title);
106+
parentComponent = state.components.find((comp: ComponentInt) => comp.title === title);
106107
}
107108

108109
interface htmlElemPositionInt {
@@ -157,7 +158,7 @@ export const addChild = (
157158
};
158159

159160
const components = [
160-
...state.components.filter(comp => {
161+
...state.components.filter((comp: ComponentInt) => {
161162
if (comp.title !== view.title) return comp;
162163
}),
163164
component,
@@ -193,7 +194,7 @@ export const deleteChild = (
193194
return state;
194195
}
195196
// make a DEEP copy of the parent component (the one thats about to loose a child)
196-
const parentComponentCopy: any = cloneDeep(state.components.find(c => c.id === parentId));
197+
const parentComponentCopy: any = cloneDeep(state.components.find((comp: ComponentInt) => comp.id === parentId));
197198

198199
// delete the CHILD from the copied array
199200
const indexToDelete = parentComponentCopy.childrenArray.findIndex((elem: ChildInt) => elem.childId === childId);
@@ -208,7 +209,7 @@ export const deleteChild = (
208209
}
209210

210211
const modifiedComponentArray = [
211-
...state.components.filter(c => c.id !== parentId), // all elements besides the one just changed
212+
...state.components.filter((comp: ComponentInt) => comp.id !== parentId), // all elements besides the one just changed
212213
parentComponentCopy,
213214
];
214215

@@ -250,7 +251,7 @@ export const handleTransform = (
250251
) => {
251252
if (childId === -1) {
252253
// the pseudochild has been transformed, its position is stored in the component
253-
const component = state.components.find(comp => comp.id === componentId);
254+
const component = state.components.find((comp: ComponentInt) => comp.id === componentId);
254255
const transformedComponent = {
255256
...component,
256257
position: {
@@ -262,7 +263,7 @@ export const handleTransform = (
262263
};
263264

264265
const components = [
265-
...state.components.filter(comp => {
266+
...state.components.filter((comp: ComponentInt) => {
266267
if (comp.id !== componentId) return comp;
267268
}),
268269
transformedComponent,
@@ -272,8 +273,8 @@ export const handleTransform = (
272273

273274
// else, a normal child has been transformed, its position lives in the children array
274275
const child = state.components
275-
.find(comp => comp.id === componentId)
276-
.childrenArray.find(child => child.childId === childId);
276+
.find((comp: ComponentInt) => comp.id === componentId)
277+
.childrenArray.find((child: ChildInt) => child.childId === childId);
277278

278279
const transformedChild = {
279280
...child,
@@ -286,7 +287,7 @@ export const handleTransform = (
286287
};
287288

288289
const children = [
289-
...state.components.find(comp => comp.id === componentId).childrenArray.filter(child => {
290+
...state.components.find((comp: ComponentInt) => comp.id === componentId).childrenArray.filter((child: ChildInt) => {
290291
if (child.childId !== childId) return child;
291292
}),
292293
transformedChild,
@@ -298,13 +299,13 @@ export const handleTransform = (
298299
}
299300

300301
const component = {
301-
...state.components.find(comp => comp.id === componentId),
302+
...state.components.find((comp: ComponentInt) => comp.id === componentId),
302303
childrenArray: children,
303304
focusChild: newFocusChild,
304305
};
305306

306307
const components: ComponentsInt = [
307-
...state.components.filter(comp => {
308+
...state.components.filter((comp: ComponentInt) => {
308309
if (comp.id !== componentId) return comp;
309310
}),
310311
component,
@@ -371,12 +372,12 @@ export const changeFocusComponent = (
371372
* if the prm TITLE is a blank Object it means REFRESH focusd Components.
372373
* sometimes we update state like adding Children/Props etc and we want those changes to be reflected in focus component
373374
************************************************* */
374-
const newFocusComp: ComponentInt = state.components.find(comp => comp.title === title);
375+
const newFocusComp: ComponentInt = state.components.find((comp: ComponentInt) => comp.title === title);
375376
// set the "focus child" to the focus child of this particular component .
376377

377378
let newFocusChild: ChildInt | any; // check if the components has a child saved as a Focus child
378379
if (newFocusComp.focusChildId > 0) {
379-
newFocusChild = newFocusComp.childrenArray.find(child => child.childId === newFocusComp.focusChildId);
380+
newFocusChild = newFocusComp.childrenArray.find((child: ChildInt) => child.childId === newFocusComp.focusChildId);
380381
}
381382

382383
if (!newFocusChild) {
@@ -395,8 +396,8 @@ export const changeFocusComponent = (
395396
};
396397

397398
export const changeFocusChild = (state: ApplicationStateInt, { childId }: { childId: number }) => {
398-
const focComp = state.components.find(comp => comp.title === state.focusComponent.title);
399-
let newFocusChild: ChildInt = focComp.childrenArray.find(child => child.childId === childId);
399+
const focComp = state.components.find((comp: ComponentInt) => comp.title === state.focusComponent.title);
400+
let newFocusChild: ChildInt = focComp.childrenArray.find((child: ChildInt) => child.childId === childId);
400401

401402
if (!newFocusChild) {
402403
newFocusChild = {
@@ -427,10 +428,10 @@ export const changeComponentFocusChild = (
427428
state: ApplicationStateInt,
428429
{ componentId, childId }: { componentId: number; childId: number },
429430
) => {
430-
const component: ComponentInt = state.components.find(comp => comp.id === componentId);
431+
const component: ComponentInt = state.components.find((comp: ComponentInt) => comp.id === componentId);
431432
const modifiedComponent: any = cloneDeep(component);
432433
modifiedComponent.focusChildId = childId;
433-
const components: ComponentsInt = state.components.filter(comp => comp.id !== componentId);
434+
const components: ComponentsInt = state.components.filter((comp: ComponentInt) => comp.id !== componentId);
434435
return {
435436
...state,
436437
components: [modifiedComponent, ...components],
@@ -470,7 +471,7 @@ export const addProp = (
470471
return state;
471472
}
472473

473-
const selectedComponent = state.components.find(comp => comp.id === state.focusComponent.id);
474+
const selectedComponent = state.components.find((comp: ComponentInt) => comp.id === state.focusComponent.id);
474475

475476
const newProp: PropInt = {
476477
id: selectedComponent.nextPropId,
@@ -487,7 +488,7 @@ export const addProp = (
487488
nextPropId: selectedComponent.nextPropId + 1,
488489
};
489490

490-
const newComponents: ComponentsInt = state.components.filter(comp => comp.id !== selectedComponent.id);
491+
const newComponents: ComponentsInt = state.components.filter((comp: ComponentInt) => comp.id !== selectedComponent.id);
491492
newComponents.push(modifiedComponent);
492493
return {
493494
...state,
@@ -502,7 +503,7 @@ export const deleteProp = (state: ApplicationStateInt, propId: number) => {
502503
return state;
503504
}
504505

505-
const modifiedComponent: any = cloneDeep(state.components.find(comp => comp.id === state.focusComponent.id));
506+
const modifiedComponent: any = cloneDeep(state.components.find((comp: ComponentInt) => comp.id === state.focusComponent.id));
506507

507508
const indexToDelete = modifiedComponent.props.findIndex((prop: PropInt) => prop.id === propId);
508509
if (indexToDelete === -1) {
@@ -512,7 +513,7 @@ export const deleteProp = (state: ApplicationStateInt, propId: number) => {
512513

513514
modifiedComponent.props.splice(indexToDelete, 1);
514515

515-
const newComponentsArray = state.components.filter(comp => comp.id !== modifiedComponent.id);
516+
const newComponentsArray = state.components.filter((comp: ComponentInt) => comp.id !== modifiedComponent.id);
516517
newComponentsArray.push(modifiedComponent);
517518

518519
return {
@@ -532,15 +533,15 @@ export const updateHtmlAttr = (state: ApplicationStateInt, { attr, value }: { at
532533
modifiedChild.HTMLInfo[attr] = value;
533534

534535
const modifiedComponent: ComponentInt = JSON.parse(
535-
JSON.stringify(state.components.find(comp => comp.id === state.focusComponent.id)),
536+
JSON.stringify(state.components.find((comp: ComponentInt) => comp.id === state.focusComponent.id)),
536537
);
537538

538539
modifiedComponent.childrenArray = modifiedComponent.childrenArray.filter(
539-
child => child.childId !== modifiedChild.childId,
540+
(child: ChildInt) => child.childId !== modifiedChild.childId,
540541
);
541542
modifiedComponent.childrenArray.push(modifiedChild);
542543

543-
const newComponentsArray = state.components.filter(comp => comp.id !== modifiedComponent.id);
544+
const newComponentsArray = state.components.filter((comp: ComponentInt) => comp.id !== modifiedComponent.id);
544545
newComponentsArray.push(modifiedComponent);
545546

546547
return {
@@ -563,10 +564,10 @@ export const updateChildrenSort = (state: ApplicationStateInt, { newSortValues }
563564
currChild.childSort = newSortValue;
564565
}
565566

566-
const modifiedComponent = state.components.find(comp => comp.id === state.focusComponent.id);
567+
const modifiedComponent = state.components.find((comp: ComponentInt) => comp.id === state.focusComponent.id);
567568
modifiedComponent.childrenArray = modifiedChildrenArray;
568569

569-
const modifiedComponentsArray = state.components.filter(comp => comp.id !== state.focusComponent.id);
570+
const modifiedComponentsArray = state.components.filter((comp: ComponentInt) => comp.id !== state.focusComponent.id);
570571
modifiedComponentsArray.push(modifiedComponent);
571572

572573
return {

0 commit comments

Comments
 (0)