From 244fd6e494551c324deacc51f4f8dd587ac82c4d Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Tue, 16 Feb 2021 11:51:17 +0100 Subject: [PATCH] feature(components): prop-type ButtonGroup component --- components/common/ButtonGroup.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/components/common/ButtonGroup.js b/components/common/ButtonGroup.js index c91bb743..353ce690 100644 --- a/components/common/ButtonGroup.js +++ b/components/common/ButtonGroup.js @@ -1,16 +1,10 @@ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import Button from './Button'; import styles from './ButtonGroup.module.css'; -export default function ButtonGroup({ - items = [], - selectedItem, - className, - size, - icon, - onClick = () => {}, -}) { +function ButtonGroup({ items = [], selectedItem, className, size, icon, onClick = () => {} }) { return (
{items.map(item => { @@ -30,3 +24,19 @@ export default function ButtonGroup({
); } + +ButtonGroup.propTypes = { + items: PropTypes.arrayOf( + PropTypes.shape({ + label: PropTypes.node, + value: PropTypes.any.isRequired, + }), + ), + selectedItem: PropTypes.any, + className: PropTypes.string, + size: PropTypes.oneOf(['xlarge', 'large', 'medium', 'small', 'xsmall']), + icon: PropTypes.node, + onClick: PropTypes.func, +}; + +export default ButtonGroup;