Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styles from './FormLayoutCustomField.scss';

const FormLayoutCustomField = ({
children,
fullWidth,
id,
label,
layout,
Expand All @@ -12,6 +13,7 @@ const FormLayoutCustomField = ({
id={id}
className={`
${styles.root}
${fullWidth ? styles.isRootFullWidth : ''}
${layout === 'vertical' ? styles.rootLayoutVertical : styles.rootLayoutHorizontal}
`.trim()}
>
Expand All @@ -34,13 +36,15 @@ const FormLayoutCustomField = ({

FormLayoutCustomField.defaultProps = {
children: null,
fullWidth: false,
id: undefined,
label: null,
layout: 'vertical',
};

FormLayoutCustomField.propTypes = {
children: PropTypes.node,
fullWidth: PropTypes.bool,
id: PropTypes.string,
label: PropTypes.string,
layout: PropTypes.oneOf(['horizontal', 'vertical']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
width: auto;
}

.isRootFullWidth .field {
justify-self: stretch;
}

.root.rootLayoutHorizontal {
@include breakpoint-up($form-field-horizontal-breakpoint) {
grid-template-columns: var(--rui-local-label-width-fallback) 1fr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('rendering', () => {
it('renders correctly with all props', () => {
const tree = shallow((
<FormLayoutCustomField
fullWidth
label="Label"
id="my-custom-field"
layout="horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`rendering renders correctly with a single child 1`] = `
<div
className="root

rootLayoutVertical"
>
<div
Expand All @@ -18,6 +19,7 @@ exports[`rendering renders correctly with a single child 1`] = `
exports[`rendering renders correctly with all props 1`] = `
<div
className="root
isRootFullWidth
rootLayoutHorizontal"
id="my-custom-field"
>
Expand Down Expand Up @@ -47,6 +49,7 @@ exports[`rendering renders correctly with all props 1`] = `
exports[`rendering renders correctly with multiple children 1`] = `
<div
className="root

rootLayoutVertical"
>
<div
Expand Down
1 change: 1 addition & 0 deletions src/lib/styles/tools/forms/_layouts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

.field {
width: min-content; // 3.
max-width: 100%; // 3.
}

.helperText {
Expand Down