Skip to content

Commit 5aafe32

Browse files
committed
use the oficial lottie react library
1 parent 6a2256c commit 5aafe32

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

packages/react-email/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
"ora": "5.4.1",
3939
"socket.io": "4.8.0"
4040
},
41-
"overrides": {
42-
"react": "^19",
43-
"react-dom": "^19"
44-
},
4541
"devDependencies": {
4642
"@radix-ui/colors": "1.0.1",
4743
"@radix-ui/react-collapsible": "1.1.0",
@@ -65,7 +61,7 @@
6561
"autoprefixer": "10.4.20",
6662
"clsx": "2.1.0",
6763
"framer-motion": "12.0.0-alpha.2",
68-
"lottie-react": "^2.4.0",
64+
"@lottiefiles/dotlottie-react": "0.12.3",
6965
"node-html-parser": "6.1.13",
7066
"postcss": "8.4.40",
7167
"prettier-plugin-tailwindcss": "0.6.6",

packages/react-email/src/components/button.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use client';
22
import * as SlotPrimitive from '@radix-ui/react-slot';
3-
import Lottie from 'lottie-react';
43
import type * as React from 'react';
54
import animatedLoadIcon from '../animated-icons-data/load.json';
65
import { cn } from '../utils/cn';
76
import { unreachable } from '../utils/unreachable';
7+
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
88

99
type RootProps = React.ComponentProps<'button'>;
1010

@@ -49,9 +49,9 @@ export const Button = ({
4949
loading && 'opacity-100',
5050
)}
5151
>
52-
<Lottie
53-
animationData={animatedLoadIcon}
54-
autoPlay={false}
52+
<DotLottieReact
53+
data={animatedLoadIcon}
54+
autoplay={false}
5555
className="h-5 w-5"
5656
loop={true}
5757
/>

packages/react-email/src/components/sidebar/sidebar.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { clsx } from 'clsx';
55
import { motion } from 'framer-motion';
66
import Lottie from 'lottie-react';
77
import Link from 'next/link';
8+
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
89
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
910
import type * as React from 'react';
1011
import animatedHelpIcon from '../../animated-icons-data/help.json';
@@ -220,12 +221,14 @@ export const Sidebar = ({
220221
tabValue="file-tree"
221222
tooltipText="File Explorer"
222223
>
223-
<Lottie
224-
animationData={animatedMailIcon as object}
225-
autoPlay={false}
224+
<DotLottieReact
225+
data={animatedMailIcon}
226+
autoplay={false}
226227
className="h-5 w-5"
227228
loop={false}
228-
lottieRef={mailAnimation.ref}
229+
dotLottieRefCallback={(instance) => {
230+
mailAnimation.ref.current = instance;
231+
}}
229232
/>
230233
</TabTrigger>
231234
<TabTrigger
@@ -236,12 +239,14 @@ export const Sidebar = ({
236239
tabValue="link-checker"
237240
tooltipText="Link Checker"
238241
>
239-
<Lottie
240-
animationData={animatedLinkIcon as object}
241-
autoPlay={false}
242+
<DotLottieReact
243+
data={animatedLinkIcon}
244+
autoplay={false}
242245
className="h-6 w-6"
243246
loop={false}
244-
lottieRef={linkAnimation.ref}
247+
dotLottieRefCallback={(instance) => {
248+
linkAnimation.ref.current = instance;
249+
}}
245250
/>
246251
</TabTrigger>
247252
<TabTrigger
@@ -261,12 +266,14 @@ export const Sidebar = ({
261266
side="right"
262267
tooltip="Documentation"
263268
>
264-
<Lottie
265-
animationData={animatedHelpIcon as object}
266-
autoPlay={false}
269+
<DotLottieReact
270+
data={animatedHelpIcon}
271+
autoplay={false}
267272
className="h-5 w-5"
268273
loop={false}
269-
lottieRef={helpAnimation.ref}
274+
dotLottieRefCallback={(instance) => {
275+
helpAnimation.ref.current = instance;
276+
}}
270277
/>
271278
</NavigationButton>
272279
<NavigationButton

packages/react-email/src/hooks/use-icon-animation.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { LottieRefCurrentProps } from 'lottie-react';
1+
import type { DotLottie } from '@lottiefiles/dotlottie-react';
22
import * as React from 'react';
33

44
const TIMEOUT = 150;
55
const THRESHOLD_ANIMATION = 0.9;
66

77
export const useIconAnimation = () => {
8-
const ref = React.useRef<LottieRefCurrentProps>(null);
8+
const ref = React.useRef<DotLottie>(null);
99
const timer = React.useRef<NodeJS.Timeout | null>(null);
1010

1111
const onMouseLeave = React.useCallback(() => {
@@ -17,9 +17,9 @@ export const useIconAnimation = () => {
1717
return;
1818
}
1919

20-
const total = Math.round(ref.current.animationItem?.totalFrames ?? 0);
20+
const total = Math.round(ref.current.totalFrames ?? 0);
2121
const current = Math.round(
22-
(ref.current.animationItem?.currentFrame ?? 0) + 1,
22+
(ref.current.currentFrame ?? 0) + 1,
2323
);
2424

2525
if (current === 1 || current >= total * THRESHOLD_ANIMATION) {
@@ -29,7 +29,6 @@ export const useIconAnimation = () => {
2929
}
3030

3131
ref.current.stop();
32-
ref.current.setDirection(1);
3332
ref.current.setSpeed(1);
3433
ref.current.play();
3534
}, TIMEOUT);

pnpm-lock.yaml

Lines changed: 18 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)