Skip to content

Commit ded1326

Browse files
committed
Merge conflicts resolved with Sean's update
2 parents 13662e3 + f83af90 commit ded1326

File tree

7 files changed

+164
-77
lines changed

7 files changed

+164
-77
lines changed

src/actionTypes/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ export const UPDATE_CHILDREN_SORT: string = 'UPDATE_CHILDREN_SORT';
3030
export const CHANGE_IMAGE_SOURCE: string = 'CHANGE_IMAGE_SOURCE';
3131
export const DELETE_IMAGE: string = 'DELETE_IMAGE';
3232
export const TOGGLE_STATE: string = 'TOGGLE_STATE';
33+
export const TOGGLE_CLASS: string = 'TOGGLE_CLASS';

src/actions/components.ts

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import {
2+
<<<<<<< HEAD
23
ComponentInt, ComponentsInt, PropInt, ChildInt, Action, ApplicationStateInt, LoadInitData, AddComponent
4+
=======
5+
ComponentInt,
6+
ComponentsInt,
7+
PropInt,
8+
ChildInt,
9+
Action,
10+
ApplicationStateInt
11+
>>>>>>> f83af9065420b5f7bd3ed2f414d8f7aa2045dce7
312
} from '../utils/Interfaces.ts';
413

514
import {
@@ -9,6 +18,7 @@ import {
918
DELETE_CHILD,
1019
DELETE_COMPONENT,
1120
TOGGLE_STATE,
21+
TOGGLE_CLASS,
1222
CHANGE_FOCUS_COMPONENT,
1323
CHANGE_FOCUS_CHILD,
1424
CHANGE_COMPONENT_FOCUS_CHILD,
@@ -36,18 +46,24 @@ import createApplicationUtil from '../utils/createApplication.util.ts';
3646

3747
export const changeImagePath = (imageSource: string) => ({
3848
type: CHANGE_IMAGE_SOURCE,
39-
payload: { imageSource },
40-
})
49+
payload: { imageSource }
50+
});
4151

52+
<<<<<<< HEAD
4253
export const loadInitData = () => (dispatch: any) => {
4354
loadState().then((data: any) => {
55+
=======
56+
export const loadInitData = () => (dispatch: (arg: Action) => void) => {
57+
loadState().then((data: ApplicationStateInt) => {
58+
console.log('data.workspace', data.workspace);
59+
>>>>>>> f83af9065420b5f7bd3ed2f414d8f7aa2045dce7
4460
dispatch({
45-
type: LOAD_INIT_DATA,
46-
payload: {
47-
data: data ? data.workspace : {},
48-
},
61+
type: LOAD_INIT_DATA,
62+
payload: {
63+
data: data ? data.workspace : {}
64+
}
65+
});
4966
});
50-
});
5167
};
5268

5369
export const addComponent = ({ title }: { title: string }) => (dispatch: (arg: AddComponent) => void) => {
@@ -59,9 +75,9 @@ export const addChild = ({
5975
childType,
6076
HTMLInfo
6177
}: {
62-
title: string;
63-
childType: string;
64-
HTMLInfo: object;
78+
title: string;
79+
childType: string;
80+
HTMLInfo: object;
6581
}) => (dispatch: (arg: Action) => void) => {
6682
dispatch({ type: ADD_CHILD, payload: { title, childType, HTMLInfo } });
6783
};
@@ -75,8 +91,8 @@ export const deleteComponent = ({
7591
componentId,
7692
stateComponents
7793
}: {
78-
componentId: number;
79-
stateComponents: ComponentsInt;
94+
componentId: number;
95+
stateComponents: ComponentsInt;
8096
}) => (dispatch: (arg: Action) => void) => {
8197
// find all places where the "to be deleted" is a child and do what u gotta do
8298
stateComponents.forEach((parent: ComponentInt) => {
@@ -100,21 +116,25 @@ stateComponents: ComponentsInt;
100116
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
101117
};
102118

103-
export const changeFocusComponent = ({ title }: { title: string }) => (dispatch: (arg: Action) => void) => {
119+
export const changeFocusComponent = ({ title }: { title: string }) => (
120+
dispatch: (arg: Action) => void
121+
) => {
104122
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title } });
105123
};
106124

107125
// make sure childId is being sent in
108-
export const changeFocusChild = ({ childId }: { childId: number }) => (dispatch: (arg: Action) => void) => {
126+
export const changeFocusChild = ({ childId }: { childId: number }) => (
127+
dispatch: (arg: Action) => void
128+
) => {
109129
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { childId } });
110130
};
111131

112132
export const changeComponentFocusChild = ({
113133
componentId,
114134
childId
115135
}: {
116-
componentId: number;
117-
childId: number;
136+
componentId: number;
137+
childId: number;
118138
}) => (dispatch: (arg: Action) => void) => {
119139
dispatch({
120140
type: CHANGE_COMPONENT_FOCUS_CHILD,
@@ -124,18 +144,18 @@ childId: number;
124144

125145
export const deleteImage = () => ({
126146
type: DELETE_IMAGE
127-
})
147+
});
128148

129149
export const exportFiles = ({
130150
components,
131151
path,
132152
appName,
133153
exportAppBool
134154
}: {
135-
components: ComponentsInt;
136-
path: string;
137-
appName: string;
138-
exportAppBool: boolean;
155+
components: ComponentsInt;
156+
path: string;
157+
appName: string;
158+
exportAppBool: boolean;
139159
}) => (dispatch: (arg: Action) => void) => {
140160
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
141161
dispatch({
@@ -185,11 +205,11 @@ export const createApplication = ({
185205
appName = 'reactype_app',
186206
exportAppBool
187207
}: {
188-
path: string;
189-
components: ComponentsInt;
190-
genOption: number;
191-
appName: string;
192-
exportAppBool: boolean;
208+
path: string;
209+
components: ComponentsInt;
210+
genOption: number;
211+
appName: string;
212+
exportAppBool: boolean;
193213
}) => (dispatch: (arg: Action) => void) => {
194214
if (genOption === 0) {
195215
exportAppBool = false;
@@ -209,7 +229,7 @@ exportAppBool: boolean;
209229
createApplicationUtil({
210230
path,
211231
appName,
212-
genOption,
232+
genOption
213233
})
214234
.then(() => {
215235
dispatch({
@@ -246,8 +266,12 @@ export const deleteProp = (propId: number) => (dispatch: (arg: Action) => void)
246266
dispatch({ type: DELETE_PROP, payload: propId });
247267
};
248268

249-
export const toggleComponentState = (index: string) => (dispatch: (arg: Action) => void) => {
250-
dispatch({ type: TOGGLE_STATE, payload: index });
269+
export const toggleComponentState = (id: string) => (dispatch: (arg: Action) => void) => {
270+
dispatch({ type: TOGGLE_STATE, payload: id });
271+
};
272+
273+
export const toggleComponentClass = (id: string) => (dispatch: (arg: Action) => void) => {
274+
dispatch({ type: TOGGLE_CLASS, payload: id });
251275
};
252276

253277
export const addProp = (prop: PropInt) => ({
@@ -256,7 +280,7 @@ export const addProp = (prop: PropInt) => ({
256280
});
257281

258282
export const updateHtmlAttr = ({ attr, value }: { attr: string; value: string }) => (
259-
dispatch: (arg: Action) => void,
283+
dispatch: (arg: Action) => void
260284
) => {
261285
dispatch({
262286
type: UPDATE_HTML_ATTR,
@@ -272,4 +296,4 @@ export const updateHtmlAttr = ({ attr, value }: { attr: string; value: string })
272296
// type: UPDATE_CHILDREN_SORT,
273297
// payload: { newSortValues },
274298
// });
275-
// };
299+
// };

src/components/LeftColExpansionPanel.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ const LeftColExpansionPanel = (props: any) => {
2626
selectableChildren,
2727
components,
2828
deleteComponent,
29-
toggleComponentState
29+
toggleComponentState,
30+
toggleComponentClass
3031
} = props;
3132

32-
const { title, id, color } = component;
33+
const { title, id, color, stateful, classBased } = component;
3334
useEffect(() => {
3435
console.log('title: ', title);
3536
});
@@ -81,8 +82,9 @@ const LeftColExpansionPanel = (props: any) => {
8182
peview
8283
*/}
8384
<Switch
85+
checked={stateful}
8486
onChange={e => {
85-
toggleComponentState(props.id);
87+
toggleComponentState(id);
8688
changeFocusComponent(title);
8789
}}
8890
value="stateful"
@@ -106,13 +108,13 @@ const LeftColExpansionPanel = (props: any) => {
106108
Class?
107109
</InputLabel>
108110
<Switch
109-
// checked={classBased}
110-
// onChange={e => ONCHANGE FUNCTION PENDING ON CLASS REDUCER
111-
// updateComponent(id, { classBased: e.target.checked })
112-
// }
111+
checked={classBased}
112+
onChange={e => {
113+
toggleComponentClass(id);
114+
changeFocusComponent(title);
115+
}}
113116
value="classBased"
114117
color="primary"
115-
id={props.index.toString()}
116118
/>
117119
</div>
118120
</div>

src/containers/LeftContainer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface PropsInt {
3434
createApp: any;
3535
deleteAllData: any;
3636
toggleComponentState: any;
37+
toggleComponentClass: any;
3738
deleteImage: any;
3839
}
3940

@@ -72,6 +73,7 @@ const mapDispatchToProps = (dispatch: any) => ({
7273
stateComponents: ComponentsInt;
7374
}) => dispatch(actions.deleteComponent({ componentId, stateComponents })),
7475
toggleComponentState: (id: string) => dispatch(actions.toggleComponentState(id)),
76+
toggleComponentClass: (id: string) => dispatch(actions.toggleComponentClass(id)),
7577
deleteAllData: () => dispatch(actions.deleteAllData()),
7678
deleteImage: () => dispatch(actions.deleteImage()),
7779
createApp: ({
@@ -214,6 +216,7 @@ class LeftContainer extends Component<PropsInt, StateInt> {
214216
changeFocusChild,
215217
selectableChildren,
216218
toggleComponentState,
219+
toggleComponentClass,
217220
deleteImage
218221
} = this.props;
219222
const { componentName, modal } = this.state;
@@ -234,6 +237,7 @@ class LeftContainer extends Component<PropsInt, StateInt> {
234237
deleteComponent={deleteComponent}
235238
components={components}
236239
toggleComponentState={toggleComponentState}
240+
toggleComponentClass={toggleComponentClass}
237241
/>
238242
));
239243
const { addImage, clearImage } = this;
@@ -408,4 +412,5 @@ function styles(): any {
408412

409413
export default compose(
410414
withStyles(styles),
411-
connect(mapStateToProps, mapDispatchToProps))(LeftContainer);
415+
connect(mapStateToProps, mapDispatchToProps)
416+
)(LeftContainer);

src/reducers/componentReducer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
DELETE_CHILD,
1414
DELETE_COMPONENT,
1515
TOGGLE_STATE,
16+
TOGGLE_CLASS,
1617
CHANGE_FOCUS_COMPONENT,
1718
CHANGE_FOCUS_CHILD,
1819
CHANGE_COMPONENT_FOCUS_CHILD,
@@ -53,7 +54,8 @@ import {
5354
deleteProp,
5455
updateHtmlAttr,
5556
updateChildrenSort,
56-
toggleComponentState
57+
toggleComponentState,
58+
toggleComponentClass
5759
} from '../utils/componentReducer.util.ts';
5860
import cloneDeep from '../utils/cloneDeep.ts';
5961

@@ -130,6 +132,8 @@ const componentReducer = (state = initialApplicationState, action: Action) => {
130132
return deleteComponent(state, action.payload);
131133
case TOGGLE_STATE:
132134
return toggleComponentState(state, action.payload);
135+
case TOGGLE_CLASS:
136+
return toggleComponentClass(state, action.payload);
133137
case CHANGE_FOCUS_COMPONENT:
134138
return changeFocusComponent(state, action.payload);
135139
case CHANGE_FOCUS_CHILD:

0 commit comments

Comments
 (0)