2021-06-02 11:50:34 +00:00
|
|
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
2021-06-28 12:13:34 +00:00
|
|
|
import { breakpoints, IconButton } from 'components/shared'
|
2021-06-02 21:17:38 +00:00
|
|
|
import Tooltip from 'components/tooltip'
|
2021-06-28 12:13:34 +00:00
|
|
|
import { memo } from 'react'
|
2021-06-02 11:50:34 +00:00
|
|
|
import { Circle } from 'react-feather'
|
|
|
|
import state, { useSelector } from 'state'
|
|
|
|
import { SizeStyle } from 'types'
|
2021-06-03 12:06:39 +00:00
|
|
|
import { DropdownContent, Item } from '../shared'
|
2021-06-02 11:50:34 +00:00
|
|
|
|
|
|
|
const sizes = {
|
|
|
|
[SizeStyle.Small]: 6,
|
|
|
|
[SizeStyle.Medium]: 12,
|
|
|
|
[SizeStyle.Large]: 22,
|
|
|
|
}
|
|
|
|
|
2021-07-13 21:13:31 +00:00
|
|
|
function changeSizeStyle(size: SizeStyle): void {
|
|
|
|
state.send('CHANGED_STYLE', { size })
|
2021-06-28 12:13:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function QuickSizeSelect(): JSX.Element {
|
2021-06-02 11:50:34 +00:00
|
|
|
const size = useSelector((s) => s.values.selectedStyle.size)
|
|
|
|
|
|
|
|
return (
|
2021-06-27 19:19:57 +00:00
|
|
|
<DropdownMenu.Root dir="ltr">
|
2021-06-28 12:13:34 +00:00
|
|
|
<DropdownMenu.Trigger as={IconButton} bp={breakpoints}>
|
2021-06-02 21:17:38 +00:00
|
|
|
<Tooltip label="Size">
|
|
|
|
<Circle size={sizes[size]} stroke="none" fill="currentColor" />
|
|
|
|
</Tooltip>
|
2021-06-02 11:50:34 +00:00
|
|
|
</DropdownMenu.Trigger>
|
2021-07-13 21:13:31 +00:00
|
|
|
<DropdownMenu.DropdownMenuRadioGroup
|
|
|
|
as={DropdownContent}
|
|
|
|
sideOffset={8}
|
|
|
|
direction="vertical"
|
|
|
|
value={size}
|
|
|
|
onValueChange={changeSizeStyle}
|
|
|
|
>
|
2021-06-28 12:13:34 +00:00
|
|
|
{Object.keys(SizeStyle).map((sizeStyle: SizeStyle) => (
|
2021-07-13 21:13:31 +00:00
|
|
|
<DropdownMenu.DropdownMenuRadioItem
|
2021-06-28 12:13:34 +00:00
|
|
|
key={sizeStyle}
|
|
|
|
as={Item}
|
|
|
|
isActive={size === sizeStyle}
|
|
|
|
value={sizeStyle}
|
|
|
|
>
|
|
|
|
<Circle size={sizes[sizeStyle]} />
|
2021-07-13 21:13:31 +00:00
|
|
|
</DropdownMenu.DropdownMenuRadioItem>
|
2021-06-28 12:13:34 +00:00
|
|
|
))}
|
2021-07-13 21:13:31 +00:00
|
|
|
</DropdownMenu.DropdownMenuRadioGroup>
|
2021-06-02 11:50:34 +00:00
|
|
|
</DropdownMenu.Root>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-28 12:13:34 +00:00
|
|
|
export default memo(QuickSizeSelect)
|