Skip to content

Commit 12cf5cb

Browse files
committed
feat: Lottie 애니메이션 지원을 위한 DotLottie 라이브러리 추가 및 홈 페이지에 애니메이션 적용
1 parent ef495a2 commit 12cf5cb

File tree

6 files changed

+51
-4
lines changed

6 files changed

+51
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"dependencies": {
1919
"@floating-ui/react": "^0.27.15",
2020
"@hotjar/browser": "1.0.9",
21+
"@lottiefiles/dotlottie-react": "^0.15.0",
2122
"@number-flow/react": "^0.5.10",
2223
"@radix-ui/themes": "3.2.1",
2324
"@tanstack/react-query": "^5.84.1",

pnpm-lock.yaml

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

src/assets/lottie/home-logo.lottie

640 KB
Binary file not shown.

src/routes/index.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
1+
import { type DotLottie, DotLottieReact } from "@lottiefiles/dotlottie-react";
12
import { Flex } from "@radix-ui/themes";
23
import { createFileRoute } from "@tanstack/react-router";
4+
import { useEffect, useState } from "react";
5+
import assetLottie from "@/assets/lottie/home-logo.lottie";
36

47
export const Route = createFileRoute("/")({
58
component: Home,
69
});
710

811
const KAKAO_LOGIN_URL = `https://dev-api.holdy.kr/login/kakao?redirect_uri=${window.location.origin}/oauth2/redirect`;
912

13+
const intermission = 1500;
1014
function Home() {
15+
const [dotLottie, setDotLottie] = useState<DotLottie | null>(null);
16+
17+
useEffect(() => {
18+
const onComplete = () => {
19+
setTimeout(() => {
20+
dotLottie?.play();
21+
}, intermission);
22+
};
23+
24+
dotLottie?.addEventListener("complete", onComplete);
25+
26+
return () => {
27+
dotLottie?.removeEventListener("complete", onComplete);
28+
};
29+
}, [dotLottie]);
30+
1131
return (
1232
<Flex direction="column" gap="5" className="h-full px-10 py-4">
1333
<Flex direction="column" align="center" gap="4px" className="mt-[160px]">
14-
<img
15-
src="/images/logo.png"
16-
alt="홀디 로고"
17-
className="w-[198px] h-[198px] rounded-full bg-neutral-300"
34+
<DotLottieReact
35+
dotLottieRefCallback={setDotLottie}
36+
src={assetLottie}
37+
autoplay
38+
loop={false}
39+
className="w-[198px] h-[198px]"
1840
/>
1941
<h2 className="t-p-22-sb pt-6">홀디에 오신 걸 환영해요 :)</h2>
2042
<p className="t-p-14-m">내 페이스에 맞춰 하나씩 올라가 볼까요?</p>

src/vite-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
/// <reference types="vite/client" />
22

33
declare const __MSW_ENABLED__: boolean;
4+
5+
declare module "*.lottie" {
6+
const content: string;
7+
export default content;
8+
}

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const dirname =
1515

1616
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
1717
export default defineConfig({
18+
assetsInclude: ["**/*.lottie"],
1819
plugins: [
1920
react(),
2021
tanstackRouter({

0 commit comments

Comments
 (0)