feature(components): prop-type ButtonGroup component

This commit is contained in:
Alexander Klein 2021-02-16 11:51:17 +01:00
parent 3d910c2367
commit 244fd6e494

View File

@ -1,16 +1,10 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames'; import classNames from 'classnames';
import Button from './Button'; import Button from './Button';
import styles from './ButtonGroup.module.css'; import styles from './ButtonGroup.module.css';
export default function ButtonGroup({ function ButtonGroup({ items = [], selectedItem, className, size, icon, onClick = () => {} }) {
items = [],
selectedItem,
className,
size,
icon,
onClick = () => {},
}) {
return ( return (
<div className={classNames(styles.group, className)}> <div className={classNames(styles.group, className)}>
{items.map(item => { {items.map(item => {
@ -30,3 +24,19 @@ export default function ButtonGroup({
</div> </div>
); );
} }
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;