Fix RadioButton style
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
0f963a93f1
commit
7750366654
2 changed files with 17 additions and 13 deletions
|
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
||||||
import './RadioButton.scss';
|
import './RadioButton.scss';
|
||||||
|
|
||||||
function RadioButton({ isActive, onToggle }) {
|
function RadioButton({ isActive, onToggle }) {
|
||||||
|
if (onToggle === null) return <span className={`radio-btn${isActive ? ' radio-btn--active' : ''}`} />;
|
||||||
return (
|
return (
|
||||||
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
||||||
<button
|
<button
|
||||||
|
@ -15,11 +16,12 @@ function RadioButton({ isActive, onToggle }) {
|
||||||
|
|
||||||
RadioButton.defaultProps = {
|
RadioButton.defaultProps = {
|
||||||
isActive: false,
|
isActive: false,
|
||||||
|
onToggle: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
RadioButton.propTypes = {
|
RadioButton.propTypes = {
|
||||||
isActive: PropTypes.bool,
|
isActive: PropTypes.bool,
|
||||||
onToggle: PropTypes.func.isRequired,
|
onToggle: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default RadioButton;
|
export default RadioButton;
|
||||||
|
|
|
@ -2,23 +2,25 @@
|
||||||
|
|
||||||
.radio-btn {
|
.radio-btn {
|
||||||
@extend .cp-fx__row--c-c;
|
@extend .cp-fx__row--c-c;
|
||||||
width: 24px;
|
width: 20px;
|
||||||
height: 24px;
|
height: 20px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background-color: var(--bg-surface-low);
|
background-color: var(--bg-surface-border);
|
||||||
box-shadow: var(--bs-surface-border);
|
border: 2px solid var(--bg-surface-border);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
background-color: var(--bg-surface-border);
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
&--active {
|
&--active {
|
||||||
background-color: var(--bg-positive);
|
border: 2px solid var(--bg-positive);
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
content: '';
|
background-color: var(--bg-positive);
|
||||||
display: inline-block;
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue