From dad03e3be5b0a7c1159e0207cce11540ca830359 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Mon, 3 Jan 2022 17:21:18 +0100 Subject: feat(filter): add option to filter by subdirectory (#190) --- components/Tweaks/Visual/ColorMenu.tsx | 88 ++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 components/Tweaks/Visual/ColorMenu.tsx (limited to 'components/Tweaks/Visual/ColorMenu.tsx') diff --git a/components/Tweaks/Visual/ColorMenu.tsx b/components/Tweaks/Visual/ColorMenu.tsx new file mode 100644 index 0000000..a792f12 --- /dev/null +++ b/components/Tweaks/Visual/ColorMenu.tsx @@ -0,0 +1,88 @@ +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" + > + + + ))} + + + + + + ) +} -- cgit v1.2.3