mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-27 18:48:22 +03:00
replace react-transition-group with framer-motion in Chip
Replace CSSTransition with framer-motion AnimatePresence + motion.div for React 19 compatibility (react-transition-group uses findDOMNode). framer-motion is already a project dependency.
This commit is contained in:
parent
c4e7cf6ef1
commit
638ee3bd0a
@ -1,8 +1,8 @@
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { LogSeverity } from "@/types/log";
|
import { LogSeverity } from "@/types/log";
|
||||||
import { ReactNode, useMemo, useRef } from "react";
|
import { ReactNode, useMemo } from "react";
|
||||||
import { isIOS } from "react-device-detect";
|
import { isIOS } from "react-device-detect";
|
||||||
import { CSSTransition } from "react-transition-group";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
|
|
||||||
type ChipProps = {
|
type ChipProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -17,23 +17,14 @@ export default function Chip({
|
|||||||
in: inProp = true,
|
in: inProp = true,
|
||||||
onClick,
|
onClick,
|
||||||
}: ChipProps) {
|
}: ChipProps) {
|
||||||
const nodeRef = useRef(null);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CSSTransition
|
<AnimatePresence>
|
||||||
in={inProp}
|
{inProp && (
|
||||||
nodeRef={nodeRef}
|
<motion.div
|
||||||
timeout={500}
|
initial={{ opacity: 0 }}
|
||||||
classNames={{
|
animate={{ opacity: 1 }}
|
||||||
enter: "opacity-0",
|
exit={{ opacity: 0 }}
|
||||||
enterActive: "opacity-100 transition-opacity duration-500 ease-in-out",
|
transition={{ duration: 0.5, ease: "easeInOut" }}
|
||||||
exit: "opacity-100",
|
|
||||||
exitActive: "opacity-0 transition-opacity duration-500 ease-in-out",
|
|
||||||
}}
|
|
||||||
unmountOnExit
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
ref={nodeRef}
|
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center rounded-2xl px-2 py-1.5",
|
"flex items-center rounded-2xl px-2 py-1.5",
|
||||||
className,
|
className,
|
||||||
@ -48,8 +39,9 @@ export default function Chip({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</motion.div>
|
||||||
</CSSTransition>
|
)}
|
||||||
|
</AnimatePresence>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user