Skip to content

Commit 32924f6

Browse files
committed
[FEAT] Allow radio buttons to have children
1 parent e11e843 commit 32924f6

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/RadioButton/RadioButton.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ export default function RadioButton(props) {
2323
{props.label && (
2424
<span className="RadioButton__label">{props.label}</span>
2525
)}
26+
27+
{props.children && (
28+
<div className="RadioButton__children">
29+
{props.children}
30+
</div>
31+
)}
2632
</label>
2733
);
2834
}
2935

3036
RadioButton.propTypes = {
3137
bordered: PropTypes.bool,
38+
children: PropTypes.node,
3239
disabled: PropTypes.bool,
3340
id: PropTypes.string.isRequired,
3441
label: PropTypes.string.isRequired,
@@ -38,6 +45,7 @@ RadioButton.propTypes = {
3845

3946
RadioButton.defaultProps = {
4047
bordered: false,
48+
children: null,
4149
disabled: false,
4250
name: '',
4351
radioButtonProps: {},

src/RadioButton/RadioButton.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
@import '../../scss/theme';
2-
@import '../../scss/borders';
1+
@import 'scss/theme';
2+
@import 'scss/borders';
33

44
.RadioButton {
55
display: flex;
66
align-items: center;
77
padding: 0.5rem;
88
border: 1px solid transparent;
9+
flex-wrap: wrap;
910

1011
&--bordered {
1112
border: 1px solid $ux-gray-400;
@@ -16,4 +17,9 @@
1617
flex-grow: 1;
1718
margin-left: 0.5rem;
1819
}
20+
21+
&__children {
22+
margin-top: 0.5rem;
23+
width: 100%;
24+
}
1925
}

stories/RadioButton.stories.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import React from 'react';
22
import { withA11y } from '@storybook/addon-a11y';
33
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
44

5-
import RadioButton from '../src/RadioButton/RadioButton';
5+
import RadioButton from 'src/RadioButton/RadioButton';
66

7-
import { withPadding } from './decorators';
7+
import { withPadding } from 'stories/decorators';
8+
import { palette } from 'src/Styles';
89

910
export default {
1011
title: 'Design System/Form Elements/Radio Button',
@@ -20,3 +21,13 @@ export const Default = () => (
2021
label={text('Label', 'label')}
2122
/>
2223
);
24+
25+
export const WithChildren = () => (
26+
<RadioButton
27+
label="Option with child"
28+
bordered
29+
id="default"
30+
>
31+
<span style={{ color: palette.uxGray500 }}>Some descriptive text for the option above</span>
32+
</RadioButton>
33+
);

0 commit comments

Comments
 (0)