import { ChevronDownIcon } from '@chakra-ui/icons' import { Text, Box, Button, Flex, Menu, MenuButton, MenuItem, MenuList, Portal, PopoverTrigger, PopoverContent, Popover, } from '@chakra-ui/react' import React, { useCallback } from 'react' import { initialVisuals } from '../../config' export interface ColorMenuProps { label: string colorList: string[] value: string visValue: string setVisuals?: any noEmpty?: boolean } export const ColorMenu = (props: ColorMenuProps) => { const { label, colorList, value, visValue, setVisuals, noEmpty } = props const clickCallback = useCallback( (color) => setVisuals((curr: typeof initialVisuals) => { return { ...curr, [value]: color, } }), [], ) return ( {label} {!noEmpty && ( clickCallback('')} justifyContent="space-between" alignItems="center" display="flex" m={1} > )} {colorList.map((color: string) => ( clickCallback(color)} justifyContent="space-between" alignItems="center" display="flex" > ))} ) }