Skip to content

Commit dfc1cda

Browse files
Fixed 2 and 3 column not rendering properly (#304)
* Fixed 2 and 3 column not rendering properly * Fixed styling & made rendering conditional
1 parent f6e82eb commit dfc1cda

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

src/components/templates/DefaultForm/DefaultForm.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@
2323
.psdk-default-form-three-column .grid-column {
2424
grid-column: 1 / span 3;
2525
}
26+
27+
.psdk-default-form-instruction-text{
28+
padding-top: 0.625rem;
29+
padding-bottom: 0.625rem;
30+
}
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { createElement } from "react";
2-
import PropTypes from "prop-types";
1+
import React, { createElement } from 'react';
2+
import PropTypes from 'prop-types';
33
import { getInstructions } from '../utils';
44
import createPConnectComponent from '../../../bridge/react_pconnect';
55

@@ -12,19 +12,19 @@ export default function DefaultForm(props) {
1212

1313
let divClass: string;
1414

15-
const numCols = NumCols || "1";
15+
const numCols = NumCols || '1';
1616
switch (numCols) {
17-
case "1" :
18-
divClass = "psdk-default-form-one-column";
17+
case '1':
18+
divClass = 'psdk-default-form-one-column';
1919
break;
20-
case "2" :
21-
divClass = "psdk-default-form-two-column";
20+
case '2':
21+
divClass = 'psdk-default-form-two-column';
2222
break;
23-
case "3" :
24-
divClass = "psdk-default-form-three-column";
23+
case '3':
24+
divClass = 'psdk-default-form-three-column';
2525
break;
26-
default :
27-
divClass = "psdk-default-form-one-column";
26+
default:
27+
divClass = 'psdk-default-form-one-column';
2828
break;
2929
}
3030

@@ -34,15 +34,17 @@ export default function DefaultForm(props) {
3434
// to take the children and create components for them, put in an array and pass as the
3535
// defaultForm kids
3636
const arChildren = getPConnect().getChildren()[0].getPConnect().getChildren();
37-
// eslint-disable-next-line react/no-array-index-key
38-
const dfChildren = arChildren.map((kid, idx) => createElement(createPConnectComponent(), {...kid, key: idx}));
37+
const dfChildren = arChildren.map((kid, idx) =>
38+
// eslint-disable-next-line react/no-array-index-key
39+
createElement(createPConnectComponent(), { ...kid, key: idx })
40+
);
3941

4042
return (
41-
<div className={divClass}>
42-
<div>{instructionText}</div>
43-
{dfChildren}
44-
</div>
45-
)
43+
<>
44+
{instructionText && <div className='psdk-default-form-instruction-text'>{instructionText}</div>}
45+
<div className={divClass}>{dfChildren}</div>
46+
</>
47+
);
4648
}
4749

4850
DefaultForm.propTypes = {
@@ -51,5 +53,5 @@ DefaultForm.propTypes = {
5153
};
5254

5355
DefaultForm.defaultProps = {
54-
NumCols: "1"
56+
NumCols: '1'
5557
};

0 commit comments

Comments
 (0)