Skip to content

Commit cedb714

Browse files
committed
linked pages to the link component dropdown menu
1 parent 5f0e3ce commit cedb714

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

app/src/components/main/AddLink.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { InputLabel } from '@material-ui/core';
88

99

1010
function AddLink({ id }: AddRoutes) {
11-
const [, dispatch] = useContext(StateContext);
12-
11+
const [state, dispatch] = useContext(StateContext);
12+
console.log('AddLink\'s state', state);
1313
const handleClick = (id) => {
1414
dispatch({
1515
type: 'ADD CHILD',
@@ -21,17 +21,26 @@ function AddLink({ id }: AddRoutes) {
2121
});
2222
}
2323

24+
const handlePageSelect = event => {
25+
const selectedPageName = event.target.value;
26+
console.log('selectedPages State: ', selectedPageName);
27+
// dispatch({ type: 'HREF TO', payload: });
28+
}
29+
30+
console.log('state', state);
31+
let pagesItems = state.components.filter(comp => state.rootComponents.includes(comp.id));
32+
let dropDown = pagesItems.map(comp => <MenuItem value={comp.name}>{comp.name}</MenuItem>);
2433
return (
2534
<div style={{ padding: '1px', float: 'right' }}>
2635
<FormControl size='small'>
27-
<Select
28-
variant="outlined"
29-
>
30-
<MenuItem>Classic React</MenuItem>
31-
<MenuItem>Gatsby.js</MenuItem>
32-
<MenuItem>Next.js</MenuItem>
33-
</Select>
34-
</FormControl>
36+
<InputLabel>Pages</InputLabel>
37+
<Select variant="outlined"
38+
onChange={handlePageSelect}
39+
id="page-select"
40+
>
41+
{dropDown}
42+
</Select>
43+
</FormControl>
3544
</div>
3645
);
3746
}

app/src/components/right/ComponentDrag.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import ComponentPanelItem from './ComponentPanelItem';
55
import ComponentPanelRoutingItem from './ComponentPanelRoutingItem';
66
import { makeStyles } from '@material-ui/core/styles';
77
// The component panel section of the left panel displays all components and has the ability to add new components
8-
const ComponentDrag = ({isThemeLight}): JSX.Element => {
8+
const ComponentDrag = ({ isThemeLight }): JSX.Element => {
99
const classes = useStyles();
10-
const [state, ] = useContext(StateContext);
10+
const [state,] = useContext(StateContext);
1111
const isFocus = (targetId: Number) => {
1212
return state.canvasFocus.componentId === targetId ? true : false;
1313
};
@@ -18,26 +18,26 @@ const ComponentDrag = ({isThemeLight}): JSX.Element => {
1818
{/* Font size for 'index' in root components in .compPanelItem h3 style.css */}
1919
<div className={classes.panelWrapperList}>
2020
{/* Heading just below ADD button */}
21-
<h4 className={ isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>{state.projectType === 'Next.js' || state.projectType === 'Gatsby.js' ? 'Pages' : 'Root Components'}</h4>
21+
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>{state.projectType === 'Next.js' || state.projectType === 'Gatsby.js' ? 'Pages' : 'Root Components'}</h4>
2222
<Grid container direction="row" justify="center" alignItems="center">
2323
{state.components
2424
.filter(comp => state.rootComponents.includes(comp.id))
2525
.map(comp => {
2626
return (
27-
<ComponentPanelItem
27+
<ComponentPanelItem
2828
isFocus={isFocus(comp.id)}
2929
key={`comp-${comp.id}`}
3030
name={comp.name}
3131
id={comp.id}
3232
root={true}
3333
isThemeLight={isThemeLight}
34-
/>
35-
34+
/>
35+
3636
);
3737
})}
3838
</Grid>
3939
{/* Display all reusable components */}
40-
<h4 className={ isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>Reusable Components</h4>
40+
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>Reusable Components</h4>
4141
<Grid container direction="row" justify="center" alignItems="center">
4242
{state.components
4343
.filter(comp => !state.rootComponents.includes(comp.id))
@@ -55,7 +55,7 @@ const ComponentDrag = ({isThemeLight}): JSX.Element => {
5555
})}
5656
</Grid>
5757
{/* Display routing components - (only applies to next.js or gatsby.js which has routing built in) */}
58-
{state.projectType === 'Next.js' || state.projectType === 'Gatsby.js'? (
58+
{/* {state.projectType === 'Next.js' || state.projectType === 'Gatsby.js'? (
5959
<React.Fragment>
6060
<h4>Routing</h4>
6161
<Grid
@@ -69,7 +69,7 @@ const ComponentDrag = ({isThemeLight}): JSX.Element => {
6969
</React.Fragment>
7070
) : (
7171
''
72-
)}
72+
)} */}
7373
</div>
7474
</div>
7575
);
@@ -78,9 +78,9 @@ const ComponentDrag = ({isThemeLight}): JSX.Element => {
7878
const useStyles = makeStyles({
7979
panelWrapper: {
8080
display: 'flex',
81-
flexDirection:'column',
82-
alignItems:'center',
83-
flexGrow : 1,
81+
flexDirection: 'column',
82+
alignItems: 'center',
83+
flexGrow: 1,
8484
overflow: 'auto',
8585
},
8686
panelWrapperList: {

0 commit comments

Comments
 (0)