import { ComponentProps, useEffect, useState } from "react"; import { cn } from "../../utils/cn.js"; import { router } from "@inertiajs/react"; import { motion } from "motion/react"; const shakeVariants = { shaking: { x: [-20, -30, 30, -30, 30, 0], // larger left/right shake y: [-15, -25, 25, -25, 25, 0], // larger up/down shake }, rest: { x: 0, y: 0, }, }; export const Island = ({ className, preventNavigation, ...props }: ComponentProps & { preventNavigation?: boolean }) => { const [variant, setVariant] = useState("idle"); useEffect(() => { const listener = router.on("before", (event: any) => { if (preventNavigation) { setVariant("shaking"); event.preventDefault(); } }); return () => listener(); }, [preventNavigation]); return ( { if (def === "shaking") setVariant("idle"); }} transition={{ duration: 0.5 }} className={cn( "bg-background rounded-full py-4 px-6 border flex transition", { "border-destructive": variant === "shaking", }, className, )} {...props} /> ); }; export const IslandContent = ({ className, ...props }: ComponentProps<"div">) => { return
; }; export const IslandActions = ({ className, ...props }: ComponentProps<"div">) => { return
; };