Skip to content

Commit 2849508

Browse files
committed
merged with PRs #1,2,3,4
2 parents 2a8ae0c + da53d41 commit 2849508

File tree

11 files changed

+372
-192
lines changed

11 files changed

+372
-192
lines changed

app/src/components/form/Selector.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// 100% Caret
2+
import React from 'react';
3+
import FormControl from '@material-ui/core/FormControl';
4+
import Select from '@material-ui/core/Select';
5+
import MenuItem from '@material-ui/core/MenuItem';
6+
7+
const FormSelector = (props): JSX.Element => {
8+
const items = [];
9+
props.items.forEach(el => {
10+
items.push(<MenuItem value={el.value}>{el.text}</MenuItem>);
11+
})
12+
return (
13+
<div className={props.classes.configRow}>
14+
<div className={props.isThemeLight ? `${props.classes.configType} ${props.classes.lightThemeFontColor}` : `${props.classes.configType} ${props.classes.darkThemeFontColor}`}>
15+
<h3>{props.title}</h3>
16+
</div>
17+
<div className={props.classes.configValue}>
18+
<FormControl variant="filled" className={props.classes.formControl}>
19+
<Select
20+
value={props.selectValue}
21+
name={props.name}
22+
onChange={props.handleChange}
23+
displayEmpty
24+
className={props.classes.select}
25+
inputProps={{ className: props.isThemeLight ? `${props.classes.selectInput} ${props.classes.lightThemeFontColor}` : `${props.classes.selectInput} ${props.classes.darkThemeFontColor}` }}
26+
>
27+
{items}
28+
</Select>
29+
</FormControl>
30+
</div>
31+
</div>
32+
);
33+
};
34+
35+
export default FormSelector;

app/src/components/left/HTMLItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ const HTMLItem : React.FC<{
119119
})
120120
);
121121
};
122-
122+
// Caret updated the id's to reflect the new element types input and label
123123
return ( // HTML Elements
124124
<Grid item xs={5} key={`html-g${name}`}>
125-
{ id <= 11 &&
125+
{ id <= 13 &&
126126
<div ref={drag} className={isThemeLight ? `${classes.HTMLPanelItem} ${classes.lightThemeFontColor}` : `${classes.HTMLPanelItem} ${classes.darkThemeFontColor}`} id="HTMLItem">
127127
<h3>{name}</h3>
128128
</div>}
129-
{id > 11 &&
129+
{id > 13 &&
130130
<span id="customHTMLElement">
131131
<div ref={drag} className={isThemeLight ? `${classes.HTMLPanelItem} ${classes.lightThemeFontColor}` : `${classes.HTMLPanelItem} ${classes.darkThemeFontColor}`} id="HTMLItem">
132132
<h3>{name}</h3>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// 100% Caret
2+
import React, {
3+
useState, useCallback, useContext, useEffect,
4+
} from 'react';
5+
import Button from '@material-ui/core/Button';
6+
import Box from '@material-ui/core/Box';
7+
import './renderDemo.css';
8+
import StateContext from '../../context/context';
9+
10+
11+
const DemoRender = (props): JSX.Element => {
12+
const [components, setComponents] = useState([]);
13+
const [state, dispatch] = useContext(StateContext);
14+
const demoContainerStyle = {
15+
width: '100%',
16+
backgroundColor: 'lightgrey',
17+
border: '2px Solid grey',
18+
};
19+
20+
const componentBuilder = (array, key = 0) => {
21+
const componentsToRender = [];
22+
for (const element of array) {
23+
if (element.name !== 'separator') {
24+
console.log('detail from children array', element);
25+
const elementType = element.name;
26+
const childId = element.childId;
27+
const elementStyle = element.style;
28+
const innerText = element.attributes.compText;
29+
const classRender = element.attributes.cssClasses;
30+
let renderedChildren;
31+
if (elementType !== 'input' && elementType !== 'img' && element.children.length > 0) {
32+
renderedChildren = componentBuilder(element.children);
33+
}
34+
if (elementType === 'input' || elementType === 'img') componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={childId}>{innerText}</Box>);
35+
else componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={childId}>{innerText}{renderedChildren}</Box>);
36+
key += 1;
37+
}
38+
}
39+
return componentsToRender;
40+
};
41+
42+
useEffect(() => {
43+
const childrenArray = state.components[0].children;
44+
console.log('Refrenced Children in State!!!', childrenArray);
45+
const renderedComponents = componentBuilder(childrenArray);
46+
setComponents(renderedComponents);
47+
}, [state.components]);
48+
49+
return (
50+
<div id={'renderFocus'} style={demoContainerStyle}>
51+
{components.map((component, index) => component)}
52+
</div>
53+
);
54+
};
55+
56+
export default DemoRender;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.text-color {
2+
color: #cc0707;
3+
}
4+
.btn {
5+
height: 20px;
6+
width: 100px;
7+
background-color: #cc0707;
8+
}

app/src/containers/MainContainer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
import React, { useContext } from 'react';
1+
import React, { useState, useContext, useEffect } from 'react';
22
import BottomPanel from '../components/bottom/BottomPanel';
33
import CanvasContainer from '../components/main/CanvasContainer';
44
import { styleContext } from './AppContainer';
5+
import DemoRender from '../components/main/DemoRender';
56

67
const MainContainer = () => {
78
const { style } = useContext(styleContext);
9+
10+
811
return (
912
<div className="main-container" style={style} >
1013
<div className="main">
1114
<CanvasContainer />
15+
{/* Caret Component Render */}
16+
<DemoRender />
1217
</div>
1318
<BottomPanel />
1419
</div>

0 commit comments

Comments
 (0)