|
1 | | -import { parseFlexStyles, setStyle } from "../../utils"; |
| 1 | +import { parseFlexStyles, setStyle, excludeKeys } from "../../utils"; |
| 2 | +import SelectComponent from "../SelectComponent"; |
2 | 3 |
|
3 | 4 | const Div = ({data}) => { |
4 | | - const {HTML, CSS} = data.Properties; |
5 | | - const style = {...setStyle(data.Properties), ...parseFlexStyles(CSS)}; |
6 | | - const fillBox = {width: '100%', height: '100%', position: 'absolute', top: 0, left: 0}; |
| 5 | + const {HTML, CSS, Flex} = data.Properties; |
| 6 | + const style = {...setStyle(data.Properties, "absolute", Flex), ...parseFlexStyles(CSS)}; |
| 7 | + |
| 8 | + // If Flex is present, make both containers flex containers and don't use |
| 9 | + // any defaults - we expect the APL user to know what they're doing here. |
| 10 | + // CSS affects outer div, innerHtml is up to them and likewise with children |
| 11 | + const innerHtmlStyle = Flex ? {display: 'flex'} : {width: '100%', height: '100%', position: 'absolute', top: 0, left: 0}; |
| 12 | + const childrenStyle = Flex ? {display: 'flex'} : {width: '100%', height: '100%', position: 'absolute', top: 0, left: 0}; |
| 13 | + const updatedData = excludeKeys(data); |
| 14 | + |
7 | 15 | return ( |
8 | 16 | <div id={data.ID} style={style}> |
9 | | - <div id={data.ID+'.$INNERHTML'} dangerouslySetInnerHTML={{__html: HTML}} style={fillBox}/> |
10 | | - <div id={data.ID+'.$CHILDREN'} style={fillBox}> |
11 | | - |
| 17 | + <div id={data.ID+'.$INNERHTML'} dangerouslySetInnerHTML={{__html: HTML}} style={innerHtmlStyle}/> |
| 18 | + <div id={data.ID+'.$CHILDREN'} style={childrenStyle}> |
| 19 | + {Object.keys(updatedData).map((key) => ( |
| 20 | + <SelectComponent key={key} data={updatedData[key]} /> |
| 21 | + ))} |
12 | 22 | </div> |
13 | 23 | </div> |
14 | 24 | ); |
|
0 commit comments