import type { ReactNode } from 'react'
import { Outlet, useRouterState } from '@tanstack/react-router'
import { motion, useReducedMotion, type Variants } from 'motion/react'
import {
CARD_ITEM_VARIANTS,
CARD_STAGGER_VARIANTS,
MOTION_TRANSITION,
MOTION_VARIANTS,
STAGGER_ITEM_VARIANTS,
STAGGER_VARIANTS,
TABLE_ROW_VARIANTS,
TABLE_STAGGER_VARIANTS,
} from '@/lib/motion'
interface PageTransitionProps {
children: ReactNode
className?: string
}
export function PageTransition(props: PageTransitionProps) {
const shouldReduce = useReducedMotion()
if (shouldReduce) {
return
{props.children}
}
return (
{props.children}
)
}
export function AnimatedOutlet() {
const shouldReduce = useReducedMotion()
const routeKey = useRouterState({
select: (s) => s.location.pathname,
})
if (shouldReduce) {
return (
)
}
return (
)
}
interface StaggerContainerProps {
children: ReactNode
className?: string
variants?: Variants
}
export function StaggerContainer(props: StaggerContainerProps) {
const shouldReduce = useReducedMotion()
if (shouldReduce) {
return {props.children}
}
return (
{props.children}
)
}
interface StaggerItemProps {
children: ReactNode
className?: string
variants?: Variants
}
export function StaggerItem(props: StaggerItemProps) {
return (
{props.children}
)
}
export function TableStaggerContainer(props: StaggerContainerProps) {
const shouldReduce = useReducedMotion()
if (shouldReduce) {
return <>{props.children}>
}
return (
{props.children}
)
}
export function TableStaggerRow(props: StaggerItemProps) {
return (
{props.children}
)
}
export function CardStaggerContainer(props: StaggerContainerProps) {
const shouldReduce = useReducedMotion()
if (shouldReduce) {
return {props.children}
}
return (
{props.children}
)
}
export function CardStaggerItem(props: StaggerItemProps) {
return (
{props.children}
)
}
interface FadeInProps {
children: ReactNode
className?: string
delay?: number
}
export function FadeIn(props: FadeInProps) {
const shouldReduce = useReducedMotion()
if (shouldReduce) {
return {props.children}
}
return (
{props.children}
)
}