Skip to content

Commit

Permalink
feat: add checkbox group component prop size
Browse files Browse the repository at this point in the history
  • Loading branch information
yvmunayev committed Sep 27, 2022
1 parent f5e8fac commit d87e038
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/CheckboxGroup/checkboxList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import StyledItemDescription from '../RadioGroup/styled/itemDescription';
import RenderIf from '../RenderIf';

export default function CheckboxList(props) {
const { values, options, onChange, describedBy, name, error } = props;
const { values, options, onChange, describedBy, name, error, size } = props;
return options.map((option, index) => {
const key = `checkbox-${index}`;
const { description, ...rest } = option;
Expand All @@ -22,6 +22,7 @@ export default function CheckboxList(props) {
ariaDescribedBy={describedBy}
name={name}
error={error}
size={size}
/>
<RenderIf isTrue={description}>
<StyledItemDescription>{description}</StyledItemDescription>
Expand All @@ -37,11 +38,13 @@ CheckboxList.propTypes = {
values: PropTypes.array,
onChange: PropTypes.func,
describedBy: PropTypes.string,
size: PropTypes.oneOf(['small', 'medium', 'large']),
};

CheckboxList.defaultProps = {
values: [],
onChange: () => {},
describedBy: undefined,
name: undefined,
size: 'medium',
};
1 change: 1 addition & 0 deletions src/components/CheckboxGroup/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface CheckboxGroupProps extends BaseProps {
onChange?: (values: string[]) => void;
id?: string;
orientation?: 'vertical' | 'horizontal';
size?: 'small' | 'medium' | 'large';
}

declare const CheckboxGroup: ComponentType<CheckboxGroupProps>;
Expand Down
5 changes: 5 additions & 0 deletions src/components/CheckboxGroup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class CheckboxGroup extends Component {
style,
className,
orientation,
size,
} = this.props;
return (
<StyledFieldset id={id} className={className} style={style}>
Expand All @@ -81,6 +82,7 @@ class CheckboxGroup extends Component {
name={this.groupNameId}
describedBy={this.getErrorMessageId()}
error={error}
size={size}
/>
</StyledContentContainer>
<RenderIf isTrue={error}>
Expand Down Expand Up @@ -127,6 +129,8 @@ CheckboxGroup.propTypes = {
id: PropTypes.string,
/** The orientation of the element. */
orientation: PropTypes.oneOf(['vertical', 'horizontal']),
/** The size of the input. Valid values are small, and large. */
size: PropTypes.oneOf(['small', 'medium', 'large']),
};

CheckboxGroup.defaultProps = {
Expand All @@ -143,6 +147,7 @@ CheckboxGroup.defaultProps = {
style: undefined,
id: undefined,
orientation: 'vertical',
size: 'medium',
};

export default withReduxForm(CheckboxGroup);

0 comments on commit d87e038

Please sign in to comment.