mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-22 21:36:25 +02:00
⚡️ Lazy load animation library to help reduce bundle size (#502)
This commit is contained in:
parent
c2c000f770
commit
696cd44ba1
14 changed files with 115 additions and 83 deletions
|
@ -1,23 +1,42 @@
|
|||
import { AnimatePresence, domAnimation, LazyMotion, m } from "framer-motion";
|
||||
import { useRouter } from "next/router";
|
||||
import React from "react";
|
||||
|
||||
import { DayjsProvider } from "@/utils/dayjs";
|
||||
|
||||
import { NextPageWithLayout } from "../../types";
|
||||
import ModalProvider from "../modal/modal-provider";
|
||||
import { UserProvider } from "../user-provider";
|
||||
import { MobileNavigation } from "./standard-layout/mobile-navigation";
|
||||
|
||||
const StandardLayout: React.VoidFunctionComponent<{
|
||||
children?: React.ReactNode;
|
||||
}> = ({ children, ...rest }) => {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<UserProvider>
|
||||
<DayjsProvider>
|
||||
<div className={"bg-pattern relative min-h-full"} {...rest}>
|
||||
<MobileNavigation />
|
||||
<div className="mx-auto max-w-4xl">{children}</div>
|
||||
</div>
|
||||
</DayjsProvider>
|
||||
</UserProvider>
|
||||
<LazyMotion features={domAnimation}>
|
||||
<UserProvider>
|
||||
<DayjsProvider>
|
||||
<ModalProvider>
|
||||
<div className={"bg-pattern relative min-h-full"} {...rest}>
|
||||
<MobileNavigation />
|
||||
<div className="mx-auto max-w-4xl">
|
||||
<AnimatePresence initial={false} exitBeforeEnter={true}>
|
||||
<m.div
|
||||
key={router.asPath}
|
||||
initial={{ opacity: 0, y: -50 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: -50 }}
|
||||
>
|
||||
{children}
|
||||
</m.div>
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</div>
|
||||
</ModalProvider>
|
||||
</DayjsProvider>
|
||||
</UserProvider>
|
||||
</LazyMotion>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue