File size: 1,120 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import { FormLabel } from '@automattic/components';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import FormRadio from 'calypso/components/forms/form-radio';
import FormRadioWithThumbnail from 'calypso/components/forms/form-radio-with-thumbnail';
import './style.scss';
const FormRadiosBar = ( { isThumbnail, checked, onChange, items, disabled } ) => {
return (
<div className={ clsx( 'form-radios-bar', { 'is-thumbnail': isThumbnail } ) }>
{ items.map( ( item, i ) =>
isThumbnail ? (
<FormRadioWithThumbnail
key={ item.value + i }
checked={ checked === item.value }
onChange={ onChange }
disabled={ disabled }
{ ...item }
/>
) : (
<FormLabel key={ item.value + i }>
<FormRadio
checked={ checked === item.value }
disabled={ disabled }
onChange={ onChange }
{ ...item }
/>
</FormLabel>
)
) }
</div>
);
};
FormRadiosBar.propTypes = {
isThumbnail: PropTypes.bool,
checked: PropTypes.string,
onChange: PropTypes.func,
items: PropTypes.array.isRequired,
};
export default FormRadiosBar;
|