Skip to content

Commit e0ff112

Browse files
Merge pull request #84 from ShlomoPorges/development
types in components
2 parents 0e48a32 + 6a6e40f commit e0ff112

File tree

10 files changed

+135
-222
lines changed

10 files changed

+135
-222
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
@@ -131,22 +131,6 @@ class HtmlAttr extends Component {
131131
onChange={this.handleChange}
132132
value={this.state[attr]}
133133
/>
134-
135-
{/* <TextField
136-
id={attr}
137-
label={attr}
138-
margin="normal"
139-
autoFocus
140-
// style={(marginLeft = "20px")}
141-
onChange={this.handleChange}
142-
value={this.state[attr]}
143-
InputProps={{
144-
className: classes.input
145-
}}
146-
InputLabelProps={{
147-
className: classes.input
148-
}}
149-
/> */}
150134
</Grid>
151135
<Grid item xs={4}>
152136
<Fab
@@ -160,24 +144,11 @@ class HtmlAttr extends Component {
160144
marginTop: '5px',
161145
marginBottom: '10px',
162146
}}
163-
// style={{ maxWidth: "20px" }}
164-
// onClick={() => {
165-
// updateHtmlAttr({ attr, value: this.state[attr] });
166-
// }}
167147
onClick={() => this.handleSave(attr)}
168148
>
169149
<SaveIcon className={classes.extendedIcon} />
170150
Save
171151
</Fab>
172-
173-
{/* <IconButton
174-
aria-label="Update"
175-
onClick={() => {
176-
updateHtmlAttr({ attr, value: this.state[attr] });
177-
}}
178-
>
179-
<SaveIcon style={{ color: "white" }} />
180-
</IconButton> */}
181152
</Grid>
182153
<Grid item xs={4}>
183154
<Paper className={classes.root} elevation={1}>
@@ -188,17 +159,6 @@ class HtmlAttr extends Component {
188159
<p style={{ color: 'black' }}>
189160
{focusChild.HTMLInfo[attr] ? focusChild.HTMLInfo[attr] : 'no attribute assigned'}
190161
</p>
191-
192-
{/* <TextField
193-
disabled
194-
id="filled-disabled"
195-
label={attr}
196-
value={focusChild.HTMLInfo[attr]}
197-
style={{ maxWidth: "20px" }}
198-
className={classes.textField}
199-
margin="normal"
200-
// variant="filled"
201-
/> */}
202162
</Paper>
203163
</Grid>
204164
</Grid>

src/components/Rectangle.tsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,13 @@ class Rectangle extends Component {
5454
}
5555

5656
setImage = imageSource => {
57-
console.log('IMAGE SOURCE', imageSource);
5857
if (!imageSource) return;
5958
const image = new window.Image();
60-
// image.src = this.props.imagePath;
61-
// image.src =
62-
// "/Users/tolgamizrakci/Traceroll/01_Product/02_UI&UX/Assets/Sample Content/Images/71tWqG7nD-L._SX355_.jpg";
63-
64-
// image.src =
65-
// "https://article.images.consumerreports.org/prod/content/dam/CRO%20Images%202019/Magazine/04April/CR-Cars-InlineHero-TopTen-BMW-X5-2-18v3";
6659

6760
image.src = imageSource;
68-
console.log('Image:');
69-
console.log('image.height', image.height);
7061
// if there was an error grtting img; heigth should b Zero
7162
if (!image.height) return null;
7263
return image;
73-
74-
// image.onload = () => {
75-
// // setState will redraw layer
76-
// // because "image" property is changed
77-
// return image;
78-
// };
7964
};
8065

8166
render() {
@@ -98,9 +83,6 @@ class Rectangle extends Component {
9883
childType,
9984
imageSource,
10085
} = this.props;
101-
//console.log("first call props", imageSource);
102-
103-
// const { rectImage } = this.state;
10486

10587
// the Group is responsible for dragging of all children
10688
// the Rect emits changes to child width and height with help from Transformer
@@ -169,7 +151,6 @@ class Rectangle extends Component {
169151
components
170152
.find(comp => comp.title === childComponentName)
171153
.childrenArray.filter(child => child.childId !== -1)
172-
// .sort((a, b) => parseInt(a.childId) - parseInt(b.childId)) // using i within map below, sorting by childId might be necessary
173154
.map((grandchild, i) => (
174155
<GrandchildRectangle
175156
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 { components, focusComponent, loading, selectableChildren } = this.props;
4656
const { width, rightColumnOpen } = this.state;
4757

@@ -53,23 +63,15 @@ class AppContainer extends Component {
5363
<div className="app-container">
5464
<LeftContainer
5565
components={components}
56-
// totalComponents={totalComponents}
5766
focusComponent={focusComponent}
5867
selectableChildren={selectableChildren}
5968
/>
6069
<MainContainer
6170
components={components}
62-
collapseColumn={this.collapseColumn}
71+
// collapseColumn={this.collapseColumn}
6372
width={width}
6473
rightColumnOpen={rightColumnOpen}
65-
// totalComponents={totalComponents}
6674
/>
67-
{/* <RightContainer
68-
width={width}
69-
components={updatedComponents}
70-
rightColumnOpen={rightColumnOpen}
71-
focusComponent={focusComponent}
72-
/> */}
7375
{loading ? (
7476
<div
7577
style={{

src/containers/LeftContainer.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,32 @@ import { withStyles } from '@material-ui/core/styles';
1010
import LeftColExpansionPanel from '../components/LeftColExpansionPanel.jsx';
1111
import HTMLComponentPanel from '../components/HTMLComponentPanel.jsx';
1212
import * as actions from '../actions/components';
13-
const mapDispatchToProps = dispatch => ({
14-
addComponent: ({ title }) => dispatch(actions.addComponent({ title })),
15-
dispatch(
16-
actions.updateComponent({
17-
index,
18-
newParentId,
19-
color,
20-
stateful,
21-
}),
22-
),
23-
addChild: ({ title, childType, HTMLInfo }) => dispatch(actions.addChild({ title, childType, HTMLInfo })),
24-
changeFocusComponent: ({ title }) => dispatch(actions.changeFocusComponent({ title })),
25-
changeFocusChild: ({ childId }) => dispatch(actions.changeFocusChild({ childId })),
26-
deleteComponent: ({ componentId, stateComponents }) =>
13+
import { ComponentInt, ComponentsInt, ChildInt } from '../utils/interfaces';
14+
15+
type Props = {
16+
components: ComponentsInt;
17+
focusComponent: ComponentInt;
18+
selectableChildren: Array<number>;
19+
classes: any;
20+
21+
addComponent: any;
22+
addChild: any;
23+
changeFocusComponent: any;
24+
changeFocusChild: any;
25+
deleteComponent: any;
26+
};
27+
28+
const mapDispatchToProps = (dispatch: any) => ({
29+
addComponent: ({ title }: { title: string }) => dispatch(actions.addComponent({ title })),
30+
addChild: ({ title, childType, HTMLInfo }: { title: string; childType: string; HTMLInfo: object }) =>
31+
dispatch(actions.addChild({ title, childType, HTMLInfo })),
32+
changeFocusComponent: ({ title }: { title: string }) => dispatch(actions.changeFocusComponent({ title })),
33+
changeFocusChild: ({ childId }: { childId: number }) => dispatch(actions.changeFocusChild({ childId })),
34+
deleteComponent: ({ componentId, stateComponents }: { componentId: number; stateComponents: ComponentsInt }) =>
2735
dispatch(actions.deleteComponent({ componentId, stateComponents })),
2836
});
2937

30-
class LeftContainer extends Component {
38+
class LeftContainer extends Component<Props> {
3139
state = {
3240
componentName: '',
3341
};
@@ -45,7 +53,7 @@ class LeftContainer extends Component {
4553
});
4654
};
4755

48-
render() {
56+
render(): JSX.Element {
4957
const {
5058
components,
5159
updateComponent,
@@ -61,7 +69,7 @@ class LeftContainer extends Component {
6169
const { componentName } = this.state;
6270

6371
const componentsExpansionPanel = components
64-
.sort((a, b) => parseInt(b.id) - parseInt(a.id)) // sort by id value of comp
72+
.sort((b: ComponentInt, a: ComponentInt) => b.id - a.id) // sort by id value of comp
6573
.map((component, i) => (
6674
<LeftColExpansionPanel
6775
key={component.id}
@@ -128,10 +136,6 @@ class LeftContainer extends Component {
128136

129137
function styles() {
130138
return {
131-
// htmlCompWrapper: {
132-
// bottom: 0,
133-
// height: "200px"
134-
// },
135139
cssLabel: {
136140
color: 'white',
137141

src/containers/MainContainer.tsx

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
import KonvaStage from '../components/KonvaStage';
2121
import MainContainerHeader from '../components/MainContainerHeader';
2222
import createModal from '../utils/createModal.util';
23-
import SortChildren from '../components/SortChildren.jsx';
2423

2524
const IPC = require('electron').ipcRenderer;
2625

@@ -52,7 +51,6 @@ const mapDispatchToProps = dispatch => ({
5251
});
5352

5453
const mapStateToProps = store => ({
55-
// totalComponents: store.workspace.totalComponents,
5654
focusComponent: store.workspace.focusComponent,
5755
focusChild: store.workspace.focusChild,
5856
stateComponents: store.workspace.components,
@@ -97,50 +95,6 @@ class MainContainer extends Component {
9795
});
9896
}
9997

100-
// setImage = () => {
101-
// const image = new window.Image();
102-
// image.src = this.props.imagePath;
103-
// image.onload = () => {
104-
// // setState will redraw layer
105-
// // because "image" property is changed
106-
// this.setState({
107-
// image,
108-
// });
109-
// };
110-
// };
111-
112-
// componentDidMount() {
113-
// this.setImage();
114-
// }
115-
116-
// updateImage = () => {
117-
// IPC.send('update-file');
118-
// };
119-
120-
// deleteImage = () => {
121-
// this.props.changeImagePath('');
122-
// this.setState({ image: '' });
123-
// };
124-
125-
closeModal = () => this.setState({ modal: null });
126-
127-
chooseAppDir = () => IPC.send('choose_app_dir');
128-
129-
// showImageDeleteModal = () => {
130-
// const { closeModal, deleteImage } = this;
131-
// this.setState({
132-
// modal: createModal({
133-
// closeModal,
134-
// message: 'Are you sure you want to delete image?',
135-
// secBtnLabel: 'Delete',
136-
// secBtnAction: () => {
137-
// deleteImage();
138-
// closeModal();
139-
// },
140-
// }),
141-
// });
142-
// };
143-
14498
chooseGenOptions = genOption => {
14599
// set option
146100
this.setState({ genOption });
@@ -247,25 +201,6 @@ class MainContainer extends Component {
247201
classes={classes}
248202
/>
249203
</div>
250-
251-
<div className="button-wrapper" style={{ background: 'rgba(76, 175, 80, 0)' }}>
252-
<Button onClick={deleteChild} style={{ width: '150px', display: 'inline-block' }}>
253-
delete child
254-
</Button>
255-
256-
<Button
257-
style={{ width: '180px', display: 'inline-block' }}
258-
onClick={() =>
259-
deleteComponent({
260-
componentId: focusComponent.id,
261-
stateComponents,
262-
})
263-
}
264-
>
265-
delete component
266-
</Button>
267-
<span>{directParents ? `Used in: ${directParents}` : 'Not used in any other component'}</span>
268-
</div>
269204
<BottomPanel focusComponent={focusComponent} />
270205
</div>
271206
</MuiThemeProvider>

0 commit comments

Comments
 (0)