diff --git a/src/components/layout/LeftNav.tsx b/src/components/layout/LeftNav.tsx index 84d96151..6770f25d 100644 --- a/src/components/layout/LeftNav.tsx +++ b/src/components/layout/LeftNav.tsx @@ -1,14 +1,29 @@ -import { cn } from "@/utils/cn"; -import { Link, useMatchRoute } from "@tanstack/react-router"; +import { HTMLAttributes, Ref, forwardRef } from "react"; +import { useMatchRoute, createLink } from "@tanstack/react-router"; +import { m, MotionProps, useReducedMotion } from "framer-motion"; +import { cn } from "@/utils/cn"; import { routeTitleToPathMapping, RouteTitle, } from "@/components/layout/Header"; import { useSentinel } from "@/lib/queries/sentinel/useSentinel"; +const MotionLinkForwardRef = forwardRef( + ( + props: MotionProps & HTMLAttributes, + ref: Ref, + ) => { + return ; + }, +); +MotionLinkForwardRef.displayName = "MotionLinkForwardRef"; + +const MotionLink = createLink(MotionLinkForwardRef); + export function LeftNav() { const matchRoute = useMatchRoute(); + const isReducedMotion = useReducedMotion(); const { data: isSentinel } = useSentinel(); return ( ); diff --git a/src/components/providers/FramerMotionProvider.tsx b/src/components/providers/FramerMotionProvider.tsx index b42b9499..d03df56a 100644 --- a/src/components/providers/FramerMotionProvider.tsx +++ b/src/components/providers/FramerMotionProvider.tsx @@ -1,7 +1,12 @@ -import { LazyMotion, domAnimation } from "framer-motion"; +import { LazyMotion } from "framer-motion"; -// NOTE: Reduced bundle size, -// see: https://www.framer.com/motion/guide-reduce-bundle-size/ +// NOTE: Reduced initial bundle size. +// Lazy load rest of the Framer Motion features after the initial render. +// See: https://motion.dev/docs/react-reduce-bundle-size + +// Make sure to return the specific export containing the feature bundle. +const loadFeatures = () => + import("framer-motion").then((module) => module.domMax); export const FramerMotionProvider = ({ children, @@ -9,7 +14,7 @@ export const FramerMotionProvider = ({ children: React.ReactNode; }) => { return ( - + {children} );