From bcd5128c59910219cb26983f249588c99d5fb5a4 Mon Sep 17 00:00:00 2001 From: soup Date: Wed, 22 Mar 2023 22:00:47 +0100 Subject: [PATCH] fix(filters): close add new dropdown of focus (#777) * hide dropdown when clicking outside it * cleaner code * cleaned up code removed uneccessary div changed to focus:ring-inset on buttons * revert focus-ring-inset change will handle this for the entire app in a separate branch * changed to using headlessui * added transition to the dropdown * feat: add export JSON to Discord button The Discord button exports the filter data in JSON format, but with Discord-specific formatting. as requested on Discord --- web/src/screens/filters/list.tsx | 140 ++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 49 deletions(-) diff --git a/web/src/screens/filters/list.tsx b/web/src/screens/filters/list.tsx index f679cc4..07fa91a 100644 --- a/web/src/screens/filters/list.tsx +++ b/web/src/screens/filters/list.tsx @@ -17,8 +17,8 @@ import { DocumentDuplicateIcon, EllipsisHorizontalIcon, PencilSquareIcon, - TrashIcon, - ExclamationTriangleIcon + ChatBubbleBottomCenterTextIcon, + TrashIcon } from "@heroicons/react/24/outline"; import { queryClient } from "../../App"; @@ -87,10 +87,13 @@ export default function Filters({}: FilterProps){ const queryClient = useQueryClient(); - const [createFilterIsOpen, toggleCreateFilter] = useToggle(false); + const [createFilterIsOpen, setCreateFilterIsOpen] = useState(false); + const toggleCreateFilter = () => { + setCreateFilterIsOpen(!createFilterIsOpen); + }; const [showImportModal, setShowImportModal] = useState(false); - const [importJson, setImportJson] = useState(""); + const [importJson, setImportJson] = useState(""); // This function handles the import of a filter from a JSON string const handleImportJson = async () => { @@ -140,53 +143,71 @@ export default function Filters({}: FilterProps){ } }; - const [showDropdown, setShowDropdown] = useState(false); - return (
-
-

- Filters -

+

Filters

- - - {showDropdown && ( -
- -
- )} + + {({ open }) => ( + <> + + + + + + + + {({ active }) => ( + + )} + + + + + )} +
+ {showImportModal && (

Import Filter JSON