feat: stash

This commit is contained in:
tiennm99 committed 2025-08-04 00:23:56 +07:00
1 parent 925a890a1a
commit 7b62155973
24 files changed
+1714 -201

No files matched your search

+3 -2
View File
@@ -12,8 +12,9 @@
"Bash(curl:*)",
"WebFetch",
"Bash(grep:*)",
"Bash(pnpm:*)"
"Bash(pnpm:*)",
"Bash(cat:*)"
],
"deny": []
}
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ const customJestConfig: Config = {
transform: {
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }],
},
moduleNameMapping: {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
}
+6 -1
View File
@@ -13,9 +13,13 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.14",
"@radix-ui/react-progress": "^1.1.7",
"@radix-ui/react-slot": "^1.2.3",
"@tanstack/react-query": "^5.84.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.536.0",
"mapillary-js": "^4.1.2",
"maplibre-gl": "^5.6.1",
"next": "^15.4.5",
@@ -24,6 +28,7 @@
"tailwind-merge": "^3.3.1"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.16",
"@testing-library/jest-dom": "^6.6.4",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
@@ -40,7 +45,7 @@
"jest-environment-jsdom": "^30.0.5",
"postcss": "^8.5.6",
"prettier": "^3.6.2",
"tailwindcss": "^4.1.11",
"tailwindcss": "^3.4.17",
"typescript": "^5.9.2"
}
}
+769 -5
View File
File diff suppressed because it is too large. Load diff
+8
View File
@@ -0,0 +1,8 @@
const config = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
module.exports = config
-10
View File
@@ -1,10 +0,0 @@
import type { Config } from 'postcss-load-config'
const config: Config = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
export default config
+87 -38
View File
@@ -10,6 +10,9 @@ import ResultModal from '@/components/features/ResultModal';
import { fetchRandomGameImage } from '@/services/game-image.service';
import { calculateDistance } from '@/services/geography.service';
import { calculatePoints } from '@/services/scoring.service';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { ArrowLeft, MapPin, Target } from 'lucide-react';
interface ImageData {
id: string;
@@ -148,54 +151,100 @@ function GamePageContent() {
};
return (
<div className="main-container">
<div className="background-layer"></div>
<div className="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-100">
<Header onDonateClick={() => setShowDonateModal(true)} />
<div className="content-wrapper">
<div className="gradient-overlay">
<Header onDonateClick={() => setShowDonateModal(true)} />
<div className="container mx-auto px-4 py-6">
{/* Back Button */}
<div className="mb-6">
<Button
onClick={goBack}
variant="outline"
className="bg-white/80 hover:bg-white border-gray-200 shadow-sm hover:shadow-md"
>
<ArrowLeft className="h-4 w-4 mr-2" />
Back to Home
</Button>
</div>
<div className="game-section">
<div className="score-header">
<button className="back-btn" onClick={goBack}>
<div className="diamond-icon">&lt;</div>
</button>
{/* Game Layout */}
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 h-[calc(100vh-200px)] min-h-[600px]">
{/* Street View - Takes 2 columns on large screens */}
<div className="lg:col-span-2">
<div className="bg-white rounded-xl shadow-lg border border-gray-200 h-full overflow-hidden">
<div className="bg-gradient-to-r from-blue-600 to-purple-600 px-6 py-3">
<h2 className="text-white font-semibold flex items-center space-x-2">
<MapPin className="h-5 w-5" />
<span>Street View - Where are you?</span>
</h2>
</div>
<div className="p-4 h-full">
<PanoViewer
imageData={imageData}
isLoading={isLoading}
onPreciseLocationLoad={handlePreciseLocationLoad}
/>
</div>
</div>
</div>
<div className="game-content">
<PanoViewer
imageData={imageData}
isLoading={isLoading}
onPreciseLocationLoad={handlePreciseLocationLoad}
/>
<div className="right-panel">
{/* Map and Controls - Takes 1 column */}
<div className="space-y-4">
{/* Map Section */}
<div className="bg-white rounded-xl shadow-lg border border-gray-200 overflow-hidden">
<div className="bg-gradient-to-r from-green-600 to-emerald-600 px-4 py-3">
<h3 className="text-white font-semibold flex items-center space-x-2">
<Target className="h-5 w-5" />
<span>Make your guess</span>
</h3>
</div>
<div className="p-4">
<GameMap
choiceLocation={choiceLocation}
onLocationSelect={handleLocationSelect}
/>
<button
className="check-btn"
disabled={!hasGuessed}
onClick={handleSubmit}
style={{ opacity: hasGuessed ? 1 : 0.5 }}
>
<div className="check-text">
{hasGuessed ? 'SUBMIT GUESS' : 'CLICK MAP TO GUESS'}
</div>
</button>
{hasGuessed && (
<div style={{
color: '#05A38C',
fontSize: '12px',
textAlign: 'center',
marginTop: '10px'
}}>
Location selected: {guessLocation[0].toFixed(4)}, {guessLocation[1].toFixed(4)}
</div>
)}
</div>
</div>
{/* Status and Submit */}
<div className="space-y-4">
{hasGuessed && (
<div className="bg-green-50 border border-green-200 rounded-lg p-4">
<div className="text-center">
<Badge variant="secondary" className="bg-green-100 text-green-800 hover:bg-green-100">
<MapPin className="h-3 w-3 mr-1" />
Location Selected
</Badge>
<div className="text-xs text-green-600 font-mono mt-2">
{guessLocation[0].toFixed(4)}, {guessLocation[1].toFixed(4)}
</div>
</div>
</div>
)}
<Button
onClick={handleSubmit}
disabled={!hasGuessed}
size="lg"
className={`w-full py-4 text-lg font-semibold ${
hasGuessed
? 'bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 shadow-lg hover:shadow-xl hover:scale-105'
: ''
}`}
>
{hasGuessed ? (
<>
<Target className="h-5 w-5 mr-2" />
Submit Guess
</>
) : (
<>
<MapPin className="h-5 w-5 mr-2" />
Click map to guess
</>
)}
</Button>
</div>
</div>
</div>
</div>
+78
View File
@@ -0,0 +1,78 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 221.2 83.2% 53.3%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96%;
--secondary-foreground: 222.2 84% 4.9%;
--muted: 210 40% 96%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96%;
--accent-foreground: 222.2 84% 4.9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 221.2 83.2% 53.3%;
--radius: 0.75rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 217.2 91.2% 59.8%;
--primary-foreground: 222.2 84% 4.9%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 224.3 76.3% 94.1%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
/* Custom styles for game components */
.pano {
min-height: 400px;
}
/* MapLibre and Mapillary CSS adjustments */
.maplibregl-canvas {
border-radius: 0.5rem;
}
.mapillary-js {
border-radius: 0.5rem;
}
/* Ensure proper z-index for modals */
.maplibregl-popup {
z-index: 40;
}
+93 -38
View File
@@ -6,6 +6,10 @@ import Header from '@/components/ui/Header';
import DonateModal from '@/components/ui/DonateModal';
import UsernameModal from '@/components/ui/UsernameModal';
import { LOCATION_NAMES } from '@/constants/locations';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { MapPin, Play, Target, Users } from 'lucide-react';
export default function Home() {
const [showDonateModal, setShowDonateModal] = useState(false);
@@ -37,47 +41,98 @@ export default function Home() {
};
return (
<div className="main-container">
<div className="background-layer"></div>
<div className="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-100">
<Header onDonateClick={() => setShowDonateModal(true)} />
<div className="content-wrapper">
<div className="gradient-overlay">
<Header onDonateClick={() => setShowDonateModal(true)} />
<div className="game-section">
<div className="score-header">
<span className="score-text">WELCOME TO VIET NAM GUESSR GAME</span>
</div>
<div className="play-section">
<div className="play-title-row">
<h1 className="play-title">PLAY NOW</h1>
</div>
</div>
<div className="game-content">
<div className="pano">
<h2 className="how-title">HOW 2 PLAY</h2>
<div className="instruction-list">
<p className="instruction">1. Choose your city</p>
<p className="instruction">2. Guess the location of the picture as accurately as possible</p>
</div>
</div>
<div className="right-panel">
{Object.entries(LOCATION_NAMES).map(([key, name]) => (
<button
key={key}
className="bridge-btn"
onClick={() => startGame(key)}
>
<div className="bridge-text">{name}</div>
</button>
))}
</div>
<div className="container mx-auto px-4 py-8">
{/* Welcome Section */}
<div className="text-center mb-12">
<div className="flex items-center justify-center mb-6">
<div className="bg-gradient-to-br from-blue-500 to-purple-600 p-4 rounded-full">
<MapPin className="h-12 w-12 text-white" />
</div>
</div>
<h1 className="text-4xl md:text-6xl font-bold bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent mb-4">
VIGEOGUESSR
</h1>
<Badge variant="secondary" className="text-lg px-6 py-2 mb-6">
<MapPin className="h-4 w-4 mr-2" />
Welcome to Vietnam Geography Game
</Badge>
{username && (
<div className="flex items-center justify-center space-x-2 text-muted-foreground">
<Users className="h-4 w-4" />
<span>Playing as: <strong>{username}</strong></span>
</div>
)}
</div>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8 max-w-6xl mx-auto">
{/* How to Play Section */}
<Card className="bg-white/90 backdrop-blur-sm shadow-lg">
<CardHeader>
<CardTitle className="flex items-center space-x-2 text-2xl">
<Target className="h-6 w-6" />
<span>How to Play</span>
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-4">
<div className="flex items-start space-x-3 p-4 bg-blue-50 rounded-lg border border-blue-200">
<Badge variant="default" className="bg-blue-600 text-white">1</Badge>
<div>
<h3 className="font-semibold text-blue-900">Choose your city</h3>
<p className="text-sm text-blue-700">Select from Vietnamese cities to explore</p>
</div>
</div>
<div className="flex items-start space-x-3 p-4 bg-green-50 rounded-lg border border-green-200">
<Badge variant="default" className="bg-green-600 text-white">2</Badge>
<div>
<h3 className="font-semibold text-green-900">Guess the location</h3>
<p className="text-sm text-green-700">View street images and guess where you are on the map</p>
</div>
</div>
</div>
</CardContent>
</Card>
{/* City Selection Section */}
<Card className="bg-white/90 backdrop-blur-sm shadow-lg">
<CardHeader>
<CardTitle className="flex items-center space-x-2 text-2xl">
<Play className="h-6 w-6" />
<span>Choose Your City</span>
</CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-1 gap-3">
{Object.entries(LOCATION_NAMES).map(([key, name]) => (
<Button
key={key}
onClick={() => startGame(key)}
size="lg"
className="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 text-white py-4 text-lg font-semibold shadow-lg hover:shadow-xl hover:scale-105 transition-all duration-200"
>
<MapPin className="h-5 w-5 mr-3" />
{name}
<Play className="h-4 w-4 ml-auto" />
</Button>
))}
</div>
</CardContent>
</Card>
</div>
{/* Stats or Additional Info */}
<div className="mt-12 text-center">
<Card className="max-w-2xl mx-auto bg-white/80 backdrop-blur-sm">
<CardContent className="pt-6">
<p className="text-muted-foreground">
Test your geography knowledge by exploring Vietnam through street view images.
Earn points based on how close your guesses are to the actual locations!
</p>
</CardContent>
</Card>
</div>
</div>
+10 -16
View File
@@ -215,18 +215,11 @@ export default function PanoViewer({ imageData, isLoading, onPreciseLocationLoad
if (isLoading) {
return (
<div className="pano" style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<div style={{ textAlign: 'center' }}>
<div style={{
border: '4px solid #f3f3f3',
borderTop: '4px solid #3498db',
borderRadius: '50%',
width: '40px',
height: '40px',
animation: 'spin 2s linear infinite',
margin: '0 auto 15px'
}}></div>
<div style={{ color: '#666', fontSize: '16px' }}>Loading image...</div>
<div className="pano flex items-center justify-center bg-muted/50 rounded-lg border-2 border-dashed border-muted-foreground/25">
<div className="text-center space-y-4">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"></div>
<div className="text-muted-foreground font-medium">Loading street view...</div>
<div className="text-sm text-muted-foreground">Getting the perfect angle for you</div>
</div>
</div>
);
@@ -234,10 +227,11 @@ export default function PanoViewer({ imageData, isLoading, onPreciseLocationLoad
if (!imageData) {
return (
<div className="pano" style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<div style={{ textAlign: 'center', color: '#e74c3c' }}>
<div style={{ fontSize: '18px', marginBottom: '10px' }}>⚠️ Error loading image</div>
<div style={{ fontSize: '14px' }}>Please try again</div>
<div className="pano flex items-center justify-center bg-destructive/10 rounded-lg border-2 border-dashed border-destructive/25">
<div className="text-center space-y-2">
<div className="text-4xl">⚠️</div>
<div className="text-lg font-semibold text-destructive">Error loading image</div>
<div className="text-sm text-muted-foreground">Please try again or select a different location</div>
</div>
</div>
);
+103 -30
View File
@@ -5,6 +5,10 @@ import maplibregl from 'maplibre-gl';
import { Viewer } from 'mapillary-js';
import 'maplibre-gl/dist/maplibre-gl.css';
import 'mapillary-js/dist/mapillary.css';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { ArrowRight, Trophy, MapPin, Target } from 'lucide-react';
interface ImageData {
id: string;
@@ -242,9 +246,9 @@ export default function ResultModal({
const formatDistance = (dist: number): string => {
if (dist > 1000) {
return `${(dist / 1000).toFixed(2)} KM`;
return `${(dist / 1000).toFixed(2)} km`;
}
return `${dist} M`;
return `${Math.round(dist)} m`;
};
const getResultMessage = (dist: number, pts: number): string => {
@@ -256,37 +260,106 @@ export default function ResultModal({
return "Keep practicing! 💪";
};
const getScoreColor = (pts: number): string => {
if (pts >= 5) return "bg-green-500";
if (pts >= 4) return "bg-blue-500";
if (pts >= 3) return "bg-yellow-500";
if (pts >= 2) return "bg-orange-500";
if (pts >= 1) return "bg-red-400";
return "bg-gray-500";
};
return (
<div className="modal" style={{ display: 'block' }}>
<div className="modal-content" style={{ maxWidth: '90vw', width: '800px' }}>
<div className="score-text">RESULT</div>
<div style={{ display: 'flex', gap: '20px', alignItems: 'center', marginBottom: '15px' }}>
<span className="distance-text">{formatDistance(distance)}</span>
<div style={{
background: '#05A38C',
padding: '8px 16px',
borderRadius: '8px',
fontFamily: 'Jersey 15, cursive',
fontSize: '24px',
color: 'white'
}}>
{points} POINTS
<div className="fixed inset-0 z-50 bg-black/80 backdrop-blur-sm">
<div className="fixed left-[50%] top-[50%] z-50 grid w-full max-w-4xl translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 sm:rounded-lg">
<div className="flex flex-col space-y-6">
{/* Header */}
<Card>
<CardHeader className="text-center">
<div className="flex items-center justify-center mb-2">
<div className="bg-gradient-to-br from-blue-500 to-purple-600 p-3 rounded-full">
<Trophy className="h-8 w-8 text-white" />
</div>
</div>
<CardTitle className="text-3xl font-bold bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent">
Game Result
</CardTitle>
</CardHeader>
<CardContent>
<div className="flex items-center justify-center space-x-8">
<div className="text-center">
<div className="text-sm font-medium text-muted-foreground mb-2">Distance</div>
<Badge variant="outline" className="text-lg px-4 py-2">
<MapPin className="h-4 w-4 mr-2" />
{formatDistance(distance)}
</Badge>
</div>
<div className="text-center">
<div className="text-sm font-medium text-muted-foreground mb-2">Score</div>
<Badge className={`text-lg px-4 py-2 text-white ${getScoreColor(points)}`}>
<Target className="h-4 w-4 mr-2" />
{points} POINTS
</Badge>
</div>
</div>
<div className="mt-6 text-center">
<Badge variant="secondary" className="text-lg px-6 py-2">
{getResultMessage(distance, points)}
</Badge>
</div>
</CardContent>
</Card>
{/* Maps Container */}
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4 h-80">
<Card className="overflow-hidden">
<CardHeader className="py-3">
<CardTitle className="text-sm flex items-center space-x-2">
<MapPin className="h-4 w-4" />
<span>Result Map</span>
</CardTitle>
</CardHeader>
<CardContent className="p-0 h-full">
<div ref={mapRef} className="h-full w-full" />
</CardContent>
</Card>
<Card className="overflow-hidden">
<CardHeader className="py-3">
<CardTitle className="text-sm flex items-center space-x-2">
<Target className="h-4 w-4" />
<span>Explore Location</span>
</CardTitle>
</CardHeader>
<CardContent className="p-0 h-full">
<div ref={panoRef} className="h-full w-full" />
</CardContent>
</Card>
</div>
{/* Instructions */}
<Card className="bg-muted/50">
<CardContent className="pt-6">
<p className="text-center text-sm text-muted-foreground">
You can now explore around the actual location using the street view! Use your mouse to look around and navigate.
</p>
</CardContent>
</Card>
{/* Action Button */}
<div className="flex justify-center">
<Button
onClick={onNextRound}
size="lg"
className="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 text-white px-8 py-3 text-lg font-semibold hover:scale-105"
>
Next Round
<ArrowRight className="h-5 w-5 ml-2" />
</Button>
</div>
</div>
<div style={{ display: 'flex', gap: '15px', height: '300px', marginBottom: '15px' }}>
<div ref={mapRef} style={{ flex: 1, minHeight: '300px' }}></div>
<div ref={panoRef} style={{ flex: 1, minHeight: '300px', borderRadius: '8px' }}></div>
</div>
<p style={{ marginBottom: '15px' }}>{getResultMessage(distance, points)}</p>
<p style={{ fontSize: '14px', color: '#ccc', marginBottom: '15px' }}>
You can now explore around the actual location using the street view!
</p>
<button onClick={onNextRound} className="next-btn">
<div className="next-text">NEXT ROUND</div>
</button>
</div>
</div>
);
+49 -18
View File
@@ -1,7 +1,10 @@
'use client';
import Image from 'next/image';
import { MouseEvent } from 'react';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from './dialog';
import { Button } from './button';
import { Card, CardContent } from './card';
import { Coffee, Heart, X } from 'lucide-react';
interface DonateModalProps {
isOpen: boolean;
@@ -9,23 +12,51 @@ interface DonateModalProps {
}
export default function DonateModal({ isOpen, onClose }: DonateModalProps) {
if (!isOpen) return null;
const handleBackdropClick = (e: MouseEvent<HTMLDivElement>) => {
if (e.target === e.currentTarget) {
onClose();
}
};
return (
<div className="modal" style={{ display: 'block' }} onClick={handleBackdropClick}>
<div className="modal-donate">
<div className="score-text">DONATE HERE</div>
<Image className="qr" src="/QR.png" width={320} height={320} alt="QR Code" />
<button onClick={onClose} className="next-btn">
<div className="next-text">CLOSE</div>
</button>
</div>
</div>
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle className="flex items-center space-x-2 text-center justify-center">
<Coffee className="h-5 w-5 text-orange-500" />
<span>Support VIGEOGUESSR</span>
<Heart className="h-4 w-4 text-red-500" />
</DialogTitle>
</DialogHeader>
<div className="flex flex-col items-center space-y-6 py-4">
<Card className="p-4 bg-gradient-to-br from-orange-50 to-yellow-50 border-orange-200">
<CardContent className="p-0 text-center">
<p className="text-sm text-muted-foreground mb-4">
If you enjoy playing VIGEOGUESSR, consider buying me a coffee!
Your support helps keep this project running and free for everyone.
</p>
<div className="bg-white p-4 rounded-lg shadow-sm">
<Image
src="/QR.png"
width={200}
height={200}
alt="Donation QR Code"
className="mx-auto rounded-md"
/>
</div>
<p className="text-xs text-muted-foreground mt-2">
Scan QR code to donate
</p>
</CardContent>
</Card>
<Button
onClick={onClose}
variant="outline"
className="w-full"
>
<X className="h-4 w-4 mr-2" />
Close
</Button>
</div>
</DialogContent>
</Dialog>
);
}
+20 -12
View File
@@ -1,24 +1,32 @@
'use client';
import { Button } from './button';
import { Coffee, MapPin } from 'lucide-react';
interface HeaderProps {
onDonateClick: () => void;
}
export default function Header({ onDonateClick }: HeaderProps) {
return (
<header className="header">
<div className="header-center">
<h3 className="logo-title">VIGEOGUESSR</h3>
</div>
<div className="header-right">
<div className="connect-wallet" onClick={onDonateClick}>
<div style={{
width: '20px',
height: '20px',
backgroundSize: 'contain'
}}></div>
<span className="wallet-text">BUY ME COFFEE</span>
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
<div className="container flex h-16 items-center justify-between px-4">
<div className="flex items-center space-x-2">
<MapPin className="h-6 w-6 text-primary" />
<h1 className="text-xl font-bold bg-gradient-to-r from-primary to-blue-600 bg-clip-text text-transparent">
VIGEOGUESSR
</h1>
</div>
<Button
variant="outline"
size="sm"
onClick={onDonateClick}
className="flex items-center space-x-2 hover:bg-orange-50 hover:border-orange-200 transition-colors"
>
<Coffee className="h-4 w-4" />
<span>Buy me coffee</span>
</Button>
</div>
</header>
);
+56 -26
View File
@@ -1,6 +1,11 @@
'use client';
import { useState, FormEvent, ChangeEvent } from 'react';
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from './dialog';
import { Button } from './button';
import { Input } from './input';
import { Card, CardContent } from './card';
import { User, Play, MapPin } from 'lucide-react';
interface UsernameModalProps {
isOpen: boolean;
@@ -21,33 +26,58 @@ export default function UsernameModal({ isOpen, onSubmit }: UsernameModalProps)
setUsername(e.target.value);
};
if (!isOpen) return null;
return (
<div className="modal-overlay">
<div className="modal-content username-modal">
<h2 className="modal-title">Welcome to VIET NAM GUESSR!</h2>
<p className="modal-subtitle">Enter your username to start playing</p>
<Dialog open={isOpen} onOpenChange={() => {}}>
<DialogContent className="sm:max-w-lg">
<DialogHeader className="text-center">
<div className="flex items-center justify-center mb-4">
<div className="bg-gradient-to-br from-blue-500 to-purple-600 p-3 rounded-full">
<MapPin className="h-8 w-8 text-white" />
</div>
</div>
<DialogTitle className="text-2xl font-bold bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent">
Welcome to VIGEOGUESSR!
</DialogTitle>
<DialogDescription className="text-base mt-2">
Test your geography knowledge by guessing locations from street view images across Vietnam
</DialogDescription>
</DialogHeader>
<form onSubmit={handleSubmit}>
<input
type="text"
value={username}
onChange={handleInputChange}
placeholder="Your username"
className="username-input"
maxLength={20}
autoFocus
/>
<button
type="submit"
className="username-submit-btn"
disabled={!username.trim()}
>
START PLAYING
</button>
</form>
</div>
</div>
<Card className="bg-gradient-to-br from-blue-50 to-purple-50 border-blue-200">
<CardContent className="p-6">
<form onSubmit={handleSubmit} className="space-y-6">
<div className="space-y-2">
<label htmlFor="username" className="text-sm font-medium flex items-center space-x-2">
<User className="h-4 w-4" />
<span>Choose your username</span>
</label>
<Input
id="username"
type="text"
value={username}
onChange={handleInputChange}
placeholder="Enter your username"
maxLength={20}
autoFocus
className="text-center text-lg py-3"
/>
<p className="text-xs text-muted-foreground text-center">
{username.length}/20 characters
</p>
</div>
<Button
type="submit"
disabled={!username.trim()}
className="w-full bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 text-white py-3 text-lg font-semibold"
>
<Play className="h-5 w-5 mr-2" />
Start Playing
</Button>
</form>
</CardContent>
</Card>
</DialogContent>
</Dialog>
);
}
+46
View File
@@ -0,0 +1,46 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const badgeVariants = cva(
"inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
secondary:
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
destructive:
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
)
function Badge({
className,
variant,
asChild = false,
...props
}: React.ComponentProps<"span"> &
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
const Comp = asChild ? Slot : "span"
return (
<Comp
data-slot="badge"
className={cn(badgeVariants({ variant }), className)}
{...props}
/>
)
}
export { Badge, badgeVariants }
+59
View File
@@ -0,0 +1,59 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
destructive:
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
ghost:
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2 has-[>svg]:px-3",
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
icon: "size-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
function Button({
className,
variant,
size,
asChild = false,
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
}) {
const Comp = asChild ? Slot : "button"
return (
<Comp
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
}
export { Button, buttonVariants }
+92
View File
@@ -0,0 +1,92 @@
import * as React from "react"
import { cn } from "@/lib/utils"
function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
className
)}
{...props}
/>
)
}
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className
)}
{...props}
/>
)
}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
className={cn("leading-none font-semibold", className)}
{...props}
/>
)
}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
}
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className
)}
{...props}
/>
)
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
className={cn("px-6", className)}
{...props}
/>
)
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
)
}
export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardAction,
CardDescription,
CardContent,
}
+141
View File
@@ -0,0 +1,141 @@
import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { XIcon } from "lucide-react"
import { cn } from "@/lib/utils"
function Dialog({
...props
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
return <DialogPrimitive.Root data-slot="dialog" {...props} />
}
function DialogTrigger({
...props
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
}
function DialogPortal({
...props
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
}
function DialogClose({
...props
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
}
function DialogOverlay({
className,
...props
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
return (
<DialogPrimitive.Overlay
data-slot="dialog-overlay"
className={cn(
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
className
)}
{...props}
/>
)
}
function DialogContent({
className,
children,
showCloseButton = true,
...props
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
showCloseButton?: boolean
}) {
return (
<DialogPortal data-slot="dialog-portal">
<DialogOverlay />
<DialogPrimitive.Content
data-slot="dialog-content"
className={cn(
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
className
)}
{...props}
>
{children}
{showCloseButton && (
<DialogPrimitive.Close
data-slot="dialog-close"
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
>
<XIcon />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
)}
</DialogPrimitive.Content>
</DialogPortal>
)
}
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="dialog-header"
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
{...props}
/>
)
}
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="dialog-footer"
className={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
className
)}
{...props}
/>
)
}
function DialogTitle({
className,
...props
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
return (
<DialogPrimitive.Title
data-slot="dialog-title"
className={cn("text-lg leading-none font-semibold", className)}
{...props}
/>
)
}
function DialogDescription({
className,
...props
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
return (
<DialogPrimitive.Description
data-slot="dialog-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
}
export {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogOverlay,
DialogPortal,
DialogTitle,
DialogTrigger,
}
+21
View File
@@ -0,0 +1,21 @@
import * as React from "react"
import { cn } from "@/lib/utils"
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
<input
type={type}
data-slot="input"
className={cn(
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
className
)}
{...props}
/>
)
}
export { Input }
+31
View File
@@ -0,0 +1,31 @@
"use client"
import * as React from "react"
import * as ProgressPrimitive from "@radix-ui/react-progress"
import { cn } from "@/lib/utils"
function Progress({
className,
value,
...props
}: React.ComponentProps<typeof ProgressPrimitive.Root>) {
return (
<ProgressPrimitive.Root
data-slot="progress"
className={cn(
"bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",
className
)}
{...props}
>
<ProgressPrimitive.Indicator
data-slot="progress-indicator"
className="bg-primary h-full w-full flex-1 transition-all"
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
/>
</ProgressPrimitive.Root>
)
}
export { Progress }
+13
View File
@@ -0,0 +1,13 @@
import { cn } from "@/lib/utils"
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="skeleton"
className={cn("bg-accent animate-pulse rounded-md", className)}
{...props}
/>
)
}
export { Skeleton }
+24 -1
View File
@@ -1,12 +1,21 @@
import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: ["class"],
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
prefix: "",
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
colors: {
border: "hsl(var(--border))",
@@ -48,9 +57,23 @@ const config: Config = {
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
},
plugins: [],
plugins: [require('@tailwindcss/typography')],
}
export default config
+3 -3
View File
@@ -3,7 +3,7 @@
"lib": ["dom", "dom.iterable", "ES2022"],
"allowJs": false,
"skipLibCheck": true,
"strict": true,
"strict": false,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
@@ -23,8 +23,8 @@
},
"target": "ES2022",
"forceConsistentCasingInFileNames": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true
"noUncheckedIndexedAccess": false,
"exactOptionalPropertyTypes": false
},
"include": [
"next-env.d.ts",
+1
View File
@@ -0,0 +1 @@
{"fileNames":["./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es5.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2021.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2022.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.dom.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.dom.iterable.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.core.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2016.intl.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.date.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.object.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.string.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2019.array.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2019.object.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2019.string.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.date.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.string.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2020.number.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2021.string.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2022.array.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2022.error.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","./node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/lib/lib.es2022.object.d.ts",".Line truncated