Skip to content

Commit cdf5d94

Browse files
committed
Merge branch 'Miko' of https://github.com/oslabs-beta/ReacType into calvinYuanji/CSSFixes
2 parents dc57bd6 + a4cb3d7 commit cdf5d94

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

app/src/components/main/DemoRender.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const DemoRender = (): JSX.Element => {
5353
const componentBuilder = (array: object, key: number = 0) => {
5454
const componentsToRender = [];
5555
for (const element of array) {
56+
5657
if (element.name !== 'separator') {
5758
const elementType = element.name;
5859
const childId = element.childId;
@@ -67,11 +68,15 @@ const DemoRender = (): JSX.Element => {
6768
if (elementType === 'input') componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
6869
else if (elementType === 'img') componentsToRender.push(<Box component={elementType} src={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
6970
else if (elementType === 'Image') componentsToRender.push(<Box component='img' src={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
70-
else if (elementType === 'a') componentsToRender.push(<Box component={elementType} href='javascript:void(0)' className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}</Box>);
71+
else if (elementType === 'a' || elementType === 'Link') componentsToRender.push(
72+
activeLink ?
73+
<Box component='a' href='javascript:void(0)' className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}</Box>
74+
:<Box component='a' className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}</Box>
75+
);
7176
else if (elementType === 'Switch') componentsToRender.push(<Switch>{renderedChildren}</Switch>);
7277
else if (elementType === 'Route') componentsToRender.push(<Route exact path={activeLink}>{renderedChildren}</Route>);
73-
else if (elementType === 'Link') componentsToRender.push(<Box component='a' href='javascript:void(0)' className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}</Box>)/*componentsToRender.push(<Link to={activeLink}>{innerText}</Link>);*/
74-
else componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}{renderedChildren}</Box>);
78+
else componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}{renderedChildren}</Box>
79+
);
7580
key += 1;
7681
}
7782
}

app/src/containers/CustomizationPanel.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import ProjectManager from '../components/right/ProjectManager';
2424
import StateContext from '../context/context';
2525
import FormSelector from '../components/form/Selector';
2626
import UseStateModal from '../components/bottom/UseStateModal';
27+
import { OutgoingMessage } from 'http';
2728
// Previously named rightContainer, Renamed to Customizationpanel this now hangs on BottomTabs
2829
// need to pass in props to use the useHistory feature of react router
2930
const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
@@ -47,9 +48,21 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
4748
const [useContextObj, setUseContextObj] = useState({});
4849
const [stateUsedObj, setStateUsedObj] = useState({});
4950

51+
//Miko -- save properties of nested div
52+
function deepIterate(arr) {
53+
const output = [];
54+
for(let i = 0; i < arr.length; i++) {
55+
if(arr[i].typeId === 1000) continue;
56+
output.push(arr[i]);
57+
if(arr[i].children.length) {
58+
output.push(...deepIterate(arr[i].children));
59+
}
60+
}
61+
return output;
62+
}
63+
5064
const resetFields = () => {
51-
const currComponent = state.components.find(element => element.id === state.canvasFocus.componentId);
52-
const childrenArray = currComponent.children;
65+
const childrenArray = deepIterate(configTarget.children);
5366
for (const element of childrenArray) {
5467
if (configTarget.child && element.childId === configTarget.child.id) {
5568
const attributes = element.attributes;

app/src/helperFunctions/generateCode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,13 @@ const generateUnformattedCode = (
286286
${` const [value, setValue] = useState("");${writeStateProps(currComponent.useStateCodes)}`}
287287
${!importReactRouter
288288
? ` return (
289-
<div className="${currComponent.name}" ${formatStyles(currComponent)}>
289+
<div className="${currComponent.name}" ${formatStyles(currComponent.style)}>
290290
\t${writeNestedElements(enrichedChildren)}
291291
</div>
292292
);`
293293
: ` return (
294294
<Router>
295-
<div className="${currComponent.name}" ${formatStyles(currComponent)}>
295+
<div className="${currComponent.name}" ${formatStyles(currComponent.style)}>
296296
\t${writeNestedElements(enrichedChildren)}
297297
</div>
298298
</Router>

0 commit comments

Comments
 (0)