omnivore/packages/web/components/elements/Checkbox.tsx

45 lines
1 KiB
TypeScript
Raw Normal View History

2022-05-09 17:12:09 +00:00
import React from 'react'
import { styled } from '@stitches/react'
import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
import { CheckIcon } from './images/CheckIcon'
const Checkbox = styled(CheckboxPrimitive.Root, {
all: 'unset',
width: 16,
height: 16,
minWidth: 16,
minHeight: 16,
2022-05-09 17:12:09 +00:00
borderRadius: 3,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
})
const CheckboxIndicator = styled(CheckboxPrimitive.Indicator, {
color: '#FFFFFF',
})
2022-06-03 08:23:05 +00:00
export const CheckboxComponent: React.FC<{
checked: boolean
setChecked: (arg: boolean) => void
}> = ({ checked, setChecked }) => {
const toggleChecked = () => setChecked(!checked)
2022-05-09 17:12:09 +00:00
return (
2022-06-03 08:23:05 +00:00
<Checkbox
css={{
border: checked ? '2px solid #F9D354' : '2px solid #3F3E3C4D',
backgroundColor: checked ? '#F9D354' : '#FFFFFF',
}}
checked={checked}
onCheckedChange={toggleChecked}
>
2022-05-09 17:12:09 +00:00
<CheckboxIndicator>
<CheckIcon />
</CheckboxIndicator>
</Checkbox>
)
}
export default CheckboxComponent