Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hayden Bleasel 2026-03-13 13:12:33 -07:00 committed by GitHub
parent 3bc77653ad
commit 453f5bb3e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
94 changed files with 4029 additions and 8199 deletions

View file

@ -1,22 +1,36 @@
"use client";
import { motion } from "motion/react";
import {
type CSSProperties,
type ElementType,
type JSX,
memo,
useMemo,
} from "react";
import { cn } from "@/lib/utils";
import type { MotionProps } from "motion/react";
import type { CSSProperties, ElementType, JSX } from "react";
export type TextShimmerProps = {
import { cn } from "@/lib/utils";
import { motion } from "motion/react";
import { memo, useMemo } from "react";
type MotionHTMLProps = MotionProps & Record<string, unknown>;
// Cache motion components at module level to avoid creating during render
const motionComponentCache = new Map<
keyof JSX.IntrinsicElements,
React.ComponentType<MotionHTMLProps>
>();
const getMotionComponent = (element: keyof JSX.IntrinsicElements) => {
let component = motionComponentCache.get(element);
if (!component) {
component = motion.create(element);
motionComponentCache.set(element, component);
}
return component;
};
export interface TextShimmerProps {
children: string;
as?: ElementType;
className?: string;
duration?: number;
spread?: number;
};
}
const ShimmerComponent = ({
children,
@ -25,7 +39,7 @@ const ShimmerComponent = ({
duration = 2,
spread = 2,
}: TextShimmerProps) => {
const MotionComponent = motion.create(
const MotionComponent = getMotionComponent(
Component as keyof JSX.IntrinsicElements
);
@ -51,9 +65,9 @@ const ShimmerComponent = ({
} as CSSProperties
}
transition={{
repeat: Number.POSITIVE_INFINITY,
duration,
ease: "linear",
repeat: Number.POSITIVE_INFINITY,
}}
>
{children}