Skip to content

Commit 7051c12

Browse files
pushing styling of development
2 parents b280427 + cf4ebd0 commit 7051c12

File tree

7 files changed

+84
-21
lines changed

7 files changed

+84
-21
lines changed

src/components/SortChildren.jsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
import React, { Component} from "react";
3+
import { connect } from "react-redux";
4+
5+
const mapStateToProps = store => ({
6+
focusComponent: store.workspace.focusComponent,
7+
});
8+
9+
10+
class SortChildren extends Component {
11+
// constructor(props) {
12+
// super(props);
13+
state = {test: 'myTestValue'};
14+
//}
15+
16+
17+
render() {
18+
const children = this.props.focusComponent.childrenArray;
19+
const List = children.map( (child,idx) => {
20+
console.log(`mappping...... ${idx} ${child.componentName + child.childId}`)
21+
return (
22+
<li
23+
Childid={child.Childid}
24+
key={idx}
25+
draggable='true'
26+
// onDragEnd={this.dragEnd.bind(this)}
27+
// onDragStart={this.dragStart.bind(this)}>{item}
28+
>
29+
{child.componentName + child.childId}
30+
</li>
31+
)})
32+
console.log('children')
33+
console.log(children)
34+
console.log('List')
35+
console.log(List)
36+
return (
37+
<div>
38+
<p>Childrens List</p>
39+
{/* <List/> */}
40+
</div>
41+
)
42+
43+
}
44+
45+
}
46+
47+
export default connect(
48+
mapStateToProps
49+
)(SortChildren);

src/containers/MainContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import KonvaStage from '../components/KonvaStage.jsx';
2020
import MainContainerHeader from '../components/MainContainerHeader.jsx';
2121
import createModal from '../utils/createModal.util';
22+
import SortChildren from '../components/SortChildren.jsx';
2223

2324
const IPC = require('electron').ipcRenderer;
2425

src/utils/findComponentById.ts renamed to src/utils/Interfaces.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
3+
4+
15
interface Prop {
26
id: number;
37
key: string;
@@ -13,7 +17,7 @@ interface Position {
1317
height: number;
1418
}
1519

16-
interface Child {
20+
export interface ChildInt {
1721
childId: number;
1822
childType: string;
1923
childComponentId: number;
@@ -24,11 +28,11 @@ interface Child {
2428
HTMLInfo: object; // replace with HTMLinfo specifics
2529
}
2630

27-
interface Component {
31+
export interface ComponentInt {
2832
id: number;
2933
stateful: boolean;
3034
title: string;
31-
parentIds: number[];
35+
//parentIds: number[];
3236
color: string;
3337
draggable: boolean;
3438
// childrenIds: number[];
@@ -42,7 +46,10 @@ interface Component {
4246
focusChildId: number;
4347
}
4448

45-
function findComponentById(id: number, components: Component[]) {
49+
export interface ComponentsInt extends Array<ComponentInt> {}
50+
51+
52+
function findComponentById(id: number, components: ComponentInt[]) {
4653
return components.find(comp => comp.id === id);
4754
}
4855

src/utils/colors.util.js renamed to src/utils/colors.util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const colors = [
1+
2+
const colors: Array<String> = [
23
'#E27D60',
34
'#E3AFBC',
45
'#E8A87C',
@@ -24,6 +25,6 @@ const colors = [
2425
'#61892F',
2526
];
2627

27-
const getColor = () => colors[Math.floor(Math.random() * colors.length)];
28+
const getColor = ():String => colors[Math.floor(Math.random() * colors.length)];
2829

2930
export default getColor;

src/utils/componentReducer.util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// import setSelectableParents from "./setSelectableParents.util";
2-
import getSelectable from './getSelectable.util';
3-
import getColor from './colors.util';
2+
import getSelectable from './getSelectable.util.ts';
3+
import getColor from './colors.util.ts';
44
import { HTMLelements, getSize } from './htmlElements.util';
55
import cloneDeep from './cloneDeep.ts';
66

src/utils/getSelectable.util.js renamed to src/utils/getSelectable.util.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
1-
function getSelectable(newFocusComponent, components) {
1+
import {ComponentInt, ComponentsInt, ChildInt } from './Interfaces.ts';
2+
3+
4+
function getSelectable(newFocusComponent:ComponentInt, components:ComponentsInt) {
25
const focusComponentId = newFocusComponent.id;
36
const componentsToCheck = components
4-
.map(comp => comp.id)
5-
.filter(id => id !== focusComponentId);
7+
.map((comp: ComponentInt) => comp.id)
8+
.filter((id: Number) => id !== focusComponentId);
69
return findAncestors(components, [focusComponentId], componentsToCheck);
710
}
811

912
function findAncestors(
10-
components,
11-
currentCompArr,
12-
componentsToCheck,
13-
ancestors = []
14-
) {
13+
components :ComponentsInt,
14+
currentCompArr: ComponentsInt,
15+
componentsToCheck: ComponentsInt,
16+
ancestors : Array<Number> = []
17+
) :Object {
1518
if (!currentCompArr.length) {
1619
return {
1720
ancestors,
1821
selectableChildren: componentsToCheck
1922
};
2023
}
2124

22-
const newAncestors = [];
25+
const newAncestors: Array<Number> = [];
2326

2427
for (let i = 0; i < components.length; i++) {
2528
if (componentsToCheck.includes(components[i].id)) {
2629
const myChildren = components[i].childrenArray.map(
27-
child => child.childComponentId
30+
(child: ChildInt) => child.childComponentId
2831
);
2932

30-
const found = currentCompArr.filter(comp => myChildren.includes(comp));
33+
const found = currentCompArr.filter((comp: ComponentInt) => myChildren.includes(comp));
3134

3235
if (found.length) {
3336
ancestors.push(components[i].id);
3437
newAncestors.push(components[i].id);
3538

3639
const indexToDelete = componentsToCheck.findIndex(
37-
c => c === components[i].id
40+
(c: Number) => c === components[i].id
3841
);
3942

4043
componentsToCheck.splice(indexToDelete, 1);

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"noImplicitAny": true,
66
"module": "commonjs",
77
"target": "es6",
8-
"jsx": "react"
8+
"jsx": "react",
9+
// "strict": true,
10+
// "alwaysStrict": true,
911
//these two options are recommended but don't work, maybe an issue with awesome-typsecript-loader vs babel
1012
// "esModuleInterop": true
1113
// "allowSyntheticDefaultImports": true

0 commit comments

Comments
 (0)