Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #647 from tryshowtime/add-animate-presence
Browse files Browse the repository at this point in the history
Add AnimatePresence to SelectList on web
  • Loading branch information
axeldelafosse authored Jan 4, 2022
2 parents d5e5373 + 83b9008 commit 9483f15
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions packages/design-system/select/lib/select-list.web.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MotiView } from "moti";
import { MotiView, AnimatePresence } from "moti";
import { forwardRef, useMemo } from "react";
import { tw } from "../../tailwind";

Expand All @@ -13,30 +13,35 @@ export const SelectList: React.FC<SelectListProps> = forwardRef(
tw`z-20 absolute w-full top-100% p-1 mt-2 bg-white dark:bg-black rounded-2xl`,
[]
);
return open ? (
<MotiView
ref={ref}
from={{
opacity: 0,
translateY: -24,
}}
animate={{
opacity: 1,
translateY: 0,
}}
exit={{
opacity: 0,
translateY: -24,
}}
transition={{
type: "timing",
duration: 250,
}}
style={containerStyle}
{...rest}
>
{children}
</MotiView>
) : null;

return (
<AnimatePresence>
{open ? (
<MotiView
ref={ref}
from={{
opacity: 0,
translateY: -24,
}}
animate={{
opacity: 1,
translateY: 0,
}}
exit={{
opacity: 0,
translateY: -24,
}}
transition={{
type: "timing",
duration: 250,
}}
style={containerStyle}
{...rest}
>
{children}
</MotiView>
) : null}
</AnimatePresence>
);
}
);

0 comments on commit 9483f15

Please sign in to comment.