Files
portifolio-evandrodevbr/app/providers/AnimationProvider.tsx
T
Evandro Fonseca Junior b791b7de9e feat: control room hero, SEO/AEO optimization and design system fixes
Hero: replace particle field with cobe globe (Capricorn view, multi-axis drag, reduced-motion safe), telemetry HUD with pointer parallax, particle text build effect, Space Grotesk display font. SEO: short titles with template, PT-BR accents, twitter cards on dynamic cases, escaped JSON-LD via lib/jsonld.ts, CSP report-only, 25 service FAQs answer-first. Design: fix TW4 layered reset killing spacing utilities, literal @theme tokens, mobile hero overflow, header overlap, empty case cards. Remove framer-motion (unified on motion/react), header version badge, phone number from hero CTA. Production build verified (24 static pages).
2026-08-27 10:55:21 -03:00

94 lines
2.3 KiB
TypeScript

"use client";
import { createContext, type ReactNode, useContext } from "react";
import { useReducedMotion } from "@/app/hooks/useReducedMotion";
import { animationConfig } from "@/app/lib/animations/config";
/**
* Animation Configuration Context
* Provides global animation settings including reduced motion detection
*/
interface AnimationConfig {
reducedMotion: boolean;
easings: typeof animationConfig.easings;
durations: typeof animationConfig.durations;
}
const AnimationContext = createContext<AnimationConfig | undefined>(undefined);
interface AnimationProviderProps {
children: ReactNode;
}
/**
* AnimationProvider
*
* Provider component that supplies global animation configuration through React context.
* Automatically detects user's reduced motion preference and provides centralized
* animation settings (easings, durations) to all child components.
*
* @example
* ```tsx
* // In app/layout.tsx
* <AnimationProvider>
* <YourApp />
* </AnimationProvider>
* ```
*
* @see useAnimationConfig - Hook to consume this context
*/
export function AnimationProvider({ children }: AnimationProviderProps) {
const reducedMotion = useReducedMotion();
const config: AnimationConfig = {
reducedMotion,
easings: animationConfig.easings,
durations: animationConfig.durations,
};
return (
<AnimationContext.Provider value={config}>
{children}
</AnimationContext.Provider>
);
}
/**
* useAnimationConfig
*
* Hook to access global animation configuration from AnimationProvider context.
* Provides reduced motion state, easing curves, and duration presets.
*
* @returns {AnimationConfig} Animation configuration object
* @throws {Error} If used outside of AnimationProvider
*
* @example
* ```tsx
* function MyComponent() {
* const { reducedMotion, easings, durations } = useAnimationConfig();
*
* return (
* <motion.div
* animate={{
* opacity: 1,
* y: reducedMotion ? 0 : 20
* }}
* transition={{
* duration: durations.normal,
* ease: easings.easeOut
* }}
* />
* );
* }
* ```
*/
export function useAnimationConfig(): AnimationConfig {
const context = useContext(AnimationContext);
if (context === undefined) {
throw new Error("useAnimationConfig must be used within AnimationProvider");
}
return context;
}