Skip to content

Commit bbab312

Browse files
add page animation
1 parent 5dd6fd3 commit bbab312

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

dashboard/components/layout/dashboard-layout.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Link from "next/link";
44
import Image from "next/image";
55
import { usePathname } from "next/navigation";
6+
import { motion } from "motion/react";
67
import useSWR from "swr";
78
import {
89
LayoutDashboard,
@@ -206,6 +207,8 @@ interface DashboardLayoutProps {
206207
}
207208

208209
export function DashboardLayout({ children, title, description }: DashboardLayoutProps) {
210+
const pathname = usePathname();
211+
209212
return (
210213
<SidebarProvider>
211214
<AppSidebar />
@@ -220,9 +223,15 @@ export function DashboardLayout({ children, title, description }: DashboardLayou
220223
)}
221224
</div>
222225
</header>
223-
<main className="flex-1 overflow-y-auto p-4">
226+
<motion.main
227+
key={pathname}
228+
className="flex-1 overflow-y-auto p-4 [will-change:transform,opacity,filter]"
229+
initial={{ opacity: 0, y: 18, scale: 0.985, filter: "blur(8px)" }}
230+
animate={{ opacity: 1, y: 0, scale: 1, filter: "blur(0px)" }}
231+
transition={{ duration: 0.55, ease: [0.16, 1, 0.3, 1] }}
232+
>
224233
{children}
225-
</main>
234+
</motion.main>
226235
</SidebarInset>
227236
</SidebarProvider>
228237
);

0 commit comments

Comments
 (0)