♿️(frontend) improve switch component visual indicators per DSFR rules
Update switch component following accessibility consultant recommendations: make indicator outlined instead of filled when not selected and add checkmark when selected. Changes align with DSFR guidelines to improve state visibility.
This commit is contained in:
committed by
aleb_the_flash
parent
ce1c3d26d2
commit
33774a44d4
@@ -14,6 +14,7 @@ export const StyledSwitch = styled(RACSwitch, {
|
|||||||
color: 'black',
|
color: 'black',
|
||||||
forcedColorAdjust: 'none',
|
forcedColorAdjust: 'none',
|
||||||
'& .indicator': {
|
'& .indicator': {
|
||||||
|
position: 'relative',
|
||||||
width: '2.6rem',
|
width: '2.6rem',
|
||||||
height: '1.563rem',
|
height: '1.563rem',
|
||||||
border: '0.125rem solid',
|
border: '0.125rem solid',
|
||||||
@@ -27,18 +28,39 @@ export const StyledSwitch = styled(RACSwitch, {
|
|||||||
width: '1.063rem',
|
width: '1.063rem',
|
||||||
height: '1.063rem',
|
height: '1.063rem',
|
||||||
borderRadius: '1.063rem',
|
borderRadius: '1.063rem',
|
||||||
background: 'primary.800',
|
border: '2px solid',
|
||||||
transition: 'all 200ms',
|
borderColor: 'primary.800',
|
||||||
|
background: 'white',
|
||||||
|
transition: 'opacity 10ms',
|
||||||
|
transitionDelay: '0ms',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'& .checkmark': {
|
||||||
|
position: 'absolute',
|
||||||
|
display: 'block',
|
||||||
|
top: '50%',
|
||||||
|
right: '0.25rem',
|
||||||
|
transform: 'translateY(-50%)',
|
||||||
|
color: 'primary.800',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
zIndex: 1,
|
||||||
|
opacity: 0,
|
||||||
|
},
|
||||||
'&[data-selected] .indicator': {
|
'&[data-selected] .indicator': {
|
||||||
borderColor: 'primary.800',
|
borderColor: 'primary.800',
|
||||||
background: 'primary.800',
|
background: 'primary.800',
|
||||||
_before: {
|
_before: {
|
||||||
|
border: 'none',
|
||||||
background: 'white',
|
background: 'white',
|
||||||
transform: 'translateX(100%)',
|
transform: 'translateX(100%)',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'&[data-selected] .checkmark': {
|
||||||
|
opacity: 1,
|
||||||
|
transition: 'opacity 30ms',
|
||||||
|
transitionDelay: '150ms',
|
||||||
|
},
|
||||||
'&[data-disabled] .indicator': {
|
'&[data-disabled] .indicator': {
|
||||||
borderColor: 'primary.200',
|
borderColor: 'primary.200',
|
||||||
background: 'transparent',
|
background: 'transparent',
|
||||||
@@ -63,7 +85,9 @@ export type SwitchProps = StyledVariantProps<typeof StyledSwitch> &
|
|||||||
*/
|
*/
|
||||||
export const Switch = ({ children, ...props }: SwitchProps) => (
|
export const Switch = ({ children, ...props }: SwitchProps) => (
|
||||||
<StyledSwitch {...props}>
|
<StyledSwitch {...props}>
|
||||||
<div className="indicator" />
|
<div className="indicator">
|
||||||
|
<span className="checkmark">✓</span>
|
||||||
|
</div>
|
||||||
{children}
|
{children}
|
||||||
</StyledSwitch>
|
</StyledSwitch>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user