mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Animate dropdown
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
import { motion } from 'framer-motion';
|
||||||
import type { CSSProperties, HTMLAttributes, MouseEvent, ReactElement, ReactNode } from 'react';
|
import type { CSSProperties, HTMLAttributes, MouseEvent, ReactElement, ReactNode } from 'react';
|
||||||
import { Children, cloneElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { Children, cloneElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useKeyPressEvent } from 'react-use';
|
import { useKeyPressEvent } from 'react-use';
|
||||||
@@ -159,13 +160,15 @@ function Menu({ className, items, onClose, triggerRect }: MenuProps) {
|
|||||||
return (
|
return (
|
||||||
<Portal name="dropdown">
|
<Portal name="dropdown">
|
||||||
<button aria-hidden title="close" className="fixed inset-0" onClick={onClose} />
|
<button aria-hidden title="close" className="fixed inset-0" onClick={onClose} />
|
||||||
<div
|
<motion.div
|
||||||
|
initial={{ opacity: 0, y: -10 }}
|
||||||
|
animate={{ opacity: 1, y: 0 }}
|
||||||
role="menu"
|
role="menu"
|
||||||
aria-orientation="vertical"
|
aria-orientation="vertical"
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
style={containerStyles}
|
style={containerStyles}
|
||||||
className={classnames(className, 'pointer-events-auto fixed z-50')}
|
className={classnames(className, 'mt-1 pointer-events-auto fixed z-50')}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
style={triangleStyles}
|
style={triangleStyles}
|
||||||
@@ -199,7 +202,7 @@ function Menu({ className, items, onClose, triggerRect }: MenuProps) {
|
|||||||
})}
|
})}
|
||||||
</VStack>
|
</VStack>
|
||||||
)}
|
)}
|
||||||
</div>
|
</motion.div>
|
||||||
</Portal>
|
</Portal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user