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

79 lines
2 KiB
TypeScript
Raw Normal View History

2024-02-16 04:25:45 +00:00
import { HStack, VStack } from './LayoutPrimitives'
2024-02-07 05:02:19 +00:00
import { Button } from './Button'
import { CaretDownIcon } from './icons/CaretDownIcon'
2024-02-08 07:01:40 +00:00
type ShowLinkMode = 'none' | 'link' | 'pdf'
2024-02-07 05:02:19 +00:00
type SplitButtonProps = {
title: string
2024-02-08 07:01:40 +00:00
setShowLinkMode: (mode: ShowLinkMode) => void
2024-02-07 05:02:19 +00:00
}
const CaretButton = (): JSX.Element => {
return (
<VStack
css={{
width: '20px',
height: '100%',
alignItems: 'center',
bg: '$ctaBlue',
2024-02-07 05:02:19 +00:00
border: '0px solid transparent',
borderTopRightRadius: '5px',
borderBottomRightRadius: '5px',
borderTopLeftRadius: '0px',
borderBottomLeftRadius: '0px',
2024-02-07 17:49:12 +00:00
'--caret-color': '#EDEDED',
'&:hover': {
opacity: 1.0,
color: 'white',
'--caret-color': 'white',
},
'&:focus': {
outline: 'none',
border: '0px solid transparent',
},
2024-02-07 05:02:19 +00:00
}}
>
2024-02-07 17:49:12 +00:00
<CaretDownIcon size={8} color="var(--caret-color)" />
2024-02-07 05:02:19 +00:00
</VStack>
)
}
export const SplitButton = (props: SplitButtonProps): JSX.Element => {
return (
2024-02-08 07:01:40 +00:00
<HStack css={{ height: '32px', gap: '1px' }}>
2024-02-07 05:02:19 +00:00
<Button
css={{
display: 'flex',
2024-05-07 04:10:33 +00:00
bg: '$omnivoreYellow',
color: '#2A2A2A',
2024-02-08 07:01:40 +00:00
fontSize: '14px',
2024-02-07 05:02:19 +00:00
fontFamily: '$inter',
border: '0px solid transparent',
borderTopLeftRadius: '5px',
borderBottomLeftRadius: '5px',
2024-02-08 07:01:40 +00:00
borderTopRightRadius: '5px',
borderBottomRightRadius: '5px',
2024-02-07 05:02:19 +00:00
'&:hover': {
2024-05-07 04:10:33 +00:00
background: '#FFD800',
2024-02-08 07:01:40 +00:00
border: '0px solid transparent',
2024-02-07 05:02:19 +00:00
},
'&:focus': {
outline: 'none',
border: '0px solid transparent',
},
}}
2024-02-08 07:01:40 +00:00
onClick={(event) => {
props.setShowLinkMode('link')
event.preventDefault()
}}
2024-02-07 05:02:19 +00:00
>
{props.title}
</Button>
2024-02-08 07:01:40 +00:00
{/* <Dropdown triggerElement={<CaretButton />}>
2024-02-07 05:02:19 +00:00
<DropdownOption onSelect={() => console.log()} title="Archive (e)" />
2024-02-08 07:01:40 +00:00
</Dropdown> */}
2024-02-07 05:02:19 +00:00
</HStack>
)
}