2 Commits

7 changed files with 195 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ import Community from './components/Community';
import PWAInstallPrompt from './components/PWAInstallPrompt'; import PWAInstallPrompt from './components/PWAInstallPrompt';
import { AuthProvider, useAuth } from './contexts/AuthContext'; import { AuthProvider, useAuth } from './contexts/AuthContext';
import { ToastProvider } from './contexts/ToastContext'; import { ToastProvider } from './contexts/ToastContext';
import CardMosaicBackground from "./components/CardMosaicBackground.tsx";
type Page = 'home' | 'deck' | 'login' | 'collection' | 'edit-deck' | 'search' | 'life-counter' | 'community'; type Page = 'home' | 'deck' | 'login' | 'collection' | 'edit-deck' | 'search' | 'life-counter' | 'community';
@@ -40,7 +41,7 @@ function AppContent() {
switch (currentPage) { switch (currentPage) {
case 'home': case 'home':
return ( return (
<div className="relative bg-gray-900 text-white p-3 sm:p-6 animate-fade-in md:min-h-screen"> <div className="relative text-white p-3 sm:p-6 animate-fade-in md:min-h-screen">
<div className="max-w-7xl mx-auto"> <div className="max-w-7xl mx-auto">
<h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6 animate-slide-in-left">My Decks</h1> <h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6 animate-slide-in-left">My Decks</h1>
<DeckList <DeckList
@@ -78,9 +79,12 @@ function AppContent() {
}; };
return ( return (
<div className="min-h-screen bg-gray-900 flex flex-col"> <div className="min-h-screen bg-gray-900 flex flex-col relative">
{/* Animated card mosaic overlay */}
<CardMosaicBackground />
<Navigation currentPage={currentPage} setCurrentPage={setCurrentPage} /> <Navigation currentPage={currentPage} setCurrentPage={setCurrentPage} />
<main className="relative flex-1 overflow-y-auto"> <main className="relative flex-1 overflow-y-auto z-20">
<div className="relative min-h-full md:min-h-0 pt-0 md:pt-16 pb-20 md:pb-0"> <div className="relative min-h-full md:min-h-0 pt-0 md:pt-16 pb-20 md:pb-0">
{renderPage()} {renderPage()}
</div> </div>

View File

@@ -0,0 +1,155 @@
import React, { useEffect, useState, useRef } from 'react';
import { getRandomCards } from '../services/api';
import { Card } from '../types';
export default function CardMosaicBackground() {
const [cards, setCards] = useState<Card[]>([]);
const [offset, setOffset] = useState({ x: 0, y: 0 });
const animationRef = useRef<number>();
// Grid configuration - large grid to cover entire screen
const cardsPerRow = 18;
const cardsPerCol = 15;
// Spacing adjusted for card transforms: w-64 = 256px
// With rotateZ(15deg) and rotateX(60deg), cards need more space
const cardWidth = 130; // Horizontal spacing to avoid overlap
const cardHeight = 85; // Vertical spacing to avoid overlap
const gridWidth = cardsPerRow * cardWidth;
const gridHeight = cardsPerCol * cardHeight;
useEffect(() => {
const fetchCards = async () => {
try {
// Fetch enough cards for one grid
const totalCards = cardsPerRow * cardsPerCol;
const randomCards = await getRandomCards(totalCards);
setCards(randomCards);
} catch (error) {
console.error('Error fetching background cards:', error);
}
};
fetchCards();
}, []);
// Diagonal infinite scroll animation
useEffect(() => {
if (cards.length === 0) return;
const speed = 0.5; // Pixels per frame (diagonal speed)
let lastTime = Date.now();
const animate = () => {
const now = Date.now();
const delta = now - lastTime;
lastTime = now;
setOffset((prev) => {
// Move diagonally: right and up
let newX = prev.x + (speed * delta) / 16;
let newY = prev.y - (speed * delta) / 16;
// Loop seamlessly when we've moved one full grid
if (newX >= gridWidth) newX = newX % gridWidth;
if (newY <= -gridHeight) newY = newY % gridHeight;
return { x: newX, y: newY };
});
animationRef.current = requestAnimationFrame(animate);
};
animationRef.current = requestAnimationFrame(animate);
return () => {
if (animationRef.current) {
cancelAnimationFrame(animationRef.current);
}
};
}, [cards.length, gridWidth, gridHeight]);
if (cards.length === 0) return null;
// Render the card grid (will be duplicated 4 times for infinite effect)
const renderGrid = (offsetX: number, offsetY: number, key: string) => (
<div
key={key}
className="absolute"
style={{
left: `${offsetX}px`,
top: `${offsetY}px`,
width: `${gridWidth}px`,
height: `${gridHeight}px`,
perspective: '2000px', // Apply perspective to parent for uniform card sizes
transformStyle: 'preserve-3d',
}}
>
{cards.map((card, index) => {
const col = index % cardsPerRow;
const row = Math.floor(index / cardsPerRow);
return (
<div
key={`${key}-${card.id}-${index}`}
className="absolute"
style={{
left: `${col * cardWidth}px`,
top: `${row * cardHeight}px`,
transform: `
perspective(1000px)
rotateX(60deg)
rotateY(5deg)
rotateZ(15deg)
`,
opacity: 1.0, // Full opacity - gradient overlay handles the fade
}}
>
<img
src={card.image_uris?.normal || card.image_uris?.large}
alt=""
className="w-64 h-auto rounded-lg shadow-2xl"
draggable={false}
/>
</div>
);
})}
</div>
);
return (
<div className="fixed inset-0 overflow-hidden pointer-events-none z-10">
{/* Scrolling grid container */}
<div
className="absolute"
style={{
transform: `translate(${offset.x}px, ${offset.y}px)`,
willChange: 'transform',
}}
>
{/* Duplicate grids in 2x2 pattern for seamless infinite scroll */}
{/* Position grids to cover entire viewport and beyond */}
{renderGrid(-gridWidth, window.innerHeight - gridHeight / 2, 'grid-tl')}
{renderGrid(0, window.innerHeight - gridHeight / 2, 'grid-tr')}
{renderGrid(-gridWidth, window.innerHeight - gridHeight / 2 + gridHeight, 'grid-bl')}
{renderGrid(0, window.innerHeight - gridHeight / 2 + gridHeight, 'grid-br')}
</div>
{/* Fixed gradient overlay - cards pass UNDER and fade naturally */}
<div
className="absolute inset-0 pointer-events-none z-10"
style={{
background: `
linear-gradient(to top,
transparent 0%,
transparent 25%,
rgba(3, 7, 18, 0.3) 40%,
rgba(3, 7, 18, 0.6) 55%,
rgba(3, 7, 18, 0.85) 70%,
rgb(3, 7, 18) 85%
)
`
}}
/>
</div>
);
}

View File

@@ -201,7 +201,7 @@ const CardSearch = () => {
}; };
return ( return (
<div className="relative bg-gray-900 text-white p-3 sm:p-6 md:min-h-screen"> <div className="relative text-white p-3 sm:p-6 md:min-h-screen">
<div className="max-w-7xl mx-auto"> <div className="max-w-7xl mx-auto">
<h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6">Card Search</h1> <h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6">Card Search</h1>
<form onSubmit={handleSearch} className="mb-8 space-y-4"> <form onSubmit={handleSearch} className="mb-8 space-y-4">

View File

@@ -321,7 +321,7 @@ export default function Collection() {
}; };
return ( return (
<div className="relative bg-gray-900 text-white p-3 sm:p-6 md:min-h-screen"> <div className="relative text-white p-3 sm:p-6 md:min-h-screen">
<div className="max-w-7xl mx-auto"> <div className="max-w-7xl mx-auto">
<h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6">My Collection</h1> <h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6">My Collection</h1>

View File

@@ -696,7 +696,7 @@ export default function Community() {
); );
return ( return (
<div className="relative bg-gray-900 text-white min-h-screen"> <div className="relative text-white min-h-screen">
<div className="max-w-7xl mx-auto p-3 sm:p-6"> <div className="max-w-7xl mx-auto p-3 sm:p-6">
{/* Header with Back and Trade buttons */} {/* Header with Back and Trade buttons */}
<div className="flex items-center justify-between gap-2 mb-4 md:mb-6"> <div className="flex items-center justify-between gap-2 mb-4 md:mb-6">
@@ -1027,7 +1027,7 @@ export default function Community() {
// ============ MAIN VIEW ============ // ============ MAIN VIEW ============
return ( return (
<div className="relative bg-gray-900 text-white p-3 sm:p-6 md:min-h-screen"> <div className="relative text-white p-3 sm:p-6 md:min-h-screen">
<div className="max-w-7xl mx-auto"> <div className="max-w-7xl mx-auto">
{/* Header */} {/* Header */}
<h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6">Community</h1> <h1 className="text-2xl md:text-3xl font-bold mb-4 md:mb-6">Community</h1>

View File

@@ -77,7 +77,7 @@ const DeckList = ({ onDeckEdit, onCreateDeck }: DeckListProps) => {
{/* Create New Deck Card */} {/* Create New Deck Card */}
<button <button
onClick={onCreateDeck} onClick={onCreateDeck}
className="bg-gray-800 rounded-lg overflow-hidden shadow-lg hover:shadow-xl border-2 border-dashed border-gray-600 hover:border-blue-500 transition-all duration-300 hover:scale-105 cursor-pointer group aspect-[5/7] flex flex-col items-center justify-center gap-3 p-4" className="rounded-lg overflow-hidden shadow-lg hover:shadow-xl border-2 border-dashed border-gray-600 hover:border-blue-500 transition-all duration-300 hover:scale-105 cursor-pointer group aspect-[5/7] flex flex-col items-center justify-center gap-3 p-4"
> >
<PlusCircle size={48} className="text-gray-600 group-hover:text-blue-500 transition-colors" /> <PlusCircle size={48} className="text-gray-600 group-hover:text-blue-500 transition-colors" />
<div className="text-center"> <div className="text-center">

View File

@@ -167,6 +167,34 @@
animation: float 3s ease-in-out infinite; animation: float 3s ease-in-out infinite;
} }
/* Diagonal Carousel - Cards flow from bottom-left to top-right diagonally and loop */
@keyframes flowDiagonal {
0% {
translate: 0 0;
opacity: 1;
}
60% {
translate: 600px -600px;
opacity: 1;
}
75% {
translate: 900px -900px;
opacity: 0.6;
}
85% {
translate: 1100px -1100px;
opacity: 0.3;
}
100% {
translate: 1400px -1400px;
opacity: 0;
}
}
.animate-flow-right {
animation: flowDiagonal 40s linear infinite;
}
/* Gradient Animation */ /* Gradient Animation */
@keyframes gradientShift { @keyframes gradientShift {
0% { 0% {