Skip to content

Commit 88c3014

Browse files
committed
Cleaned up comments and unused code and deleted customHooks.ts file
1 parent 77c6d95 commit 88c3014

File tree

7 files changed

+11
-68
lines changed

7 files changed

+11
-68
lines changed

app/src/components/bottom/BottomTabs.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ const BottomTabs = () => {
2525

2626
// breaks if handleChange is commented out
2727
const handleChange = (event: React.ChangeEvent, value: number) => {
28-
// console.log('value', value)
29-
// console.log('setTab', setTab)
3028
setTab(value);
3129
};
3230
// Allows users to toggle project between "next.js" and "Classic React"
@@ -36,7 +34,6 @@ const BottomTabs = () => {
3634
dispatch({ type: 'CHANGE PROJECT TYPE', payload: { projectType } });
3735
};
3836
const { components, HTMLTypes } = state;
39-
// console.log('components', components)
4037

4138
const changeTheme = e => {
4239
setTheme(e.target.value);

app/src/components/bottom/CodePreview.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ const CodePreview: React.FC<{
1616
setTheme: any | null;
1717
}> = ({ theme, setTheme }) => {
1818
const wrapper = useRef();
19-
// console.log('wrapper', wrapper)
2019
const dimensions = useResizeObserver(wrapper);
21-
// console.log('dimensions', dimensions)
2220
const { width, height } =
2321
dimensions || 0;
2422

@@ -27,7 +25,7 @@ const CodePreview: React.FC<{
2725
const currentComponent = state.components.find(
2826
(elem: Component) => elem.id === state.canvasFocus.componentId
2927
);
30-
// console.log('currentComp in CodePreview', currentComponent)
28+
3129
const handleCodeSnipChange = val => {
3230
currentComponent.code = val;
3331
};

app/src/components/main/Canvas.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,44 @@ import { Component, DragItem } from '../../interfaces/Interfaces';
77
import { combineStyles } from '../../helperFunctions/combineStyles';
88
import renderChildren from '../../helperFunctions/renderChildren';
99

10-
// const snapStateArr = [];
10+
1111
function Canvas() {
1212
const [state, dispatch] = useContext(StateContext);
13-
console.log('state in Canvas', state);
14-
// const [ prevState, setPrevState ] = useState<Array<object>>([]); // NOT USING
1513
// find the current component to render on the canvas
1614
const currentComponent: Component = state.components.find(
1715
(elem: Component) => elem.id === state.canvasFocus.componentId
1816
);
1917

20-
// console.log('currentComponent', currentComponent)
21-
2218
// changes focus of the canvas to a new component / child
2319
const changeFocus = (componentId: number, childId: number | null) => {
2420
dispatch({ type: 'CHANGE FOCUS', payload: { componentId, childId } });
25-
2621
};
22+
2723
// onClickHandler is responsible for changing the focused component and child component
2824
function onClickHandler(event) {
2925
event.stopPropagation();
3026
// note: a null value for the child id means that we are focusing on the top-level component rather than any child
3127
changeFocus(state.canvasFocus.componentId, null);
32-
}
28+
};
3329

3430
// stores a snapshot of state into the past array for UNDO
3531
const snapShotFunc = () => {
3632
// make a deep clone of state
3733
const deepCopiedState = JSON.parse(JSON.stringify(state));
3834
state.past.push(deepCopiedState.components[0].children);
39-
// console.log('state in snapShotFunc', state.past)
40-
}
41-
35+
};
4236

4337
// This hook will allow the user to drag items from the left panel on to the canvas
4438
const [{ isOver }, drop] = useDrop({
4539
accept: ItemTypes.INSTANCE,
4640
drop: (item: DragItem, monitor: DropTargetMonitor) => {
4741
const didDrop = monitor.didDrop();
48-
// returns false for direct drop target
42+
// takes a snapshot of state to be used in UNDO and REDO cases
4943
snapShotFunc();
44+
// returns false for direct drop target
5045
if (didDrop) {
5146
return;
5247
}
53-
// console.log('item', item)
5448
// if item dropped is going to be a new instance (i.e. it came from the left panel), then create a new child component
5549
if (item.newInstance) {
5650
dispatch({

app/src/components/main/DirectChildHTMLNestable.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ function DirectChildHTMLNestable({
1717
}: ChildElement) {
1818
const [state, dispatch] = useContext(StateContext);
1919
const ref = useRef(null);
20-
// stores a snapshot of state into the past array for nested elements for the UNDO case
20+
// takes a snapshot of state to be used in UNDO and REDO cases
2121
const snapShotFunc = () => {
2222
const deepCopiedState = JSON.parse(JSON.stringify(state));
2323
state.past.push(deepCopiedState.components[0].children);
24-
// state.future.push(deepCopiedState.components[0].children);
25-
// console.log('state.past in directChildHTMLNest', state)
2624
};
2725
// find the HTML element corresponding with this instance of an HTML element
2826
// find the current component to render on the canvas
@@ -55,6 +53,7 @@ const snapShotFunc = () => {
5553
// triggered on drop
5654
drop: (item: any, monitor: DropTargetMonitor) => {
5755
const didDrop = monitor.didDrop();
56+
// takes a snapshot of state to be used in UNDO and REDO cases
5857
snapShotFunc();
5958
if (didDrop) {
6059
return;

app/src/containers/RightContainer.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const RightContainer = ({isThemeLight}): JSX.Element => {
4343
const [deleteComponentError, setDeleteComponentError] = useState(false);
4444
const { style } = useContext(styleContext);
4545
const [modal, setModal] = useState(null);
46-
const [prevState, setPrevState] = useState(state);
4746

4847

4948
const resetFields = () => {
@@ -197,10 +196,7 @@ const RightContainer = ({isThemeLight}): JSX.Element => {
197196
return styleObj;
198197
};
199198

200-
/****************************** UNDO AND REDO ****************************************** */
201-
// undo functionality
202-
// onClick this function will be invoked.
203-
// set current state components.children to previous state and store current state children array in another place holder to not lose current state before reassigning to previous position.
199+
// UNDO/REDO functionality--onClick these functions will be invoked.
204200
const undoAction = () => {
205201
dispatch({ type: 'UNDO', payload: {} });
206202
};
@@ -523,23 +519,15 @@ const redoAction = () => {
523519
color="primary"
524520
className={classes.button}
525521
onClick={undoAction}
526-
// onClick={((e) => handleClick(e, prevCount))}
527522
>
528-
529-
{/* <i className="fas fa-backward"/> */}
530523
<i className="fas fa-undo"></i>
531524
</Button>
532525
<Button
533526
color="primary"
534527
className={classes.button}
535528
onClick={redoAction}
536-
537-
// onClick={clearComps}
538-
// onClick={redoAction}
539-
// onClick = {handleClick}
540529
>
541530
<i className="fas fa-redo"></i>
542-
{/* <i className="fas fa-forward"/> */}
543531
</Button>
544532
</div>
545533
</div>

app/src/helperFunctions/customHook.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/src/reducers/componentReducer.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,6 @@ const reducer = (state: State, action: Action) => {
192192
}
193193
};
194194

195-
/******************************* REDO ARRAY ********************************* */
196-
// let redoArr = [];
197-
// let stateSnap = [state];
198-
// console.log('stateSnap', stateSnap)
199-
// const redoArrFunc = (...htmlTag) => {
200-
// redoArr.push(...htmlTag);
201-
// return redoArr;
202-
// }
203-
204195
switch (action.type) {
205196
case 'ADD COMPONENT': {
206197
if (
@@ -628,10 +619,6 @@ const reducer = (state: State, action: Action) => {
628619
state.components[0].children = state.past[state.past.length-1];
629620
//the last element of past array gets pushed into future;
630621
state.future.push(state.past.pop());
631-
// state.past[state.past.length - 1]);
632-
//pop the last element off the past array
633-
// state.past.pop();
634-
console.log('state in UNDO', state);
635622
//generate code for the Code Preview
636623
state.components.forEach((el, i) => {
637624
el.code = generateCode(
@@ -647,16 +634,12 @@ const reducer = (state: State, action: Action) => {
647634
};
648635
}
649636
case 'REDO': {
650-
//nothing left to undo
651-
// if (state.past.length === 0) return {...state};
652637
//nothing left to redo
653638
if(state.future.length === 0) return {...state};
654639
//the children array of state.components[0] will equal the last element of the future array
655640
state.components[0].children = state.future[state.future.length - 1];
656-
//the last element of the future array gets pushed into the past array
641+
//the last element of the future array gets pushed into the past array and the last element of the future array gets popped off
657642
state.past.push(state.future.pop());
658-
//the last element of the future array gets popped off
659-
console.log('state in REDO', state);
660643
//generate code for the Code Preview
661644
state.components.forEach((el, i) => {
662645
el.code = generateCode(

0 commit comments

Comments
 (0)