From 6c92c1e232b2672067a4ccc1e9c5f43715a17b17 Mon Sep 17 00:00:00 2001 From: southclaws Date: Wed, 27 Dec 2023 13:02:33 +0000 Subject: [PATCH 1/4] upgrade ark to 1.2.1 --- web/package.json | 6 +- .../content/CollectionMenu/CollectionMenu.tsx | 8 +- .../CollectionMenu/useCollectionMenu.ts | 5 +- .../feed/common/FeedItemMenu/FeedItemMenu.tsx | 4 +- .../MemberOptions/MemberOptionsMenu.tsx | 7 +- .../components/thread/PostMenu/PostMenu.tsx | 4 +- .../components/thread/ReactList/ReactList.tsx | 2 +- .../components/Checkbox/checkbox.recipe.ts | 2 +- .../theme/components/Menu copy/menu.recipe.ts | 135 + web/src/theme/components/Menu/menu.recipe.ts | 2 +- .../components/Popover/popover.recipe.ts | 4 +- web/src/theme/components/Tabs/tabs.recipe.ts | 2 +- web/src/theme/components/TitleInput/index.ts | 12 - web/src/theme/components/TitleInput/index.tsx | 39 + web/src/utils/useDisclosure.ts | 17 + web/styled-system/recipes/checkbox.d.ts | 2 +- web/styled-system/recipes/checkbox.mjs | 4 + web/styled-system/recipes/menu.d.ts | 2 +- web/styled-system/recipes/menu.mjs | 12 + web/styled-system/recipes/popover.d.ts | 2 +- web/styled-system/recipes/popover.mjs | 4 + web/yarn.lock | 3638 ++++++++--------- 22 files changed, 1907 insertions(+), 2006 deletions(-) create mode 100644 web/src/theme/components/Menu copy/menu.recipe.ts delete mode 100644 web/src/theme/components/TitleInput/index.ts create mode 100644 web/src/theme/components/TitleInput/index.tsx diff --git a/web/package.json b/web/package.json index b68743802..6925583f3 100644 --- a/web/package.json +++ b/web/package.json @@ -11,7 +11,7 @@ "openapi": "orval" }, "dependencies": { - "@ark-ui/react": "^0.15.0", + "@ark-ui/react": "^1.2.1", "@dnd-kit/core": "^6.0.8", "@dnd-kit/sortable": "^7.0.2", "@emoji-mart/data": "^1.1.2", @@ -56,6 +56,6 @@ "typescript": "^5.2.2" }, "resolutions": { - "@ark-ui/react": "^0.15.0" + "@ark-ui/react": "^1.2.1" } -} +} \ No newline at end of file diff --git a/web/src/components/content/CollectionMenu/CollectionMenu.tsx b/web/src/components/content/CollectionMenu/CollectionMenu.tsx index 185f39f44..36e38e7e5 100644 --- a/web/src/components/content/CollectionMenu/CollectionMenu.tsx +++ b/web/src/components/content/CollectionMenu/CollectionMenu.tsx @@ -16,8 +16,7 @@ export function CollectionMenu(props: Props) { onKeyDown, onKeyUp, isOpen, - onOpen, - onClose, + onOpenChange, isAlreadySaved, } = useCollectionMenu(props); @@ -27,9 +26,8 @@ export function CollectionMenu(props: Props) { diff --git a/web/src/components/content/CollectionMenu/useCollectionMenu.ts b/web/src/components/content/CollectionMenu/useCollectionMenu.ts index b81f8a797..398c7126c 100644 --- a/web/src/components/content/CollectionMenu/useCollectionMenu.ts +++ b/web/src/components/content/CollectionMenu/useCollectionMenu.ts @@ -21,7 +21,7 @@ export function useCollectionMenu({ thread }: Props) { setSelected(0); }; - const { isOpen, onOpen, onClose, onToggle } = useDisclosure({ + const { isOpen, onOpenChange, onToggle } = useDisclosure({ onClose: onReset, }); @@ -54,9 +54,8 @@ export function useCollectionMenu({ thread }: Props) { collections: collections.collections, onKeyDown, onKeyUp, + onOpenChange, multiSelect, isOpen, - onOpen, - onClose, }; } diff --git a/web/src/components/feed/common/FeedItemMenu/FeedItemMenu.tsx b/web/src/components/feed/common/FeedItemMenu/FeedItemMenu.tsx index 436b70ebd..f64ac2c00 100644 --- a/web/src/components/feed/common/FeedItemMenu/FeedItemMenu.tsx +++ b/web/src/components/feed/common/FeedItemMenu/FeedItemMenu.tsx @@ -22,13 +22,13 @@ export function FeedItemMenu(props: Props) { useFeedItemMenu(props); return ( - + - + + {children} diff --git a/web/src/components/thread/PostMenu/PostMenu.tsx b/web/src/components/thread/PostMenu/PostMenu.tsx index c93e745ff..03840709f 100644 --- a/web/src/components/thread/PostMenu/PostMenu.tsx +++ b/web/src/components/thread/PostMenu/PostMenu.tsx @@ -34,14 +34,14 @@ export function PostMenu(props: PostProps) { } = usePostMenu(props); return ( - + - + + - + - + - + diff --git a/web/src/components/thread/ReactList/useReactList.ts b/web/src/components/thread/ReactList/useReactList.ts index 4f802fc90..34770ae76 100644 --- a/web/src/components/thread/ReactList/useReactList.ts +++ b/web/src/components/thread/ReactList/useReactList.ts @@ -1,9 +1,11 @@ +import { useClickAway } from "@uidotdev/usehooks"; import { mutate } from "swr"; import { postReactAdd } from "src/api/openapi/posts"; import { PostProps } from "src/api/openapi/schemas"; import { getThreadGetKey } from "src/api/openapi/threads"; import { useSession } from "src/auth"; +import { useDisclosure } from "src/utils/useDisclosure"; export type Props = PostProps & { slug?: string; @@ -17,15 +19,37 @@ export function useReactList(props: Props) { const account = useSession(); const authenticated = !!account; - async function onSelect(event: EmojiSelectEvent) { + const { onOpen, onClose, isOpen } = useDisclosure(); + const ref = useClickAway(() => { + onClose(); + }); + + async function handleSelect(event: EmojiSelectEvent) { await postReactAdd(props.id, { emoji: event.native }); props.slug && mutate(getThreadGetKey(props.slug)); + + onClose(); + } + + function handleTrigger() { + if (!authenticated) { + return; + } + + // NOTE: Doesn't currently work to close the popover if it's open, because + // by the time this handler is called, the outside click handler has already + // closed the popover. But... tbh who cares! Very low impact issue to fix... + if (!isOpen) onOpen(); + else onClose(); } return { authenticated, + isOpen, + ref, handlers: { - onSelect, + handleTrigger, + handleSelect, }, }; } From d079d0bef5336ca25a7c02dcb0a69b32e9f8f210 Mon Sep 17 00:00:00 2001 From: southclaws Date: Wed, 27 Dec 2023 13:25:01 +0000 Subject: [PATCH 3/4] force light theme for emojimart for now --- web/src/components/thread/ReactList/ReactList.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/components/thread/ReactList/ReactList.tsx b/web/src/components/thread/ReactList/ReactList.tsx index 74ad4fafe..a7f74a9d7 100644 --- a/web/src/components/thread/ReactList/ReactList.tsx +++ b/web/src/components/thread/ReactList/ReactList.tsx @@ -43,7 +43,12 @@ export function ReactList(props: Props) { - + From 27579fe9405fedd886fd2e3e51d8f52d6985a705 Mon Sep 17 00:00:00 2001 From: southclaws Date: Wed, 27 Dec 2023 13:48:32 +0000 Subject: [PATCH 4/4] remove unused PopoverTrigger --- web/src/components/thread/ReactList/ReactList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/web/src/components/thread/ReactList/ReactList.tsx b/web/src/components/thread/ReactList/ReactList.tsx index a7f74a9d7..a54f9f18d 100644 --- a/web/src/components/thread/ReactList/ReactList.tsx +++ b/web/src/components/thread/ReactList/ReactList.tsx @@ -8,7 +8,6 @@ import { PopoverAnchor, PopoverContent, PopoverPositioner, - PopoverTrigger, } from "src/theme/components/Popover"; import { styled } from "@/styled-system/jsx";