Skip to content

Commit 3db4d99

Browse files
committed
fixed drop down and focus select
1 parent 68494f3 commit 3db4d99

File tree

5 files changed

+37
-28
lines changed

5 files changed

+37
-28
lines changed

app/src/components/left/DragDropPanel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const DragDropPanel = (props): JSX.Element => {
2828
};
2929

3030
// filter out separator so that it will not appear on the html panel
31-
const htmlTypesToRender = state.HTMLTypes.filter(type => type.name !== 'separator' && type.name !== 'Route');
31+
const htmlTypesToRender = state.HTMLTypes.filter(type => type.name !== 'separator');
3232
return (
3333
<div className="HTMLItems">
3434
<div id="HTMLItemsTopHalf">
@@ -37,7 +37,7 @@ const DragDropPanel = (props): JSX.Element => {
3737
>
3838
<h3 style={ {color: isThemeLight ? '#000' : '#fff'} }>HTML ELEMENTS</h3>
3939
{htmlTypesToRender.map(option => {
40-
if (!['Switch', 'LinkTo', 'LinkHref', 'Image'].includes(option.name)) {
40+
if (!['Switch', 'LinkTo', 'LinkHref', 'Image', 'Route'].includes(option.name)) {
4141
return (
4242
<HTMLItem
4343
name={option.name}
@@ -53,7 +53,7 @@ const DragDropPanel = (props): JSX.Element => {
5353
})}
5454
{state.projectType === "Classic React" ? <h3 style={ {color: isThemeLight ? '#000' : '#fff' } }>REACT ROUTER</h3> : null}
5555
{htmlTypesToRender.map(option => {
56-
if ((option.name === 'Switch' || option.name === 'LinkTo') && state.projectType === "Classic React") {
56+
if ((option.name === 'Switch' || option.name === 'LinkTo' || option.name === 'Route') && state.projectType === "Classic React") {
5757
return (
5858
<HTMLItem
5959
name={option.name}

app/src/components/main/AddLink.tsx

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

99
import { styleContext } from '../../containers/AppContainer';
1010

11-
function AddLink({ id }: AddRoutes) {
11+
function AddLink({ id, onClickHandler }) {
1212
const { isThemeLight } = useContext(styleContext);
1313
const [state, dispatch] = useContext(StateContext);
1414

@@ -25,29 +25,33 @@ function AddLink({ id }: AddRoutes) {
2525

2626
const handlePageSelect = event => {
2727
const currComponent = state.components.find(element => element.id === state.canvasFocus.componentId);
28-
currComponent.children.forEach(element => {
28+
currComponent.children.some(element => {
2929
if(element.childId === id) {
3030
const state = JSON.parse(JSON.stringify(element));
31+
state.childId = id;
3132
state.attributes.compLink = event.target.value;
3233
dispatch({type: 'UPDATE ATTRIBUTES', payload: state})
34+
return true;
3335
}
3436
});
3537
}
3638

37-
let pagesItems = state.components.filter(comp => state.rootComponents.includes(comp.id));
38-
let dropDown = pagesItems.map(comp => <MenuItem value={comp.name}>{comp.name}</MenuItem>);
39+
const pagesItems = state.components.filter(comp => state.rootComponents.includes(comp.id));
40+
const dropDown = pagesItems.map(comp => <MenuItem value={comp.name}>{comp.name}</MenuItem>);
3941

4042
return (
41-
<div style={{paddingBottom: '1px', float: 'right' }}>
42-
<FormControl size='small'>
43-
<InputLabel style={ { color: isThemeLight? '#000' : '#fff'} }>Pages</InputLabel>
44-
<Select variant="outlined"
45-
onChange={handlePageSelect}
46-
id="page-select"
47-
style={ isThemeLight? {backgroundColor: '#eef0f1', color: '#000', border: '1px solid black', height: '28px', width: '200px'} : {backgroundColor: 'gray', color: '#fff', border: '1px solid white', height: '28px', width: '200px'}}
48-
>
49-
{dropDown}
50-
</Select>
43+
<div style={{padding: '1px', float: 'right', display: 'flex', border: '2px solid red', alignSelf: 'center'}}>
44+
<FormControl size='medium' style={{display: 'flex'}}>
45+
<InputLabel style={ { color: isThemeLight? '#000' : '#fff'} }>Pages</InputLabel>
46+
<Select label='pages'
47+
variant="outlined"
48+
onMouseDown={onClickHandler}
49+
onChange={handlePageSelect}
50+
id="page-select"
51+
style={ isThemeLight? {backgroundColor: '#eef0f1', color: '#000', border: '1px solid black', height: '28px', width: '200px'} : {backgroundColor: 'gray', color: '#fff', border: '1px solid white', height: '28px', width: '200px'}}
52+
>
53+
{dropDown}
54+
</Select>
5155
</FormControl>
5256
</div>
5357
);

app/src/components/main/DirectChildHTMLNestable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ function DirectChildHTMLNestable({
143143
routeButton.push(<AddRoute id={childId} name={name} />);
144144
}
145145
if (typeId === 19) {
146-
routeButton.push(<AddLink id={childId} name={name} />);
146+
routeButton.push(<AddLink id={childId} onClickHandler={onClickHandler} name={name} />);
147147
}
148-
148+
149149
return (
150150
<div onClick={onClickHandler} style={combinedStyle} ref={ref} id={`canv${childId}`}>
151151
<strong style={ {color: isThemeLight ? 'black' : 'white'} }>{HTMLType.placeHolderShort}</strong>

app/src/containers/CustomizationPanel.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
4848
const [stateUsedObj, setStateUsedObj] = useState({});
4949

5050
const resetFields = () => {
51-
const childrenArray = state.components[0].children;
52-
let attributes;
51+
const currComponent = state.components.find(element => element.id === state.canvasFocus.componentId);
52+
const childrenArray = currComponent.children;
5353
for (const element of childrenArray) {
5454
if (configTarget.child && element.childId === configTarget.child.id) {
55-
attributes = element.attributes;
56-
setCompText(attributes.text ? attributes.text : '');
57-
setCompLink(attributes.link ? attributes.link : '');
55+
const attributes = element.attributes;
56+
const style = element.style;
57+
setCompText(attributes.compText ? attributes.compText : '');
58+
setCompLink(attributes.compLink ? attributes.compLink : '');
5859
setCssClasses(attributes.cssClasses ? attributes.cssClasses : '');
5960
}
6061
}
@@ -73,6 +74,9 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
7374
// after component renders, reset the input fields with the current styles of the selected child
7475
useEffect(() => {
7576
resetFields();
77+
// const currComponent = state.components.find(element => element.id === state.canvasFocus.componentId);
78+
// const childrenArray = currComponent.children;
79+
// console.log('childrenArray', childrenArray)
7680
}, [state.canvasFocus.componentId, state.canvasFocus.childId]);
7781
// handles all input field changes, with specific updates called based on input's name
7882
const handleChange = (e: React.ChangeEvent<{ value: any }>) => {
@@ -399,7 +403,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
399403
<FormSelector
400404
classes={classes}
401405
isThemeLight={isThemeLight}
402-
selectValue={flexAlign}
406+
selectValue={displayMode}
403407
handleChange={handleChange}
404408
title="Display:"
405409
name="display"
@@ -415,7 +419,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
415419
<FormSelector
416420
classes={classes}
417421
isThemeLight={isThemeLight}
418-
selectValue={flexAlign}
422+
selectValue={flexDir}
419423
handleChange={handleChange}
420424
title="Flex direction:"
421425
name="flexdir"
@@ -428,7 +432,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
428432
<FormSelector
429433
classes={classes}
430434
isThemeLight={isThemeLight}
431-
selectValue={flexAlign}
435+
selectValue={flexJustify}
432436
handleChange={handleChange}
433437
title="Justify content:"
434438
name="flexjust"

app/src/helperFunctions/generateCode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ const generateUnformattedCode = (
182182
return `${levelSpacer(level, 5)}<${childElement.tag} src=${activeLink} ${elementTagDetails(childElement)}/>`;
183183
} else if (nestable) {
184184
const routePath = (childElement.tag === 'Route') ? (' ' + 'exact path=' + activeLink) : '';
185-
return `${levelSpacer(level, 5)}<${childElement.tag}${elementTagDetails(childElement)}${routePath}>${innerText}
185+
return `${levelSpacer(level, 5)}<${childElement.tag}${elementTagDetails(childElement)}${routePath}>
186+
${tabSpacer(level)}${innerText}
186187
${tabSpacer(level)}${writeNestedElements(childElement.children, level + 1)}
187188
${tabSpacer(level - 1)}</${childElement.tag}>${levelSpacer(2, (3 + level))}`;
188189
} else if (childElement.tag !== 'separator') {

0 commit comments

Comments
 (0)