11import { type Key } from "react" ;
2- import { Popover } from "@base-ui/react/popover" ;
32import isEmpty from "lodash/isEmpty" ;
43
54import { useAddCategoryToBookmarksOptimisticMutation } from "@/async/mutationHooks/category/use-add-category-to-bookmarks-optimistic-mutation" ;
65import useFetchCategories from "@/async/queryHooks/category/useFetchCategories" ;
7- import { Button } from "@/components/ui/recollect/button " ;
6+ import { Menu } from "@/components/ui/recollect/menu " ;
87import MoveIcon from "@/icons/moveIcon" ;
9- import {
10- dropdownMenuClassName ,
11- dropdownMenuItemClassName ,
12- } from "@/utils/commonClassNames" ;
138
149interface AddToCollectionPopoverProps {
1510 onSuccess : ( ) => void ;
@@ -21,38 +16,36 @@ export function AddToCollectionPopover({
2116 selectedKeys,
2217} : AddToCollectionPopoverProps ) {
2318 return (
24- < Popover . Root >
25- < Popover . Trigger className = "flex items-center rounded-lg bg-gray-200 px-2 py-[5px] text-13 leading-4 font-450 text-gray-900" >
19+ < Menu . Root >
20+ < Menu . Trigger className = "flex items-center rounded-lg bg-gray-200 px-2 py-[5px] text-13 leading-4 font-450 text-gray-900" >
2621 < span className = "mr-[6px] text-gray-1000" aria-hidden = "true" >
2722 < MoveIcon />
2823 </ span >
2924 < p > Add to</ p >
30- </ Popover . Trigger >
31- < Popover . Portal >
32- < Popover . Positioner align = "end" className = "z-10" sideOffset = { 1 } >
33- < Popover . Popup
34- className = { `${ dropdownMenuClassName } leading-[20px] outline-hidden` }
35- >
36- < AddToCollectionMenu
25+ </ Menu . Trigger >
26+ < Menu . Portal >
27+ < Menu . Positioner align = "end" >
28+ < Menu . Popup className = "leading-[20px]" >
29+ < AddToCollectionMenuItems
3730 onSuccess = { onSuccess }
3831 selectedKeys = { selectedKeys }
3932 />
40- </ Popover . Popup >
41- </ Popover . Positioner >
42- </ Popover . Portal >
43- </ Popover . Root >
33+ </ Menu . Popup >
34+ </ Menu . Positioner >
35+ </ Menu . Portal >
36+ </ Menu . Root >
4437 ) ;
4538}
4639
47- interface AddToCollectionMenuProps {
40+ interface AddToCollectionMenuItemsProps {
4841 onSuccess : ( ) => void ;
4942 selectedKeys : Set < Key > ;
5043}
5144
52- function AddToCollectionMenu ( {
45+ function AddToCollectionMenuItems ( {
5346 onSuccess,
5447 selectedKeys,
55- } : AddToCollectionMenuProps ) {
48+ } : AddToCollectionMenuItemsProps ) {
5649 const { allCategories } = useFetchCategories ( ) ;
5750 const { addCategoryToBookmarksOptimisticMutation } =
5851 useAddCategoryToBookmarksOptimisticMutation ( ) ;
@@ -69,8 +62,8 @@ function AddToCollectionMenu({
6962 return (
7063 < >
7164 { categories . map ( ( item ) => (
72- < Button
73- className = { ` w-full truncate text-left ${ dropdownMenuItemClassName } ` }
65+ < Menu . Item
66+ className = " w-full truncate text-left"
7467 key = { item . value }
7568 onClick = { ( ) => {
7669 const selectedIds = Array . from ( selectedKeys ) . map ( Number ) ;
@@ -82,10 +75,9 @@ function AddToCollectionMenu({
8275 { onSuccess } ,
8376 ) ;
8477 } }
85- type = "button"
8678 >
8779 { item . label }
88- </ Button >
80+ </ Menu . Item >
8981 ) ) }
9082 </ >
9183 ) ;
0 commit comments