11import { Menu , Transition } from '@headlessui/react' ;
2+ import { Float } from '@headlessui-float/react' ;
23import { Icon } from '@iconify/react' ;
34import cx from 'classnames' ;
45import { Fragment } from 'react' ;
@@ -23,66 +24,66 @@ interface Props {
2324
2425export function DropDown ( { label, options, className } : Props ) {
2526 return (
26- < div className = "text-right" >
27- < Menu as = "div" className = { `relative inline-block text-left ${ className } ` } >
28- < div >
27+ < div className = "relative text-right" >
28+ < Menu as = "div" className = { `inline-block text-left ${ className } ` } >
29+ < Float placement = "bottom-end" flip portal >
2930 < Menu . Button className = "inline-flex w-full justify-center gap-1 rounded-md bg-opacity-20 p-2 text-sm font-medium hover:bg-slate-300 hover:bg-opacity-30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 dark:hover:bg-slate-700" >
3031 { label }
3132 < Icon icon = "mdi:chevron-down" />
3233 </ Menu . Button >
33- </ div >
34- < Transition
35- as = { Fragment }
36- enter = "transition ease-out duration-100"
37- enterFrom = "transform opacity-0 scale-95"
38- enterTo = "transform opacity-100 scale-100"
39- leave = "transition ease-in duration-75"
40- leaveFrom = "transform opacity-100 scale-100"
41- leaveTo = "transform opacity-0 scale-95"
42- >
43- < Menu . Items className = "absolute right-0 z-50 mt-2 w-fit origin-top-right divide-y divide-slate-100 rounded-md bg-slate-100 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-slate-900" >
44- < div className = "px-1 py-1 " >
45- { options . map ( ( option , idx ) => {
46- if ( option . type === 'separator' ) {
34+ < Transition
35+ as = { Fragment }
36+ enter = "transition ease-out duration-100"
37+ enterFrom = "transform opacity-0 scale-95"
38+ enterTo = "transform opacity-100 scale-100"
39+ leave = "transition ease-in duration-75"
40+ leaveFrom = "transform opacity-100 scale-100"
41+ leaveTo = "transform opacity-0 scale-95"
42+ >
43+ < Menu . Items className = "z-50 mt-2 w-fit origin-top-right divide-y divide-slate-100 rounded-md bg-slate-100 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-slate-900" >
44+ < div className = "px-1 py-1 " >
45+ { options . map ( ( option , idx ) => {
46+ if ( option . type === 'separator' ) {
47+ return (
48+ < div
49+ className = "m-1 border-t-[1px] border-t-slate-500"
50+ // eslint-disable-next-line react/no-array-index-key
51+ key = { `divider-${ idx } ` }
52+ />
53+ ) ;
54+ }
4755 return (
48- < div
49- className = "m-1 border-t-[1px] border-t-slate-500"
50- // eslint-disable-next-line react/no-array-index-key
51- key = { `divider-${ idx } ` }
52- />
56+ // eslint-disable-next-line react/no-array-index-key
57+ < Menu . Item key = { idx . toString ( ) } >
58+ { ( { active } ) =>
59+ option . onClick !== null ? (
60+ < button
61+ className = { cx (
62+ 'group flex w-full items-center rounded-md px-2 py-2 text-sm' ,
63+ { 'bg-slate-200 dark:bg-slate-800' : active }
64+ ) }
65+ type = "button"
66+ onClick = { option . onClick }
67+ >
68+ { option . label }
69+ </ button >
70+ ) : (
71+ < div
72+ className = { cx (
73+ 'group mt-2 flex w-full items-center rounded-md px-2'
74+ ) }
75+ >
76+ { option . label }
77+ </ div >
78+ )
79+ }
80+ </ Menu . Item >
5381 ) ;
54- }
55- return (
56- // eslint-disable-next-line react/no-array-index-key
57- < Menu . Item key = { idx . toString ( ) } >
58- { ( { active } ) =>
59- option . onClick !== null ? (
60- < button
61- className = { cx (
62- 'group flex w-full items-center rounded-md px-2 py-2 text-sm' ,
63- { 'bg-slate-200 dark:bg-slate-800' : active }
64- ) }
65- type = "button"
66- onClick = { option . onClick }
67- >
68- { option . label }
69- </ button >
70- ) : (
71- < div
72- className = { cx (
73- 'group mt-2 flex w-full items-center rounded-md px-2'
74- ) }
75- >
76- { option . label }
77- </ div >
78- )
79- }
80- </ Menu . Item >
81- ) ;
82- } ) }
83- </ div >
84- </ Menu . Items >
85- </ Transition >
82+ } ) }
83+ </ div >
84+ </ Menu . Items >
85+ </ Transition >
86+ </ Float >
8687 </ Menu >
8788 </ div >
8889 ) ;
0 commit comments