Skip to content

Commit 3e605e2

Browse files
committed
Fixed some typing
1 parent 17e491f commit 3e605e2

File tree

4 files changed

+25
-56
lines changed

4 files changed

+25
-56
lines changed

src/actions/components.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,24 +273,23 @@ export const deleteProp = (propId: number) => (
273273
dispatch({ type: DELETE_PROP, payload: propId });
274274
};
275275

276-
export const toggleComponentState = (id: string) => (
276+
export const toggleComponentState = ({ id }: { id: number }) => (
277277
dispatch: (arg: Action) => void
278278
) => {
279-
dispatch({ type: TOGGLE_STATE, payload: id });
279+
dispatch({ type: TOGGLE_STATE, payload: { id } });
280280
};
281281

282-
export const toggleComponentClass = (id: string) => (
282+
export const toggleComponentClass = ({ id }: { id: number }) => (
283283
dispatch: (arg: Action) => void
284284
) => {
285-
dispatch({ type: TOGGLE_CLASS, payload: id });
285+
dispatch({ type: TOGGLE_CLASS, payload: { id } });
286286
};
287287

288288
export const addProp = (prop: PropInt) => ({
289289
type: ADD_PROP,
290290
payload: { ...prop },
291291
});
292292

293-
294293
//action creators for undo and redo
295294
export const undo = () => ({
296295
type: UNDO,

src/components/LeftColExpansionPanel.tsx

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ interface LeftColExpPanPropsInt extends PropsInt {
2525
componentId: number;
2626
stateComponents: ComponentsInt;
2727
}): void;
28-
toggleComponentState(arg: number): void;
29-
toggleComponentClass(arg: number): void;
28+
toggleComponentState(arg: {id: number}): void;
29+
toggleComponentClass(arg: {id: number}): void;
3030
}
3131
//interface created but never used
3232
// interface TypographyProps {
@@ -56,7 +56,6 @@ const LeftColExpansionPanel = (props: LeftColExpPanPropsInt) => {
5656
return (
5757
<Grid
5858
container
59-
spacing={16}
6059
direction='row'
6160
justify='center'
6261
alignItems='center'
@@ -142,9 +141,9 @@ const LeftColExpansionPanel = (props: LeftColExpPanPropsInt) => {
142141
</InputLabel>
143142
<Switch
144143
checked={stateful}
145-
onChange={e => {
146-
toggleComponentState(id);
147-
// changeFocusComponent({ title });
144+
onChange={() => {
145+
toggleComponentState({ id });
146+
changeFocusComponent({ title });
148147
}}
149148
value='stateful'
150149
color='primary'
@@ -166,9 +165,9 @@ const LeftColExpansionPanel = (props: LeftColExpPanPropsInt) => {
166165
</InputLabel>{' '}
167166
<Switch
168167
checked={classBased}
169-
onChange={e => {
170-
toggleComponentClass(id);
171-
// changeFocusComponent({ title });
168+
onChange={() => {
169+
toggleComponentClass({ id });
170+
changeFocusComponent({ title });
172171
}}
173172
value='classBased'
174173
color='primary'
@@ -204,7 +203,8 @@ const LeftColExpansionPanel = (props: LeftColExpPanPropsInt) => {
204203
/>
205204
<div
206205
style={{
207-
marginTop: '3px',
206+
marginTop: '4px',
207+
marginLeft: '5px',
208208
fontSize: '15px',
209209
textShadow: '1px 1px 2px rgba(0, 0, 0, 0.8)'
210210
}}
@@ -217,42 +217,11 @@ const LeftColExpansionPanel = (props: LeftColExpPanPropsInt) => {
217217
)}
218218
</div>
219219
}
220-
// style={{ color }}
221220
/>
222221
</ListItem>
223222
</List>
224223
</Grid>
225224
</Collapse>
226-
{/* {id === 1 || !isFocused() ? ( Removed sepearate delete icon and
227-
made it part of card
228-
<div />
229-
) : (
230-
<Fragment>
231-
<Button
232-
variant="text"
233-
size="small"
234-
color="default"
235-
aria-label="Delete"
236-
className={classes.margin}
237-
onClick={() =>
238-
deleteComponent({
239-
componentId: id,
240-
stateComponents: components,
241-
})
242-
}
243-
style={{
244-
color: '#D3D3D3',
245-
marginBottom: '10px',
246-
marginTop: '4px',
247-
marginLeft: '11px',
248-
padding: '0px',
249-
}}
250-
>
251-
<DeleteIcon style={{ color: '#D3D3D3' }} />
252-
<span style={{ marginTop: '3px' }}>Delete Component</span>
253-
</Button>
254-
</Fragment>
255-
)} */}
256225
</div>
257226
</Grid>
258227
{/* {Create the '+' symbol that add's components as children.} */}
@@ -279,7 +248,7 @@ const LeftColExpansionPanel = (props: LeftColExpPanPropsInt) => {
279248
</Grid>
280249
);
281250
};
282-
function styles(themes: any): any {
251+
function styles(): object {
283252
return {
284253
root: {
285254
width: '100%',

src/containers/LeftContainer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ const mapDispatchToProps = (dispatch: any) => ({
7676
componentId: number;
7777
stateComponents: ComponentsInt;
7878
}) => dispatch(actions.deleteComponent({ componentId, stateComponents })),
79-
toggleComponentState: (id: string) =>
80-
dispatch(actions.toggleComponentState(id)),
81-
toggleComponentClass: (id: string) =>
82-
dispatch(actions.toggleComponentClass(id)),
79+
toggleComponentState: ({ id }: { id: number }) =>
80+
dispatch(actions.toggleComponentState({ id })),
81+
toggleComponentClass: ({ id }: { id: number }) =>
82+
dispatch(actions.toggleComponentClass({ id })),
8383
deleteAllData: () => dispatch(actions.deleteAllData()),
8484
deleteImage: () => dispatch(actions.deleteImage()),
8585
createApp: ({
@@ -98,7 +98,7 @@ const mapDispatchToProps = (dispatch: any) => ({
9898
genOption,
9999
appName: 'reactype_app',
100100
exportAppBool: null,
101-
}),
101+
})
102102
),
103103
});
104104

@@ -119,7 +119,7 @@ class LeftContainer extends Component<LeftContPropsInt, StateInt> {
119119
imageSource: this.props.imageSource,
120120
};
121121

122-
IPC.on('app_dir_selected', (event: any, path: string) => {
122+
IPC.on('app_dir_selected', (event: string, path: string) => {
123123
const { components } = this.props;
124124
const { genOption } = this.state;
125125
this.props.createApp({
@@ -435,5 +435,5 @@ function styles(): any {
435435

436436
export default compose(
437437
withStyles(styles),
438-
connect(mapStateToProps, mapDispatchToProps),
438+
connect(mapStateToProps, mapDispatchToProps)
439439
)(LeftContainer);

src/utils/componentReducer.util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ export const deleteComponent = (
501501
//Reducer that toggles the component statefulness
502502
export const toggleComponentState = (
503503
state: ApplicationStateInt,
504-
id: number
504+
{ id }: { id: number }
505505
) => {
506506
//creates a deep copy of the components array
507507
const componentCopy = cloneDeep(state.components);
@@ -512,6 +512,7 @@ export const toggleComponentState = (
512512
element.stateful = !element.stateful;
513513
}
514514
});
515+
515516
// return state and updated components array
516517
const { history, historyIndex, future } = createHistory(state);
517518

@@ -527,7 +528,7 @@ export const toggleComponentState = (
527528
//Reducer that toggles the component class
528529
export const toggleComponentClass = (
529530
state: ApplicationStateInt,
530-
id: number
531+
{ id }: { id: number }
531532
) => {
532533
//creates a deep copy of the components array
533534
const componentCopy = cloneDeep(state.components);

0 commit comments

Comments
 (0)