diff --git a/site/.oxlintrc.jsonc b/site/.oxlintrc.jsonc index 85f58434934..b43ca941ea4 100644 --- a/site/.oxlintrc.jsonc +++ b/site/.oxlintrc.jsonc @@ -109,6 +109,7 @@ "refs": "error", "erasing-op": "error", "no-unused-expressions": "error", + "static-components": "error", // --- security --- "jsx-no-target-blank": "error", @@ -238,7 +239,6 @@ "no-noninteractive-element-interactions": "off", // (small) "no-useless-fallback-in-spread": "off", // (small) "no-conditional-tests": "off", // (small) - "static-components": "off", // (small) "no-restricted-imports": [ "error", diff --git a/site/src/pages/AgentsPage/components/ChatElements/Shimmer.tsx b/site/src/pages/AgentsPage/components/ChatElements/Shimmer.tsx index 5b19b3d7f4c..192bfdac921 100644 --- a/site/src/pages/AgentsPage/components/ChatElements/Shimmer.tsx +++ b/site/src/pages/AgentsPage/components/ChatElements/Shimmer.tsx @@ -1,28 +1,15 @@ import { cn } from "cn"; -import type { MotionProps } from "motion/react"; import { MotionConfig, MotionConfigContext, motion } from "motion/react"; import { useContext } from "react"; -type MotionHTMLProps = MotionProps & Record; - -// Cache motion components at module level to avoid creating during render -const motionComponentCache = new Map< - keyof React.JSX.IntrinsicElements, - React.ComponentType ->(); - -const getMotionComponent = (element: keyof React.JSX.IntrinsicElements) => { - let component = motionComponentCache.get(element); - if (!component) { - component = motion.create(element); - motionComponentCache.set(element, component); - } - return component; +const motionComponents = { + p: motion.p, + span: motion.span, }; type TextShimmerProps = { children: string; - as?: React.ElementType; + as?: keyof typeof motionComponents; className?: string; duration?: number; spread?: number; @@ -30,14 +17,12 @@ type TextShimmerProps = { const ShimmerComponent = ({ children, - as: Component = "p", + as = "p", className, duration = 2, spread = 2, }: TextShimmerProps) => { - const MotionComponent = getMotionComponent( - Component as keyof React.JSX.IntrinsicElements, - ); + const MotionComponent = motionComponents[as]; // skipAnimations jumps to the final keyframe, which leaves the // gradient offscreen, so hold it centered for captures.