@chayns-components/core
Version:
A set of beautiful React components for developing your own applications with chayns.
142 lines (137 loc) • 3.31 kB
JavaScript
import { motion } from 'motion/react';
import styled, { css } from 'styled-components';
import { keyboardFocusHighlightingCircleRingCss } from '../../utils/keyboardFocusHighlighting.styles';
export const StyledRadioButton = styled.span`
display: flex;
flex-direction: column;
position: relative;
opacity: ${({
$isDisabled
}) => $isDisabled ? 0.5 : 1};
${({
$radioButtonRightElementMargin
}) => {
switch ($radioButtonRightElementMargin) {
case 'BOTH':
return css`
margin: 6px 0;
`;
case 'TOP':
return css`
margin-top: 6px;
`;
case 'BOTTOM':
return css`
margin-bottom: 6px;
`;
case 'NONE':
default:
return css`
margin: 0;
`;
}
}}
`;
export const StyledRadioButtonWrapper = styled.div`
display: flex;
align-items: center;
position: relative;
gap: 5px;
user-select: none;
`;
export const StyledRadioButtonPseudoCheckBox = styled.div`
background-color: ${({
theme,
$isChecked
}) => $isChecked ? theme['secondary-408'] : theme['secondary-403']};
opacity: 1;
border: 1px solid
rgba(${({
theme
}) => theme['409-rgb']}, 0.5);
width: 15px;
height: 15px;
position: absolute;
border-radius: 100%;
z-index: 1;
cursor: ${({
$isDisabled
}) => $isDisabled ? 'default !important' : 'pointer !important'};
`;
export const StyledRadioButtonCheckBox = styled.input`
opacity: 0;
height: 15px;
width: 15px;
cursor: ${({
$isDisabled
}) => $isDisabled ? 'default !important' : 'pointer !important'};
${({
$shouldShowKeyboardHighlighting
}) => $shouldShowKeyboardHighlighting && css`
&:focus-visible + ${StyledRadioButtonPseudoCheckBox} {
transition: none;
${keyboardFocusHighlightingCircleRingCss}
}
`}
`;
export const StyledRadioButtonCheckBoxMark = styled.span`
background-color: transparent;
position: absolute;
top: 1px;
left: 3.925px;
display: inline-block;
transform: rotate(35deg);
height: 9px;
width: 5px;
border-bottom: 2px solid white;
border-right: 2px solid white;
border-top: transparent;
border-left: transparent;
z-index: 2;
cursor: ${({
$isDisabled
}) => $isDisabled ? 'default !important' : 'pointer !important'};
${({
$isHovered,
$isSelected
}) => {
if ($isSelected) {
return css`
opacity: 1;
`;
}
if ($isHovered) {
return css`
opacity: 0.5;
`;
}
return css`
opacity: 0;
`;
}}
`;
export const StyledRadioButtonLabel = styled.div`
color: ${({
theme
}) => theme.text};
margin: 0;
cursor: ${({
$isDisabled
}) => $isDisabled ? 'default !important' : 'pointer !important'};
`;
export const StyledLabelWrapper = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
gap: 12px;
`;
export const StyledMotionRadioButtonChildren = styled(motion.div)`
margin-left: 20px;
cursor: text;
overflow: hidden;
color: ${({
theme
}) => theme.text};
`;
//# sourceMappingURL=RadioButton.styles.js.map