Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad74da5dbc | ||
|
|
ed27d2cc63 | ||
|
|
d53fba06a2 | ||
|
|
370611cb01 | ||
|
|
75d4e006ff | ||
|
|
18f71c6730 |
@@ -0,0 +1,45 @@
|
||||
import { motion } from "framer-motion"
|
||||
|
||||
export function FloatingPaths({ position }: { position: number }) {
|
||||
const paths = Array.from({ length: 12 }, (_, i) => ({
|
||||
id: i,
|
||||
d: `M-${380 - i * 15 * position} -${189 + i * 18}C-${
|
||||
380 - i * 15 * position
|
||||
} -${189 + i * 18} -${312 - i * 15 * position} ${216 - i * 18} ${
|
||||
152 - i * 15 * position
|
||||
} ${343 - i * 18}C${616 - i * 15 * position} ${470 - i * 18} ${
|
||||
684 - i * 15 * position
|
||||
} ${875 - i * 18} ${684 - i * 15 * position} ${875 - i * 18}`,
|
||||
color: `rgba(var(--accent),${0.1 + i * 0.03})`,
|
||||
width: 0.5 + i * 0.09,
|
||||
}))
|
||||
|
||||
return (
|
||||
<div className="absolute inset-0 pointer-events-none floating-paths">
|
||||
<svg className="w-full h-full text-accent" viewBox="0 0 696 316" fill="none" style={{ transform: 'translateZ(0)' }}>
|
||||
<title>Background Paths</title>
|
||||
{paths.map((path) => (
|
||||
<motion.path
|
||||
key={path.id}
|
||||
d={path.d}
|
||||
stroke="currentColor"
|
||||
strokeWidth={path.width}
|
||||
strokeOpacity={0.1 + path.id * 0.03}
|
||||
initial={{ pathLength: 0.3, opacity: 0.6 }}
|
||||
animate={{
|
||||
pathLength: 1,
|
||||
opacity: [0.3, 0.6, 0.3],
|
||||
}}
|
||||
transition={{
|
||||
duration: 20 + (path.id % 3) * 5,
|
||||
repeat: Number.POSITIVE_INFINITY,
|
||||
ease: "linear",
|
||||
}}
|
||||
style={{ willChange: 'opacity' }}
|
||||
/>
|
||||
))}
|
||||
</svg>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Database, Server, Store, Code2, Box } from 'lucide-react';
|
||||
@@ -15,7 +15,6 @@ interface SkillGroup {
|
||||
items: SkillItem[];
|
||||
}
|
||||
|
||||
// Move iconMap outside component for better performance
|
||||
const iconMap: Record<string, React.ReactNode> = {
|
||||
'Python': <Code2 className="w-8 h-8" />,
|
||||
'Server': <Server className="w-8 h-8" />,
|
||||
@@ -33,19 +32,6 @@ const Skills = () => {
|
||||
const [selectedSkill, setSelectedSkill] = useState<string | null>(null);
|
||||
const [allSkills, setAllSkills] = useState<SkillItem[]>([]);
|
||||
|
||||
// Memoized event handlers
|
||||
const handleHoverStart = useCallback((skillName: string) => {
|
||||
setSelectedSkill(skillName);
|
||||
}, []);
|
||||
|
||||
const handleHoverEnd = useCallback(() => {
|
||||
setSelectedSkill(null);
|
||||
}, []);
|
||||
|
||||
const handleClick = useCallback((skillName: string) => {
|
||||
setSelectedSkill(prev => prev === skillName ? null : skillName);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
const skillGroups = t.raw('skillGroups') as SkillGroup[];
|
||||
@@ -72,8 +58,8 @@ const Skills = () => {
|
||||
className="space-y-2"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
onHoverStart={() => handleHoverStart(skill.name)}
|
||||
onHoverEnd={handleHoverEnd}
|
||||
onHoverStart={() => setSelectedSkill(skill.name)}
|
||||
onHoverEnd={() => setSelectedSkill(null)}
|
||||
>
|
||||
<div className="flex justify-between items-center">
|
||||
<div className="flex flex-col">
|
||||
@@ -120,7 +106,7 @@ const Skills = () => {
|
||||
selectedSkill === skill.name ? 'ring-2 ring-zinc-500' : ''
|
||||
}`}
|
||||
whileHover={{ scale: 1.05 }}
|
||||
onClick={() => handleClick(skill.name)}
|
||||
onClick={() => setSelectedSkill(skill.name === selectedSkill ? null : skill.name)}
|
||||
role="button"
|
||||
aria-pressed={selectedSkill === skill.name}
|
||||
>
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
// Mock next-intl
|
||||
vi.mock('next-intl', () => ({
|
||||
useTranslations: () => {
|
||||
const t = (key: string) => key;
|
||||
t.raw = (key: string) => {
|
||||
if (key === 'skillGroups') {
|
||||
return [
|
||||
{
|
||||
category: 'Programming',
|
||||
items: [
|
||||
{ name: 'Python', level: 90 },
|
||||
{ name: 'TypeScript', level: 85 },
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
return t;
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock framer-motion
|
||||
vi.mock('framer-motion', () => ({
|
||||
motion: {
|
||||
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock lucide-react icons
|
||||
vi.mock('lucide-react', () => ({
|
||||
Database: () => <div>Database Icon</div>,
|
||||
Server: () => <div>Server Icon</div>,
|
||||
Store: () => <div>Store Icon</div>,
|
||||
Code2: () => <div>Code2 Icon</div>,
|
||||
Box: () => <div>Box Icon</div>,
|
||||
}));
|
||||
|
||||
describe('Skills Component (About)', () => {
|
||||
it('exports component successfully', async () => {
|
||||
const Skills = await import('../Skills');
|
||||
expect(Skills.default).toBeDefined();
|
||||
});
|
||||
|
||||
it('iconMap is defined outside component for performance', async () => {
|
||||
// This test verifies that the iconMap optimization is in place
|
||||
// The actual iconMap is defined at module level
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it('component uses memoized callbacks', () => {
|
||||
// Verify the component follows memoization patterns with useCallback
|
||||
// handleHoverStart, handleHoverEnd, handleClick should be memoized
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import Image from 'next/image';
|
||||
import { motion } from 'framer-motion';
|
||||
@@ -123,4 +122,4 @@ const PortfolioCard = ({ project }: PortfolioCardProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(PortfolioCard);
|
||||
export default PortfolioCard;
|
||||
|
||||
@@ -18,21 +18,20 @@ interface PortfolioGridProps {
|
||||
projects: Project[];
|
||||
}
|
||||
|
||||
const containerVariants = {
|
||||
hidden: {},
|
||||
visible: {
|
||||
transition: {
|
||||
staggerChildren: 0.1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const itemVariants = {
|
||||
hidden: { opacity: 0, y: 20 },
|
||||
visible: { opacity: 1, y: 0 },
|
||||
};
|
||||
|
||||
const PortfolioGrid = ({ projects }: PortfolioGridProps) => {
|
||||
const containerVariants = {
|
||||
hidden: {},
|
||||
visible: {
|
||||
transition: {
|
||||
staggerChildren: 0.1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const itemVariants = {
|
||||
hidden: { opacity: 0, y: 20 },
|
||||
visible: { opacity: 1, y: 0 },
|
||||
};
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
// Mock next/link
|
||||
vi.mock('next/link', () => ({
|
||||
default: ({ children, ...props }: any) => <a {...props}>{children}</a>,
|
||||
}));
|
||||
|
||||
// Mock next/image
|
||||
vi.mock('next/image', () => ({
|
||||
default: (props: any) => <img {...props} />,
|
||||
}));
|
||||
|
||||
// Mock next-intl
|
||||
vi.mock('next-intl', () => ({
|
||||
useLocale: () => 'en',
|
||||
useTranslations: () => (key: string) => key,
|
||||
}));
|
||||
|
||||
// Mock framer-motion
|
||||
vi.mock('framer-motion', () => ({
|
||||
motion: {
|
||||
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock lucide-react icons
|
||||
vi.mock('lucide-react', () => ({
|
||||
ExternalLink: () => <div>ExternalLink Icon</div>,
|
||||
Calendar: () => <div>Calendar Icon</div>,
|
||||
Tag: () => <div>Tag Icon</div>,
|
||||
}));
|
||||
|
||||
describe('PortfolioCard Component', () => {
|
||||
it('exports memoized component successfully', async () => {
|
||||
const PortfolioCard = await import('../PortfolioCard');
|
||||
expect(PortfolioCard.default).toBeDefined();
|
||||
});
|
||||
|
||||
it('component is wrapped with React.memo', async () => {
|
||||
const PortfolioCard = await import('../PortfolioCard');
|
||||
// React.memo wrapped components have specific properties
|
||||
// This verifies the component is properly memoized
|
||||
expect(PortfolioCard.default).toBeDefined();
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it('prevents unnecessary re-renders with memoization', () => {
|
||||
// Verify the component uses React.memo to prevent re-renders
|
||||
// when props don't change
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useRef, useEffect, useCallback } from 'react';
|
||||
import { useState, useRef, useEffect } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
|
||||
@@ -32,15 +32,15 @@ const Experience = () => {
|
||||
|
||||
const totalPages = Math.ceil((Array.isArray(experiences) ? experiences.length : 0) / itemsPerPage);
|
||||
|
||||
const handleTouchStart = useCallback((e: React.TouchEvent) => {
|
||||
const handleTouchStart = (e: React.TouchEvent) => {
|
||||
setTouchStart(e.touches[0].clientX);
|
||||
}, []);
|
||||
};
|
||||
|
||||
const handleTouchMove = useCallback((e: React.TouchEvent) => {
|
||||
const handleTouchMove = (e: React.TouchEvent) => {
|
||||
setTouchEnd(e.touches[0].clientX);
|
||||
}, []);
|
||||
};
|
||||
|
||||
const handleTouchEnd = useCallback(() => {
|
||||
const handleTouchEnd = () => {
|
||||
if (!touchStart || !touchEnd) return;
|
||||
|
||||
const distance = touchStart - touchEnd;
|
||||
@@ -56,13 +56,13 @@ const Experience = () => {
|
||||
|
||||
setTouchStart(null);
|
||||
setTouchEnd(null);
|
||||
}, [touchStart, touchEnd, currentPage, totalPages]);
|
||||
};
|
||||
|
||||
const getCurrentPageItems = useCallback(() => {
|
||||
const getCurrentPageItems = () => {
|
||||
if (!Array.isArray(experiences)) return [];
|
||||
const startIndex = currentPage * itemsPerPage;
|
||||
return experiences.slice(startIndex, startIndex + itemsPerPage);
|
||||
}, [experiences, currentPage, itemsPerPage]);
|
||||
};
|
||||
|
||||
return (
|
||||
<section id="experience" className="py-12 md:py-24 overflow-hidden">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Database, Server, Code2, Bot, Workflow, FileCode2 } from 'lucide-react';
|
||||
@@ -66,14 +66,6 @@ const Skills = () => {
|
||||
const t = useTranslations('pages.home.skills');
|
||||
const [skills, setSkills] = useState<Skill[]>([]);
|
||||
|
||||
const handleHoverStart = useCallback((skillName: string) => {
|
||||
setSelectedSkill(skillName);
|
||||
}, []);
|
||||
|
||||
const handleHoverEnd = useCallback(() => {
|
||||
setSelectedSkill(null);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Temporary delay to see skeleton loading state
|
||||
const timer = setTimeout(() => {
|
||||
@@ -153,55 +145,10 @@ const Skills = () => {
|
||||
transition={{ duration: 0.5, delay: idx * 0.1 }}
|
||||
className="p-6 rounded-xl bg-zinc-800/30 backdrop-blur-sm flex flex-col items-center justify-center gap-3"
|
||||
>
|
||||
<<<<<<< HEAD
|
||||
<motion.div
|
||||
className={`relative p-6 rounded-xl bg-zinc-800/30 backdrop-blur-sm flex flex-col items-center justify-center gap-3 cursor-pointer transition-colors duration-300 hover:bg-zinc-700/50 ${
|
||||
selectedSkill === skill.name ? 'ring-2 ring-zinc-500 z-20' : ''
|
||||
}`}
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
onHoverStart={() => handleHoverStart(skill.name)}
|
||||
onHoverEnd={handleHoverEnd}
|
||||
role="button"
|
||||
>
|
||||
<motion.div
|
||||
className={selectedSkill === skill.name ? 'text-zinc-500' : 'text-white'}
|
||||
animate={{
|
||||
rotate: selectedSkill === skill.name ? [0, -10, 10, 0] : 0,
|
||||
scale: selectedSkill === skill.name ? 1.1 : 1
|
||||
}}
|
||||
transition={{ duration: 0.4 }}
|
||||
>
|
||||
{iconMap[skill.name] || <Code2 className="w-8 h-8" />}
|
||||
</motion.div>
|
||||
<span className="text-white text-sm text-center">{skill.name}</span>
|
||||
|
||||
<AnimatePresence>
|
||||
{selectedSkill === skill.name && (
|
||||
<motion.div
|
||||
className="absolute left-1/2 top-0 -translate-x-1/2 bg-zinc-800/80 backdrop-blur-sm rounded-lg px-4 py-2 text-zinc-300 text-xs text-center shadow-xl pointer-events-none"
|
||||
initial={{ opacity: 0, y: 5 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: 5 }}
|
||||
transition={{ duration: 0.15 }}
|
||||
style={{
|
||||
whiteSpace: 'nowrap',
|
||||
transform: 'translate(-50%, calc(-100% - 12px))',
|
||||
zIndex: 999
|
||||
}}
|
||||
>
|
||||
{skill.description}
|
||||
<div className="absolute left-1/2 bottom-0 translate-y-1/2 -translate-x-1/2 w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px] border-t-zinc-800" />
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</motion.div>
|
||||
=======
|
||||
<div className="text-white">
|
||||
{iconMap[skill.name] || <Code2 className="w-8 h-8" />}
|
||||
</div>
|
||||
<span className="text-white text-sm text-center">{skill.name}</span>
|
||||
>>>>>>> origin/master
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
// Mock next-intl
|
||||
vi.mock('next-intl', () => ({
|
||||
useTranslations: () => {
|
||||
const t = (key: string) => {
|
||||
const translations: Record<string, any> = {
|
||||
title: 'Experience',
|
||||
};
|
||||
return translations[key] || key;
|
||||
};
|
||||
t.raw = (key: string) => {
|
||||
if (key === 'positions') {
|
||||
return [
|
||||
{
|
||||
role: 'Software Engineer',
|
||||
company: 'Tech Corp',
|
||||
period: '2020-2022',
|
||||
highlights: ['Built features', 'Improved performance']
|
||||
},
|
||||
];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
return t;
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock framer-motion
|
||||
vi.mock('framer-motion', () => ({
|
||||
motion: {
|
||||
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
|
||||
},
|
||||
AnimatePresence: ({ children }: any) => <>{children}</>,
|
||||
}));
|
||||
|
||||
describe('Experience Component', () => {
|
||||
it('exports component successfully', async () => {
|
||||
const Experience = await import('../Experience');
|
||||
expect(Experience.default).toBeDefined();
|
||||
});
|
||||
|
||||
it('component has correct memoization patterns', () => {
|
||||
// Verify the component follows memoization patterns
|
||||
// This test ensures the component structure is maintained
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,101 +0,0 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import Skills from '../Skills';
|
||||
|
||||
// Mock next-intl
|
||||
vi.mock('next-intl', () => ({
|
||||
useTranslations: () => {
|
||||
const t = (key: string) => {
|
||||
const translations: Record<string, any> = {
|
||||
title: 'Skills',
|
||||
'skills': [
|
||||
{ name: 'Python', level: 90, description: 'Backend development' },
|
||||
{ name: 'TypeScript', level: 85, description: 'Frontend development' },
|
||||
],
|
||||
};
|
||||
return translations[key] || key;
|
||||
};
|
||||
t.raw = (key: string) => {
|
||||
if (key === 'skills') {
|
||||
return [
|
||||
{ name: 'Python', level: 90, description: 'Backend development' },
|
||||
{ name: 'TypeScript', level: 85, description: 'Frontend development' },
|
||||
];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
return t;
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock framer-motion
|
||||
vi.mock('framer-motion', () => ({
|
||||
motion: {
|
||||
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
|
||||
},
|
||||
AnimatePresence: ({ children }: any) => <>{children}</>,
|
||||
}));
|
||||
|
||||
describe('Skills Component', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const { container } = render(<Skills />);
|
||||
expect(container).toBeTruthy();
|
||||
});
|
||||
|
||||
it('displays the skills title', () => {
|
||||
render(<Skills />);
|
||||
expect(screen.getByText('Skills')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('renders skill items with correct data', () => {
|
||||
render(<Skills />);
|
||||
expect(screen.getByText('Python')).toBeTruthy();
|
||||
expect(screen.getByText('TypeScript')).toBeTruthy();
|
||||
expect(screen.getByText('90%')).toBeTruthy();
|
||||
expect(screen.getByText('85%')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('renders progress bars with correct attributes', () => {
|
||||
const { container } = render(<Skills />);
|
||||
const progressBars = container.querySelectorAll('[role="progressbar"]');
|
||||
expect(progressBars.length).toBeGreaterThan(0);
|
||||
|
||||
// Check first progress bar has correct attributes
|
||||
const firstProgressBar = progressBars[0];
|
||||
expect(firstProgressBar.getAttribute('aria-valuenow')).toBe('90');
|
||||
expect(firstProgressBar.getAttribute('aria-valuemin')).toBe('0');
|
||||
expect(firstProgressBar.getAttribute('aria-valuemax')).toBe('100');
|
||||
});
|
||||
|
||||
it('has memoized event handlers', () => {
|
||||
// This test verifies that useCallback is used by checking
|
||||
// that the component uses the pattern (we can't directly test memoization in unit tests)
|
||||
const { rerender } = render(<Skills />);
|
||||
|
||||
// Re-render the component
|
||||
rerender(<Skills />);
|
||||
|
||||
// If the component re-renders without errors, memoization is likely working
|
||||
expect(screen.getByText('Skills')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('handles missing skills gracefully', () => {
|
||||
// Re-mock with empty skills
|
||||
vi.mock('next-intl', () => ({
|
||||
useTranslations: () => {
|
||||
const t = (key: string) => key;
|
||||
t.raw = () => {
|
||||
throw new Error('No skills');
|
||||
};
|
||||
return t;
|
||||
},
|
||||
}));
|
||||
|
||||
const { container } = render(<Skills />);
|
||||
expect(container).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,21 +1,4 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
<<<<<<< HEAD
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
setupFiles: ['./vitest.setup.ts'],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
=======
|
||||
import { resolve } from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
@@ -53,5 +36,4 @@ export default defineConfig({
|
||||
'@': resolve(__dirname, './src')
|
||||
}
|
||||
}
|
||||
>>>>>>> origin/master
|
||||
});
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// Vitest setup file
|
||||
// This file runs before each test file
|
||||
|
||||
// Mock next-intl for testing
|
||||
vi.mock('next-intl', () => ({
|
||||
useTranslations: () => (key: string) => {
|
||||
if (key === 'title') return 'Test Title';
|
||||
if (key === 'raw') return () => [];
|
||||
return key;
|
||||
},
|
||||
useLocale: () => 'en',
|
||||
}));
|
||||
|
||||
// Mock framer-motion to avoid animation issues in tests
|
||||
vi.mock('framer-motion', () => ({
|
||||
motion: {
|
||||
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
|
||||
},
|
||||
AnimatePresence: ({ children }: any) => <>{children}</>,
|
||||
}));
|
||||
Reference in New Issue
Block a user