mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-12 02:00:28 +03:00
30 lines
751 B
JavaScript
30 lines
751 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import './RadioButton.scss';
|
|
|
|
function RadioButton({ isActive, onToggle, disabled }) {
|
|
if (onToggle === null) return <span className={`radio-btn${isActive ? ' radio-btn--active' : ''}`} />;
|
|
return (
|
|
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
|
<button
|
|
onClick={() => onToggle(!isActive)}
|
|
className={`radio-btn${isActive ? ' radio-btn--active' : ''}`}
|
|
type="button"
|
|
disabled={disabled}
|
|
/>
|
|
);
|
|
}
|
|
|
|
RadioButton.defaultProps = {
|
|
isActive: false,
|
|
onToggle: null,
|
|
disabled: false,
|
|
};
|
|
|
|
RadioButton.propTypes = {
|
|
isActive: PropTypes.bool,
|
|
onToggle: PropTypes.func,
|
|
disabled: PropTypes.bool,
|
|
};
|
|
|
|
export default RadioButton;
|