algospaced-dsa / algospaced-ui /src /components /map /ExpeditionLogModal.tsx
iamfebin's picture
feat: initial commit for AlgoSpaced DSA Review
8800c81
Raw History Blame Contribute Delete
5.83 kB
import React from 'react';
import type { MapNode, MapTheme } from '../../types/mapTypes';
import { Trophy, CheckCircle2, RotateCcw, X, Sparkles } from 'lucide-react';
interface ExpeditionLogModalProps {
isOpen: boolean;
onClose: () => void;
nodes: MapNode[];
theme: MapTheme;
onReset: () => void;
}
export const ExpeditionLogModal: React.FC<ExpeditionLogModalProps> = ({
isOpen,
onClose,
nodes,
theme,
onReset,
}) => {
if (!isOpen) return null;
const isDark = theme.id !== 'parchment';
const totalCount = nodes.length;
return (
<div className="fixed inset-0 z-[120] flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm animate-fade-in select-none">
<div
id="expedition-complete-modal"
className={`relative w-full max-w-lg p-6 rounded-2xl border-2 shadow-2xl transition-all ${
isDark
? 'bg-[#1c1813] border-[#594634] text-[#f2e6d5]'
: 'bg-[#f7efe0] border-[#c8b28f] text-[#332415]'
}`}
>
{/* Close Button */}
<button
onClick={onClose}
className="absolute top-4 right-4 p-1.5 rounded-lg opacity-60 hover:opacity-100 hover:bg-black/10 cursor-pointer"
>
<X className="w-5 h-5" />
</button>
{/* Header with Trophy */}
<div className="text-center mb-6">
<div className="inline-flex p-3 rounded-2xl bg-amber-500/20 border border-amber-500/40 text-amber-500 mb-3 shadow-lg shadow-amber-500/20">
<Trophy className="w-10 h-10 animate-bounce" />
</div>
<h2 className="font-cinzel-dec font-bold text-2xl md:text-3xl text-amber-600 dark:text-amber-400">
Expedition Completed!
</h2>
<p className="font-garamond italic text-sm md:text-base opacity-80 mt-1">
All {totalCount} Waypoints and the entire ancient trail are now fully illuminated.
</p>
</div>
{/* Expedition Statistics Grid */}
<div className="grid grid-cols-3 gap-3 mb-6">
<div className="p-3 rounded-xl bg-amber-500/10 border border-amber-900/15 text-center">
<span className="block font-cinzel font-bold text-xl text-amber-600 dark:text-amber-300">{totalCount}</span>
<span className="font-garamond text-xs opacity-75">Nodes Solved</span>
</div>
<div className="p-3 rounded-xl bg-amber-500/10 border border-amber-900/15 text-center">
<span className="block font-cinzel font-bold text-xl text-amber-600 dark:text-amber-300">7</span>
<span className="font-garamond text-xs opacity-75">Biomes Crossed</span>
</div>
<div className="p-3 rounded-xl bg-amber-500/10 border border-amber-900/15 text-center">
<span className="block font-cinzel font-bold text-xl text-amber-600 dark:text-amber-300">1,620m</span>
<span className="font-garamond text-xs opacity-75">Peak Citadel</span>
</div>
</div>
{/* Trail Highlights */}
<div className="space-y-2 mb-6 max-h-48 overflow-y-auto custom-scrollbar pr-1">
{nodes.length > 0 && (
<div className="flex items-center gap-2 text-xs font-garamond">
<CheckCircle2 className="w-4 h-4 text-emerald-500 flex-shrink-0" />
<span className="font-bold">Waypoint 1:</span>
<span>{nodes[0].name}</span>
</div>
)}
{nodes.length > 25 && (
<div className="flex items-center gap-2 text-xs font-garamond">
<CheckCircle2 className="w-4 h-4 text-emerald-500 flex-shrink-0" />
<span className="font-bold">Waypoint 25:</span>
<span>{nodes[24].name}</span>
</div>
)}
{nodes.length > 50 && (
<div className="flex items-center gap-2 text-xs font-garamond">
<CheckCircle2 className="w-4 h-4 text-emerald-500 flex-shrink-0" />
<span className="font-bold">Waypoint 50:</span>
<span>{nodes[49].name}</span>
</div>
)}
{nodes.length > 75 && (
<div className="flex items-center gap-2 text-xs font-garamond">
<CheckCircle2 className="w-4 h-4 text-emerald-500 flex-shrink-0" />
<span className="font-bold">Waypoint 75:</span>
<span>{nodes[74].name}</span>
</div>
)}
{nodes.length > 0 && (
<div className="flex items-center gap-2 text-xs font-garamond">
<CheckCircle2 className="w-4 h-4 text-emerald-500 flex-shrink-0" />
<span className="font-bold">Final Milestone:</span>
<span className="text-amber-600 dark:text-amber-300 font-bold">{nodes[nodes.length - 1].name}</span>
</div>
)}
</div>
{/* Action Buttons */}
<div className="flex items-center justify-between gap-3">
<button
onClick={() => {
onReset();
onClose();
}}
className="flex-1 flex items-center justify-center gap-1.5 py-2.5 px-4 rounded-xl border border-stone-400 dark:border-stone-700 font-cinzel font-semibold text-xs transition-all hover:bg-stone-500/10 cursor-pointer"
>
<RotateCcw className="w-4 h-4" />
<span>Retrace From Start</span>
</button>
<button
onClick={onClose}
className="flex-1 flex items-center justify-center gap-1.5 py-2.5 px-4 rounded-xl bg-amber-600 hover:bg-amber-500 text-white font-cinzel font-bold text-xs shadow-lg transition-all cursor-pointer"
>
<Sparkles className="w-4 h-4" />
<span>Admire Map</span>
</button>
</div>
</div>
</div>
);
};