Skip to content

Commit 6d5ec6a

Browse files
authored
Merge pull request #84 from ShlomoPorges/development
types in components
2 parents 0daaa11 + 4911f5b commit 6d5ec6a

File tree

10 files changed

+52
-226
lines changed

10 files changed

+52
-226
lines changed

src/components/App.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,3 @@ export const App: React.SFC = () => (
1414

1515
export default App;
1616

17-
// class App extends Component {
18-
// // render() {
19-
// return (
20-
// <div className="app">
21-
// <div>
22-
// <header style={{ height: '40px', width: '100%' }}>ReacType</header>
23-
// <AppContainer />
24-
// </div>
25-
// </div>
26-
// );
27-
// }
28-
// }

src/components/CodePreview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ type Props = {
1212

1313
class CodePreview extends Component<Props> {
1414
render(): JSX.Element {
15-
//const {focusComponent, components } : {focusComponent:ComponentInt, components:ComponentsInt } = this.props;
1615
const focusComponent : ComponentInt = this.props.focusComponent;
1716
const components : ComponentsInt = this.props.components;
1817

src/components/HtmlAttr.jsx

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,6 @@ class HtmlAttr extends Component {
141141
onChange={this.handleChange}
142142
value={this.state[attr]}
143143
/>
144-
145-
{/* <TextField
146-
id={attr}
147-
label={attr}
148-
margin="normal"
149-
autoFocus
150-
// style={(marginLeft = "20px")}
151-
onChange={this.handleChange}
152-
value={this.state[attr]}
153-
InputProps={{
154-
className: classes.input
155-
}}
156-
InputLabelProps={{
157-
className: classes.input
158-
}}
159-
/> */}
160144
</Grid>
161145
<Grid item xs={4}>
162146
<Fab
@@ -170,24 +154,11 @@ class HtmlAttr extends Component {
170154
marginTop: "5px",
171155
marginBottom: "10px"
172156
}}
173-
// style={{ maxWidth: "20px" }}
174-
// onClick={() => {
175-
// updateHtmlAttr({ attr, value: this.state[attr] });
176-
// }}
177157
onClick={() => this.handleSave(attr)}
178158
>
179159
<SaveIcon className={classes.extendedIcon} />
180160
Save
181161
</Fab>
182-
183-
{/* <IconButton
184-
aria-label="Update"
185-
onClick={() => {
186-
updateHtmlAttr({ attr, value: this.state[attr] });
187-
}}
188-
>
189-
<SaveIcon style={{ color: "white" }} />
190-
</IconButton> */}
191162
</Grid>
192163
<Grid item xs={4}>
193164
<Paper className={classes.root} elevation={1}>
@@ -200,17 +171,6 @@ class HtmlAttr extends Component {
200171
? focusChild.HTMLInfo[attr]
201172
: "no attribute assigned"}
202173
</p>
203-
204-
{/* <TextField
205-
disabled
206-
id="filled-disabled"
207-
label={attr}
208-
value={focusChild.HTMLInfo[attr]}
209-
style={{ maxWidth: "20px" }}
210-
className={classes.textField}
211-
margin="normal"
212-
// variant="filled"
213-
/> */}
214174
</Paper>
215175
</Grid>
216176
</Grid>

src/components/Rectangle.jsx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,13 @@ class Rectangle extends Component {
5858
}
5959

6060
setImage = imageSource => {
61-
console.log("IMAGE SOURCE", imageSource);
6261
if (!imageSource) return;
6362
const image = new window.Image();
64-
// image.src = this.props.imagePath;
65-
// image.src =
66-
// "/Users/tolgamizrakci/Traceroll/01_Product/02_UI&UX/Assets/Sample Content/Images/71tWqG7nD-L._SX355_.jpg";
67-
68-
// image.src =
69-
// "https://article.images.consumerreports.org/prod/content/dam/CRO%20Images%202019/Magazine/04April/CR-Cars-InlineHero-TopTen-BMW-X5-2-18v3";
70-
63+
7164
image.src = imageSource;
72-
console.log("Image:");
73-
console.log("image.height", image.height);
7465
// if there was an error grtting img; heigth should b Zero
7566
if (!image.height) return null;
7667
return image;
77-
78-
// image.onload = () => {
79-
// // setState will redraw layer
80-
// // because "image" property is changed
81-
// return image;
82-
// };
8368
};
8469

8570
render() {
@@ -102,9 +87,6 @@ class Rectangle extends Component {
10287
childType,
10388
imageSource
10489
} = this.props;
105-
//console.log("first call props", imageSource);
106-
107-
// const { rectImage } = this.state;
10890

10991
// the Group is responsible for dragging of all children
11092
// the Rect emits changes to child width and height with help from Transformer
@@ -185,7 +167,6 @@ class Rectangle extends Component {
185167
components
186168
.find(comp => comp.title === childComponentName)
187169
.childrenArray.filter(child => child.childId !== -1)
188-
// .sort((a, b) => parseInt(a.childId) - parseInt(b.childId)) // using i within map below, sorting by childId might be necessary
189170
.map((grandchild, i) => (
190171
<GrandchildRectangle
191172
key={i}

src/containers/AppContainer.tsx

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@ import LeftContainer from './LeftContainer';
66
import MainContainer from './MainContainer';
77
import theme from '../components/theme';
88
import { loadInitData } from '../actions/components.js';
9+
import {ComponentInt, ComponentsInt, ChildInt} from '../utils/interfaces'
910

10-
const mapStateToProps = store => ({
11+
type Props = {
12+
components: ComponentsInt,
13+
focusComponent: ComponentInt,
14+
totalComponents: number,
15+
loading: boolean,
16+
selectableChildren: Array<number>,
17+
loadInitData: any
18+
};
19+
20+
const mapStateToProps = (store:any) => ({
1121
components: store.workspace.components,
1222
totalComponents: store.workspace.totalComponents,
1323
focusComponent: store.workspace.focusComponent,
@@ -17,31 +27,31 @@ const mapStateToProps = store => ({
1727

1828
const mapDispatchToProps = { loadInitData };
1929

20-
class AppContainer extends Component {
30+
class AppContainer extends Component<Props> {
2131
state = {
2232
width: 25,
2333
rightColumnOpen: true,
2434
};
2535

26-
collapseColumn = () => {
27-
if (this.state.width === 25) {
28-
this.setState({
29-
width: 0,
30-
rightColumnOpen: false,
31-
});
32-
} else {
33-
this.setState({
34-
width: 25,
35-
rightColumnOpen: true,
36-
});
37-
}
38-
};
36+
// collapseColumn = () => {
37+
// if (this.state.width === 25) {
38+
// this.setState({
39+
// width: 0,
40+
// rightColumnOpen: false,
41+
// });
42+
// } else {
43+
// this.setState({
44+
// width: 25,
45+
// rightColumnOpen: true,
46+
// });
47+
// }
48+
// };
3949

4050
componentDidMount() {
4151
this.props.loadInitData();
4252
}
4353

44-
render() {
54+
render() : JSX.Element {
4555
const {
4656
components, focusComponent, loading, selectableChildren,
4757
} = this.props;
@@ -55,23 +65,15 @@ class AppContainer extends Component {
5565
<div className="app-container">
5666
<LeftContainer
5767
components={components}
58-
// totalComponents={totalComponents}
5968
focusComponent={focusComponent}
6069
selectableChildren={selectableChildren}
6170
/>
6271
<MainContainer
6372
components={components}
64-
collapseColumn={this.collapseColumn}
73+
// collapseColumn={this.collapseColumn}
6574
width={width}
6675
rightColumnOpen={rightColumnOpen}
67-
// totalComponents={totalComponents}
6876
/>
69-
{/* <RightContainer
70-
width={width}
71-
components={updatedComponents}
72-
rightColumnOpen={rightColumnOpen}
73-
focusComponent={focusComponent}
74-
/> */}
7577
{loading ? (
7678
<div
7779
style={{

src/containers/LeftContainer.tsx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,30 @@ import { withStyles } from '@material-ui/core/styles';
99
import LeftColExpansionPanel from '../components/LeftColExpansionPanel';
1010
import HTMLComponentPanel from '../components/HTMLComponentPanel';
1111
import * as actions from '../actions/components';
12+
import {ComponentInt, ComponentsInt, ChildInt} from '../utils/interfaces'
1213

13-
const mapDispatchToProps = dispatch => ({
14-
addComponent: ({ title }) => dispatch(actions.addComponent({ title })),
15-
updateComponent: ({
16-
id, index, newParentId = null, color = null, stateful = null,
17-
}) => dispatch(
18-
actions.updateComponent({
19-
id,
20-
index,
21-
newParentId,
22-
color,
23-
stateful,
24-
}),
25-
),
26-
addChild: ({ title, childType, HTMLInfo }) => dispatch(actions.addChild({ title, childType, HTMLInfo })),
27-
changeFocusComponent: ({ title }) => dispatch(actions.changeFocusComponent({ title })),
28-
changeFocusChild: ({ childId }) => dispatch(actions.changeFocusChild({ childId })),
29-
deleteComponent: ({ componentId, stateComponents }) => dispatch(actions.deleteComponent({ componentId, stateComponents })),
14+
type Props = {
15+
components: ComponentsInt,
16+
focusComponent: ComponentInt,
17+
selectableChildren: Array<number>,
18+
classes:any,
19+
20+
addComponent: any,
21+
addChild: any,
22+
changeFocusComponent:any,
23+
changeFocusChild: any,
24+
deleteComponent: any,
25+
};
26+
27+
const mapDispatchToProps = (dispatch:any) => ({
28+
addComponent: ({ title } :{title:string}) => dispatch(actions.addComponent({ title })),
29+
addChild: ({ title, childType, HTMLInfo }:{title:string, childType:string, HTMLInfo:object }) => dispatch(actions.addChild({ title, childType, HTMLInfo })),
30+
changeFocusComponent: ({ title }:{title:string}) => dispatch(actions.changeFocusComponent({ title })),
31+
changeFocusChild: ({ childId }:{childId:number}) => dispatch(actions.changeFocusChild({ childId })),
32+
deleteComponent: ({ componentId, stateComponents }:{ componentId:number, stateComponents :ComponentsInt}) => dispatch(actions.deleteComponent({ componentId, stateComponents })),
3033
});
3134

32-
class LeftContainer extends Component {
35+
class LeftContainer extends Component<Props> {
3336
state = {
3437
componentName: '',
3538
};
@@ -47,7 +50,7 @@ class LeftContainer extends Component {
4750
});
4851
};
4952

50-
render() {
53+
render() : JSX.Element {
5154
const {
5255
components,
5356
deleteComponent,
@@ -61,7 +64,7 @@ class LeftContainer extends Component {
6164
const { componentName } = this.state;
6265

6366
const componentsExpansionPanel = components
64-
.sort((b, a) => parseInt(b.id) - parseInt(a.id)) // sort by id value of comp
67+
.sort((b:ComponentInt, a:ComponentInt) => b.id - a.id) // sort by id value of comp
6568
.map((component, i) => (
6669
<LeftColExpansionPanel
6770
key={component.id}
@@ -134,10 +137,6 @@ class LeftContainer extends Component {
134137

135138
function styles() {
136139
return {
137-
// htmlCompWrapper: {
138-
// bottom: 0,
139-
// height: "200px"
140-
// },
141140
cssLabel: {
142141
color: 'white',
143142

0 commit comments

Comments
 (0)