2026-01-07 09:31:02 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
import { Card } from '../ui/card';
|
|
|
|
|
import { Achievement } from '../../types';
|
|
|
|
|
import { Lock, CheckCircle } from 'lucide-react';
|
|
|
|
|
|
|
|
|
|
interface AchievementCardProps {
|
|
|
|
|
achievement: Achievement;
|
|
|
|
|
compact?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
export const AchievementCard: React.FC<AchievementCardProps> = ({
|
|
|
|
|
achievement,
|
|
|
|
|
compact = false,
|
|
|
|
|
}) => {
|
2026-01-07 09:31:02 +00:00
|
|
|
const isUnlocked = achievement.progress >= achievement.maxProgress;
|
2026-01-13 18:47:57 +00:00
|
|
|
const percentage = Math.min(
|
|
|
|
|
100,
|
|
|
|
|
(achievement.progress / achievement.maxProgress) * 100,
|
|
|
|
|
);
|
2026-01-07 09:31:02 +00:00
|
|
|
|
|
|
|
|
return (
|
2026-01-13 18:47:57 +00:00
|
|
|
<Card
|
|
|
|
|
variant={isUnlocked ? 'gaming' : 'default'}
|
|
|
|
|
className={`relative overflow-hidden transition-all group ${isUnlocked ? 'border-kodo-gold/30 bg-kodo-gold/5' : 'opacity-80 grayscale hover:grayscale-0 hover:opacity-100'}`}
|
2026-01-07 09:31:02 +00:00
|
|
|
>
|
2026-01-13 18:47:57 +00:00
|
|
|
{isUnlocked && (
|
|
|
|
|
<div className="absolute top-2 right-2 text-kodo-gold animate-pulse">
|
|
|
|
|
<CheckCircle className="w-5 h-5" />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{!isUnlocked && (
|
2026-01-16 00:59:31 +00:00
|
|
|
<div className="absolute top-2 right-2 text-kodo-content-dim">
|
2026-01-13 18:47:57 +00:00
|
|
|
<Lock className="w-4 h-4" />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<div
|
aesthetic-improvements: align spacing to 8px grid (Action 11.2.1.3)
- Created automated script (scripts/align-8px-grid.py) to align all spacing to 8px grid
- Replaced non-8px-aligned spacing: gap-3/p-3/m-3 (12px) → gap-4/p-4/m-4 (16px), gap-5/p-5/m-5 (20px) → gap-6/p-6/m-6 (24px), gap-10/p-10/m-10 (40px) → gap-12/p-12/m-12 (48px), gap-20/p-20/m-20 (80px) → gap-24/p-24/m-24 (96px)
- Preserved: 4px values (gap-1, p-1, m-1) as they may be intentional fine-tuning, responsive breakpoints (sm:, md:, lg:), test files, documentation
- Modified files across all components to ensure consistent 8px grid alignment
- Action 11.2.1.3: Align all elements to 8px grid - COMPLETE
2026-01-16 10:50:46 +00:00
|
|
|
className={`flex ${compact ? 'flex-row items-center gap-4' : 'flex-col items-center text-center gap-4'}`}
|
2026-01-13 18:47:57 +00:00
|
|
|
>
|
|
|
|
|
<div
|
2026-01-16 00:59:31 +00:00
|
|
|
className={`rounded-full bg-gradient-to-br from-kodo-graphite to-black flex items-center justify-center border-2 ${isUnlocked ? 'border-kodo-gold w-16 h-16 text-3xl shadow-[0_0_15px_rgba(234,179,8,0.3)]' : 'border-kodo-steel w-12 h-12 text-xl text-kodo-content-dim'}`}
|
2026-01-13 18:47:57 +00:00
|
|
|
>
|
|
|
|
|
{achievement.icon}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
<h4
|
2026-01-16 00:59:31 +00:00
|
|
|
className={`font-bold truncate ${isUnlocked ? 'text-white' : 'text-kodo-content-dim'}`}
|
2026-01-13 18:47:57 +00:00
|
|
|
>
|
|
|
|
|
{achievement.name}
|
|
|
|
|
</h4>
|
2026-01-16 00:59:31 +00:00
|
|
|
<p className="text-xs text-kodo-content-dim line-clamp-2 mb-2">
|
2026-01-13 18:47:57 +00:00
|
|
|
{achievement.description}
|
|
|
|
|
</p>
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
{/* Progress */}
|
2026-01-16 00:59:31 +00:00
|
|
|
<div className="w-full bg-kodo-graphite h-1.5 rounded-full overflow-hidden">
|
2026-01-13 18:47:57 +00:00
|
|
|
<div
|
2026-01-16 00:59:31 +00:00
|
|
|
className={`h-full transition-all duration-500 ${isUnlocked ? 'bg-kodo-gold' : 'bg-kodo-steel'}`}
|
2026-01-13 18:47:57 +00:00
|
|
|
style={{ width: `${percentage}%` }}
|
|
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex justify-between text-[10px] mt-1 font-mono">
|
2026-01-16 00:59:31 +00:00
|
|
|
<span className={isUnlocked ? 'text-kodo-gold' : 'text-kodo-content-dim'}>
|
2026-01-13 18:47:57 +00:00
|
|
|
{achievement.progress} / {achievement.maxProgress}
|
|
|
|
|
</span>
|
aesthetic-improvements: reduce decorative cyan in marketplace, gamification, commerce, and education (80/20 rule, batch 10)
- Marketplace: LicenceDetailsModal decorative icon and price text, ProductDetailView decorative author text, ReviewProductModal decorative icon, LicenceCard decorative price text (4 instances)
- Gamification: AchievementCard decorative XP reward text, LeaderboardView loading spinner and decorative XP text, ProfileXPView loading spinner and decorative icons, AchievementsView loading spinner (5 instances)
- Commerce: WishlistView decorative price text, PromoCodeModal decorative icon, CartItem decorative license tag icon, OrderSummary decorative total price text (4 instances)
- Education: MyCoursesView decorative icon (1 instance)
- Total: ~14 files, ~14 instances replaced
- Preserved: Functional links (LicenceDetailsModal legal contract link), active/selected states (CourseLearningView active lesson, QuizModal selected answer - already preserved), primary actions, design system variants
- Action 11.3.1.3 in progress (tenth batch: marketplace, gamification, commerce, and education components)
2026-01-16 10:23:25 +00:00
|
|
|
<span className="text-kodo-steel">+{achievement.xpReward} XP</span>
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
};
|