@bonizario-ignite-ui/react
Version:
Ignite UI react components
61 lines (51 loc) • 1.19 kB
text/typescript
import * as Checkbox from '@radix-ui/react-checkbox';
import { keyframes } from '@stitches/react';
import { styled } from '../../styles';
export const CheckboxContainer = styled(Checkbox.Root, {
all: 'unset',
width: '$6',
height: '$6',
backgroundColor: '$gray900',
borderRadius: '$xs',
lineHeight: 0,
cursor: 'pointer',
overflow: 'hidden',
boxSizing: 'border-box',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
border: '2px solid $gray900',
'&[data-state="checked"]': {
backgroundColor: '$ignite300',
},
'&:focus, &[data-state="checked"]': {
border: '2px solid $ignite300',
},
});
const slideIn = keyframes({
from: {
transform: 'translateY(-100%)',
},
to: {
transform: 'translateY(0)',
},
});
const slideOut = keyframes({
from: {
transform: 'translateY(0)',
},
to: {
transform: 'translateY(-100%)',
},
});
export const CheckboxIndicator = styled(Checkbox.Indicator, {
width: '$4',
height: '$4',
color: '$white',
'&[data-state="checked"]': {
animation: `${slideIn} 150ms ease-out`,
},
'&[data-state="unchecked"]': {
animation: `${slideOut} 150ms ease-out`,
},
});