Files
omnivore/packages/web/components/elements/EditLabelChip.tsx
2023-06-20 17:06:18 +08:00

61 lines
1.7 KiB
TypeScript

import { Button } from './Button'
import { SpanBox, HStack } from './LayoutPrimitives'
import { Circle, X } from 'phosphor-react'
import { isDarkTheme } from '../../lib/themeUpdater'
import { theme } from '../tokens/stitches.config'
type EditLabelChipProps = {
text: string
color: string
isSelected?: boolean
xAction: () => void
}
export function EditLabelLabelChip(props: EditLabelChipProps): JSX.Element {
const isDark = isDarkTheme()
const selectedBorder = isDark ? '#FFEA9F' : '#D9D9D9'
const unSelectedBorder = isDark ? 'transparent' : '#DEDEDE'
const xUnselectedColor = isDark ? '#6A6968' : '#DEDEDE'
return (
<SpanBox
css={{
display: 'inline-table',
margin: '2px',
fontSize: '11px',
fontWeight: '500',
fontFamily: '$inter',
padding: '1px 7px',
whiteSpace: 'nowrap',
cursor: 'pointer',
backgroundClip: 'padding-box',
borderRadius: '5px',
borderWidth: '1px',
borderStyle: 'solid',
color: isDark ? '#EBEBEB' : '#2A2A2A',
borderColor: props.isSelected ? selectedBorder : unSelectedBorder,
backgroundColor: isDark ? '#2A2A2A' : '#F9F9F9',
}}
>
<HStack alignment="center" css={{ gap: '7px' }}>
<Circle size={14} color={props.color} weight="fill" />
<SpanBox css={{ pt: '1px' }}>{props.text}</SpanBox>
<Button
style="ghost"
css={{ display: 'flex', pt: '1px' }}
onClick={(event) => {
props.xAction()
event.preventDefault()
}}
>
<X
size={14}
color={props.isSelected ? '#FFEA9F' : xUnselectedColor}
/>
</Button>
</HStack>
</SpanBox>
)
}