Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 2 additions & 96 deletions .storybook/utils/mocks/animationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,106 +9,12 @@ import React from 'react';
import { AnimationContext, AnimationContextType } from '../../../src/context/AnimationContext';
import type { Decorator } from '../index';

// Define standard variants to use across components
const defaultFadeIn = {
hidden: { opacity: 0 },
visible: { opacity: 1, transition: { duration: 0.5 } }
};

const defaultSlideUp = {
hidden: { opacity: 0, y: 20 },
visible: { opacity: 1, y: 0, transition: { duration: 0.5 } }
};

const defaultScale = {
hidden: { opacity: 0, scale: 0.8 },
visible: { opacity: 1, scale: 1, transition: { duration: 0.5 } }
};

const defaultPulse = {
hidden: { opacity: 0.6 },
visible: {
opacity: [0.6, 1, 0.6],
transition: {
repeat: Infinity,
duration: 2,
ease: "easeInOut" as const
}
}
};

const defaultMatrix = {
hidden: { opacity: 0 },
visible: {
opacity: 1,
transition: {
duration: 0.8,
staggerChildren: 0.05
}
}
};

const defaultGlitch = {
hidden: { opacity: 0 },
visible: {
opacity: 1,
x: [0, -2, 3, -1, 0],
transition: {
duration: 0.5,
x: {
repeat: Infinity,
repeatType: "reverse",
duration: 0.2
}
}
}
};

/**
* Mock animation context data with working no-op implementations
* Mock animation context data: animations on, no reduced-motion preference
*/
export const mockAnimationData: AnimationContextType = {
inView: true, // Always in view for stories
setInView: () => {}, // No-op for stories
animationEnabled: true,
entryAnimations: {},
registerEntryAnimation: (id: string, initialState: string = 'visible') => {
// In Storybook, we'll default all animations to visible
// This ensures elements are shown immediately without animations
console.log(`[Storybook] Registered animation for ${id} with state ${initialState}`);
},
playEntryAnimation: (id: string, delay: number = 0) => {
console.log(`[Storybook] Playing animation for ${id} with delay ${delay}`);
},
resetEntryAnimations: () => {
console.log(`[Storybook] Reset animations`);
},
animationStaggerDelay: 0,
getAnimationDelay: (index: number) => '0s', // No delay in Storybook

// Add missing properties used by components
controls: {
start: () => Promise.resolve(),
stop: () => Promise.resolve(),
set: () => Promise.resolve(),
mount: () => Promise.resolve(),
unmount: () => Promise.resolve()
} as any, // Use type assertion to avoid TypeScript errors
getVariants: (duration = 0.5, delay = 0) => ({
hidden: { opacity: 0 },
visible: { opacity: 1, transition: { duration, delay } }
}),
fadeInVariants: defaultFadeIn,
slideUpVariants: defaultSlideUp,
scaleVariants: defaultScale,
pulseVariants: defaultPulse,
matrixVariants: defaultMatrix,
glitchVariants: defaultGlitch,
prefersReducedMotion: false,
isLowPowerDevice: false,
optimizeVariants: (variants) => variants,
enablePerformanceMonitoring: () => {},
disablePerformanceMonitoring: () => {}
prefersReducedMotion: false
};

/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ These have no package.json entry; run them with `node scripts/<name>.js`.

- **analyze-dependencies.js**: scans components, hooks, contexts and utils for import patterns and circular dependencies. Writes `dependency-report.html` and `dependency-report.json` to the project root.
- **finalize-package-cleanup.js**: lists the package.json scripts by category. With `--clean` it rewrites package.json (after saving `package.json.bak`) to drop the one-time reorganization scripts; none of those remain, so it currently removes nothing.
- **monitor-animation-performance.js**: not a command-line script. It is a browser module that measures animation frame times; `src/context/AnimationContext.tsx` loads it through the `@scripts` alias when performance monitoring is switched on.
- **monitor-animation-performance.js**: not a command-line script. It is a browser module that measures animation frame times. Nothing imports it at the moment.

## Not working

Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/utilities/animations.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Animation Utilities
*
* This file has been converted to use framer-motion for animations.
* See src/context/AnimationContext.tsx and the MotionVariants export.
* See src/utils/motion.ts for the shared variants.
*
* IMPORTANT: The CSS classes below are kept only as fallbacks for when JS is disabled.
* All new code should use framer-motion's animation system.
Expand Down
2 changes: 0 additions & 2 deletions src/components/layout/Background/Background.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import Background from './Background';
vi.mock('@context/AnimationContext', () => ({
useAnimation: () => ({
animationEnabled: true,
registerEntryAnimation: vi.fn(),
playEntryAnimation: vi.fn(),
}),
}));

Expand Down
18 changes: 15 additions & 3 deletions src/components/layout/Section/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ import { motion, HTMLMotionProps, MotionProps } from 'framer-motion';
import { FaGraduationCap, FaBriefcase, FaCode, FaStar, FaHandshake, FaShieldAlt } from 'react-icons/fa';
import '@assets/css/tailwind.css';
import './Section.css';
import { useAnimation, MotionVariants } from '@context/AnimationContext';
import { useAnimation } from '@context/AnimationContext';
import { slideUpVariants, fadeInVariants } from '@utils/motion';

// Staggers the section's children as they appear
const containerVariants = {
hidden: { opacity: 0 },
visible: {
opacity: 1,
transition: {
staggerChildren: 0.1
}
}
};

export interface SectionProps extends HTMLMotionProps<'section'> {
/** The section content */
Expand Down Expand Up @@ -50,7 +62,7 @@ const Section = ({
role = 'region',
...rest
}: SectionProps) => {
const { animationEnabled, slideUpVariants, fadeInVariants } = useAnimation();
const { animationEnabled } = useAnimation();

// Base classes - removed background styling to let global background show through
const sectionClasses = [
Expand Down Expand Up @@ -146,7 +158,7 @@ const Section = ({
const motionProps: MotionProps = animationEnabled ? {
initial: "hidden",
animate: "visible",
variants: MotionVariants.container,
variants: containerVariants,
} : {};

// Handle animation with Framer Motion
Expand Down
Loading
Loading