1+ "use client" ;
2+ import React , { useState , useEffect } from "react" ;
3+ import QRCode from "react-qr-code" ;
4+ import WalletConnectButton from "@/app/components/WalletConnectButton" ;
5+
6+ const GameCreationPage = ( ) => {
7+ const [ gameCode , setGameCode ] = useState < string > ( "014454" ) ;
8+ const [ qrValue , setQrValue ] = useState < string > ( "" ) ;
9+
10+ useEffect ( ( ) => {
11+ const baseUrl = "https://yourgame.com/join" ;
12+ setQrValue ( `${ baseUrl } ?code=${ gameCode } ` ) ;
13+ } , [ gameCode ] ) ;
14+
15+ const handleCreateGame = ( ) => {
16+ const newCode = Math . floor ( 100000 + Math . random ( ) * 900000 )
17+ . toString ( )
18+ . substring ( 0 , 6 ) ;
19+ setGameCode ( newCode ) ;
20+ console . log ( "Creating new game with code:" , newCode ) ;
21+ } ;
22+
23+ // Shared dimensions for both the CREATE GAME card and QR code container
24+ const containerClasses =
25+ "w-full sm:w-[250px] md:w-[292px] h-[180px] sm:h-[220px] md:h-[260px] mx-auto" ;
26+
27+ return (
28+ < div className = "relative h-screen w-full overflow-hidden bg-gradient-to-b from-blue-900 to-purple-900 bg-[url('/Background.png')] bg-cover bg-center" >
29+ { /* Connect Wallet Button */ }
30+ < div className = "absolute top-5 right-5 z-10" >
31+ < WalletConnectButton />
32+ </ div >
33+
34+ < div className = "relative flex items-center justify-center h-full" >
35+ { /* Grid Container */ }
36+ < div className = "grid grid-cols-1 sm:grid-cols-2 gap-3 lg:gap-4 max-w-2xl w-full px-4 sm:px-6 lg:px-8" >
37+ { /* CREATE GAME Card */ }
38+ < div
39+ className = { `${ containerClasses } bg-gradient-to-r from-[#EB655F] to-[#151515] flex items-end justify-center relative opacity-90` }
40+ style = { {
41+ transform : "perspective(500px) rotateY(5deg)" ,
42+ boxShadow : "0 4px 12px rgba(0,0,0,0.3)" ,
43+ } }
44+ >
45+ < button
46+ onClick = { handleCreateGame }
47+ className = "text-white font-bold py-3 sm:py-4 mr-0 sm:mr-6 md:mr-10 transform transition-transform duration-300 hover:scale-105 relative z-10"
48+ >
49+ < span
50+ className = "text-lg sm:text-xl md:text-2xl tracking-widest uppercase font-sans"
51+ style = { { textShadow : "0 1px 2px rgba(0,0,0,0.4)" } }
52+ >
53+ CREATE GAME
54+ </ span >
55+ </ button >
56+ </ div >
57+
58+ { /* QR Code and Game Code Container */ }
59+ < div className = { `${ containerClasses } relative flex flex-col items-center justify-center` } >
60+ < div className = "p-2 bg-white rounded-md" >
61+ < QRCode
62+ value = { qrValue }
63+ size = { 100 }
64+ className = "w-[100px] h-[100px] sm:w-[120px] sm:h-[120px] md:w-[150px] md:h-[150px]"
65+ />
66+ </ div >
67+ < div className = "mt-4 text-white text-xl sm:text-2xl md:text-3xl lg:text-4xl font-bold tracking-widest text-center" >
68+ { gameCode }
69+ </ div >
70+ </ div >
71+ </ div >
72+ </ div >
73+ </ div >
74+ ) ;
75+ } ;
76+
77+ export default GameCreationPage ;
0 commit comments