Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

1.5 KB
Raw Blame
"use client";

import { motion, useReducedMotion, Variants } from "framer-motion";
import { ReactNode } from "react";

const ITEM: Variants = {
  hidden: { opacity: 0, y: 14, filter: "blur(8px)" },
  show: {
    opacity: 1,
    y: 0,
    filter: "blur(0px)",
    transition: { duration: 0.45, ease: [0.16, 1, 0.3, 1] },
  },
};

const ITEM_UNBLURRED: Variants = {
  hidden: { opacity: 0, y: 14 },
  show: {
    opacity: 1,
    y: 0,
    transition: { duration: 0.45, ease: [0.16, 1, 0.3, 1] },
  },
};

const ITEM_REDUCED: Variants = {
  hidden: { opacity: 0 },
  show: { opacity: 1, transition: { duration: 0.2 } },
};

export function RevealGroup({
  children,
  className,
}: {
  children: ReactNode;
  className?: string;
}) {
  return <div className={className}>{children}</div>;
}

// Each item drives its own reveal instead of inheriting a variant from the
// group: variant propagation only reaches children that exist when the
// parent animates, so items mounted later (the mic block returning after
// processing, the subline after the recovery prompt) would render stuck at
// `hidden` — an invisible page with a working headline.
export function RevealItem({
  children,
  className,
  blur = true,
}: {
  children: ReactNode;
  className?: string;
  blur?: boolean;
}) {
  const prefersReducedMotion = useReducedMotion();

  return (
    <motion.div
      variants={
        prefersReducedMotion ? ITEM_REDUCED : blur ? ITEM : ITEM_UNBLURRED
      }
      initial="hidden"
      animate="show"
      className={className}
    >
      {children}
    </motion.div>
  );
}