Skip to content

Commit e928fe8

Browse files
committed
image shows up inside Link, no functionality yet
1 parent a2e3b98 commit e928fe8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

app/src/components/main/DemoRender.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const DemoRender = (): JSX.Element => {
7070
const componentBuilder = (array: object, key: number = 0) => {
7171
const componentsToRender = [];
7272
for (const element of array) {
73-
73+
console.log('array', array);
7474
if (element.name !== 'separator') {
7575
const elementType = element.name;
7676
const childId = element.childId;
@@ -79,13 +79,13 @@ const DemoRender = (): JSX.Element => {
7979
const classRender = element.attributes.cssClasses;
8080
const activeLink = element.attributes.compLink;
8181
let renderedChildren;
82-
if (elementType !== 'input' && elementType !== 'img' && element.children.length > 0) {
82+
if (elementType !== 'input' && elementType !== 'img' && elementType !== 'Image' && element.children.length > 0) {
8383
renderedChildren = componentBuilder(element.children);
8484
}
8585
if (elementType === 'input') componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
8686
else if (elementType === 'img') componentsToRender.push(<Box component={elementType} src={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
8787
else if (elementType === 'Image') componentsToRender.push(<Box component='img' src={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
88-
else if (elementType === 'a' || elementType === 'Link') componentsToRender.push(<Box component='a' href={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}</Box>);
88+
else if (elementType === 'a' || elementType === 'Link') componentsToRender.push(<Box component='a' href={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}{renderedChildren}</Box>);
8989
else if (elementType === 'Switch') componentsToRender.push(<Switch>{renderedChildren}</Switch>);
9090
else if (elementType === 'Route') componentsToRender.push(<Route exact path={activeLink}>{renderedChildren}</Route>);
9191
else componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}{renderedChildren}</Box>
@@ -98,9 +98,10 @@ const DemoRender = (): JSX.Element => {
9898

9999
let code = '';
100100
const currComponent = state.components.find(element => element.id === state.canvasFocus.componentId);
101+
101102
componentBuilder(currComponent.children).forEach(element => {
102103
try{
103-
code += ReactDOMServer.renderToString(element)
104+
code += ReactDOMServer.renderToString(element);
104105
} catch {
105106
return;
106107
}
@@ -111,6 +112,7 @@ const DemoRender = (): JSX.Element => {
111112
}, [])
112113

113114
useEffect(() => {
115+
console.log('code', code);
114116
iframe.current.contentWindow.postMessage(code, '*');
115117
}, [code])
116118

app/src/reducers/componentReducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ const reducer = (state: State, action: Action) => {
397397
const canvasFocus = { ...state.canvasFocus, componentId, childId };
398398
//makes it so the code preview will update when clicking on a new component
399399
const components = state.components.map(element => {
400+
console.log('element', element);
400401
return Object.assign({}, element);
401402
});
402403
return { ...state, components, canvasFocus };

0 commit comments

Comments
 (0)