Skip to content

Commit 4b48065

Browse files
working on deleting nested els
1 parent cbcc7d8 commit 4b48065

File tree

15 files changed

+57
-74
lines changed

15 files changed

+57
-74
lines changed

app/electron/main.js

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,6 @@ app.on('web-contents-created', (event, contents) => {
225225
'https://reactype.herokuapp.com',
226226
'https://github.com/',
227227
'https://nextjs.org',
228-
'https://nextjs.org/',
229-
'http://nextjs.org',
230-
'http://nextjs.org/',
231-
'https://www.nextjs.org',
232-
'https://www.nextjs.org/',
233-
'http://www.nextjs.org',
234-
'http://www.nextjs.org/',
235228
];
236229
console.log('parsed URL origin', parsedUrl.origin);
237230
// Log and prevent the app from navigating to a new page if that page's origin is not whitelisted
@@ -253,13 +246,6 @@ app.on('web-contents-created', (event, contents) => {
253246
'https://reactype.herokuapp.com',
254247
'https://github.com/',
255248
'https://nextjs.org',
256-
'https://nextjs.org/',
257-
'http://nextjs.org',
258-
'http://nextjs.org/',
259-
'https://www.nextjs.org',
260-
'https://www.nextjs.org/',
261-
'http://www.nextjs.org',
262-
'http://www.nextjs.org/',
263249
];
264250

265251
// Log and prevent the app from redirecting to a new page
@@ -273,7 +259,7 @@ app.on('web-contents-created', (event, contents) => {
273259

274260
event.preventDefault();
275261
return;
276-
}
262+
} else console.log('Succesful link sent to browser');
277263
});
278264

279265
// https://electronjs.org/docs/tutorial/security#11-verify-webview-options-before-creation
@@ -299,13 +285,6 @@ app.on('web-contents-created', (event, contents) => {
299285
'https://reactype.herokuapp.com',
300286
'https://github.com/',
301287
'https://nextjs.org',
302-
'https://nextjs.org/',
303-
'http://nextjs.org',
304-
'http://nextjs.org/',
305-
'https://www.nextjs.org',
306-
'https://www.nextjs.org/',
307-
'http://www.nextjs.org',
308-
'http://www.nextjs.org/',
309288
];
310289
console.log('parsed URL origin', parsedUrl.origin);
311290
// Log and prevent the app from navigating to a new page if that page's origin is not whitelisted
@@ -316,9 +295,9 @@ app.on('web-contents-created', (event, contents) => {
316295
// if the requested URL is not in the whitelisted array, then don't navigate there
317296
event.preventDefault();
318297
return;
319-
} else console.log(`Successful navigation to ${parsedUrl}`);
320-
event.preventDefault();
321-
return;
298+
} else console.log(`Successful new window to ${parsedUrl}`);
299+
// event.preventDefault();
300+
// return;
322301
});
323302
});
324303

app/src/components/bottom/CodePreview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import useResizeObserver from '../../tree/useResizeObserver';
1313

1414
const CodePreview = ({ theme, setTheme }) => {
1515
const wrapper = useRef();
16-
console.log(wrapper.current);
16+
//console.log(wrapper.current);
1717
const dimensions = useResizeObserver(wrapper);
1818
const { width, height } =
1919
dimensions || 0;
@@ -35,7 +35,7 @@ const CodePreview = ({ theme, setTheme }) => {
3535

3636
useEffect(() => {
3737
setDivHeight(height);
38-
console.log(divHeight);
38+
//console.log(divHeight);
3939
}, [height])
4040

4141
return (

app/src/components/main/Canvas.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,25 @@ import { Component, DragItem } from '../../interfaces/Interfaces';
66
import { combineStyles } from '../../helperFunctions/combineStyles';
77
import renderChildren from '../../helperFunctions/renderChildren';
88

9+
const findNestedChild = (curr, components) => {
10+
components.forEach((comp, i) => {
11+
comp.children.forEach(child => {
12+
if (child.name === curr.name) console.log(child.name)
13+
});
14+
if (comp.children.length !== 0) findNestedChild(curr, comp.children);
15+
});
16+
}
17+
918
function Canvas() {
1019
const [state, dispatch] = useContext(StateContext);
11-
console.log('state.comps', state.components);
1220

1321
// find the current component to render on the canvas
1422
const currentComponent: Component = state.components.find(
1523
(elem: Component) => elem.id === state.canvasFocus.componentId
1624
);
1725

26+
findNestedChild(currentComponent, state.components);
27+
1828
// changes focus of the canvas to a new component / child
1929
const changeFocus = (componentId: number, childId: number | null) => {
2030
dispatch({ type: 'CHANGE FOCUS', payload: { componentId, childId } });

app/src/containers/RightContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ const RightContainer = (): JSX.Element => {
215215
}
216216

217217
const handleDeleteReusableComponent = () => {
218-
/*isChildOfPage()
218+
isChildOfPage()
219219
? handleDialogError('component')
220-
:*/ dispatch({ type: 'DELETE REUSABLE COMPONENT', payload: {} });
220+
: dispatch({ type: 'DELETE REUSABLE COMPONENT', payload: {} });
221221
};
222222

223223
const isReusable = (configTarget): boolean => {

app/src/reducers/componentReducer.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,21 @@ const reducer = (state: State, action: Action) => {
127127
}
128128

129129
const deleteComponentFromPages = (components, name) => {
130+
console.log('name', name);
130131
const searchNestedComps = (childComponents) => {
131-
console.log(childComponents);
132-
if (childComponents.length === 0) return;
133-
childComponents.forEach((comp, i) => {
134-
if (comp.isPage){
135-
comp.children.forEach((child, i, arr) => {
136-
if (child.name === name) {
137-
arr.splice(i, 1);
138-
}
139-
})
140-
}
141-
searchNestedComps(childComponents.children)
142-
});
132+
console.log('child components', childComponents);
133+
// if (childComponents.length === 0) return console.log('empty children array');
134+
// childComponents.forEach((comp, i, arr) => {
135+
// console.log('each individual comp', comp);
136+
// if (comp.name === name){
137+
// arr.splice(i, 1);
138+
// } else searchNestedComps(childComponents.children)
139+
// });
143140
}
144-
components.forEach(comp => searchNestedComps(comp.children));
141+
components.forEach(comp => {
142+
console.log('current comp', comp);
143+
searchNestedComps(comp.children)
144+
});
145145
console.log(components);
146146
}
147147

@@ -393,7 +393,7 @@ const reducer = (state: State, action: Action) => {
393393
updateIds(components);
394394

395395
// check if reusable comp is inside a page
396-
deleteComponentFromPages(components, name);
396+
//deleteComponentFromPages(components, name);
397397

398398
const canvasFocus = { componentId: 1, childId: null };
399399

app/src/tutorial/RouteLinks.tsx

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import React from 'react';
22
import { Link, withRouter, RouteComponentProps } from 'react-router-dom';
3-
import AccountTreeIcon from '@material-ui/icons/AccountTree';
4-
53
import { makeStyles } from '@material-ui/core/styles';
6-
import Typography from '@material-ui/core/Typography';
7-
import Container from '@material-ui/core/Container';
8-
import link1 from '../../../resources/route_links_tutorial_images/links1.png';
9-
import tree2 from '../../../resources/tree_tutorial_images/tree2.png';
10-
import tree3 from '../../../resources/tree_tutorial_images/tree3.png';
11-
import tree4 from '../../../resources/tree_tutorial_images/tree4.png';
12-
import tree5 from '../../../resources/tree_tutorial_images/tree5.png';
13-
import pages from '../../../resources/tree_tutorial_images/pages.png';
14-
import re_comps from '../../../resources/tree_tutorial_images/re_comps.png';
4+
import links2 from '../../../resources/route_links_tutorial_images/links2.png';
5+
import links3 from '../../../resources/route_links_tutorial_images/links3.png';
6+
import links4 from '../../../resources/route_links_tutorial_images/links4.png';
7+
import links6 from '../../../resources/route_links_tutorial_images/links6.png';
8+
import linksCanvas from '../../../resources/route_links_tutorial_images/links-canvas.png';
159
// import Grid from '@material-ui/core/Grid';
1610

1711
// import ComponentPanel from '../components/left/ComponentPanel';
@@ -35,9 +29,13 @@ const ComponentTree: React.FC<RouteComponentProps> = () => {
3529
margin: '30px 30px 30px 30px',
3630
width: 'auto'
3731
},
38-
img: {
32+
smallImg: {
3933
borderRadius: '3px',
40-
// alignSelf: 'center'
34+
height: '300px',
35+
marginRight: '20px'
36+
},
37+
largeImg: {
38+
height: '700px'
4139
},
4240
imgWrapper: {
4341
display: 'flex',
@@ -51,30 +49,25 @@ const ComponentTree: React.FC<RouteComponentProps> = () => {
5149
return (
5250
<div className={classes.wrapper}>
5351
<h1 className={classes.title}>Next.js Route Links</h1>
54-
<h2></h2>
55-
<p className={classes.text}>Users are able to drag-and-drop 'Link' components which allow navigation to different pages.</p>
56-
<p className={classes.text}>For more information on 'Link', please <a href="https://nextjs.org/docs/api-reference/next/link" target="_blank">visit the official documentation on nextjs.org.</a></p>
52+
<h2>Route Links are only available for Next.js projects.</h2>
53+
<p className={classes.text}>Users are able to drag-and-drop 'Link' components onto the canvas which allow navigation to different pages.</p>
5754
<div className={classes.imgWrapper}>
58-
<img className={classes.img} src={link1}></img>
55+
<img className={classes.largeImg} src={linksCanvas}></img>
5956
</div>
60-
<p className={classes.text}>Each tree begins with a root node. The current page that is selected represents the root node.</p>
57+
<p className={classes.text}>Each page found in the 'Pages' section can be navigated to via a 'Link'. Clicking on the 'Route Link' dropdown will display all the created pages in your application.</p>
6158
<div className={classes.imgWrapper}>
62-
{/* <img className={classes.img} src={pages}></img> */}
63-
<img className={classes.img} src={tree2}></img>
59+
<img className={classes.smallImg} src={links2}></img>
60+
<img className={classes.smallImg} src={links3}></img>
6461
</div>
65-
<p className={classes.text}>Reusable components are shown attached to the current page along with their subtrees of components and HTML elements.</p>
66-
<div className={classes.imgWrapper}>
67-
{/* <img className={classes.img} src={re_comps}></img> */}
68-
<img className={classes.img} src={tree3}></img>
69-
</div>
70-
<p className={classes.text}>HTML elements are shown by their tag name.</p>
62+
<p className={classes.text}>The code generator will automatically <code>import Link from 'next/link'</code> and create your Link component in the bottom panel.</p>
7163
<div className={classes.imgWrapper}>
72-
<img className={classes.img} src={tree4}></img>
64+
<img className={classes.largeImg} src={links4}></img>
7365
</div>
74-
<p className={classes.text}>You can also view the tree for each reusable component.</p>
66+
<p className={classes.text}>Clicking on a Link component on the canvas will navigate to the corresponding page.</p>
7567
<div className={classes.imgWrapper}>
76-
<img className={classes.img} src={tree5}></img>
68+
<img className={classes.smallImg} src={links6}></img>
7769
</div>
70+
<p className={classes.text}>For more information on 'Link' for Next.js, please <a href="https://nextjs.org/docs/api-reference/next/link" target="_blank">visit the official documentation on nextjs.org.</a></p>
7871
<Link to={`/tutorial`}>
7972
<button>Tutorial</button>
8073
</Link>

app/src/tutorial/TutorialPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const useStyles = makeStyles({
1515
tutorial_page: {
1616
display: 'flex',
1717
flexDirection: 'row',
18-
justifyContent: 'center'
18+
justifyContent: 'center',
19+
fontSize: '30px'
1920
},
2021
main_tutorial: {
2122
flexGrow: 2
-17.8 KB
Binary file not shown.
-2.5 KB
Binary file not shown.
Loading
489 Bytes
Loading
3.01 KB
Loading
38.3 KB
Loading
5.83 KB
Loading
4.16 KB
Loading

0 commit comments

Comments
 (0)