File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed
Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 11import type { Metadata } from 'next'
22import { Inter } from 'next/font/google'
33import './globals.css'
4+ import { MobileDetector } from '../components/MobileDetector'
45
56const inter = Inter ( { subsets : [ 'latin' ] } )
67
@@ -16,7 +17,10 @@ export default function RootLayout({
1617} ) {
1718 return (
1819 < html lang = "en" >
19- < body className = { inter . className } > { children } </ body >
20+ < body className = { inter . className } >
21+ < MobileDetector />
22+ { children }
23+ </ body >
2024 </ html >
2125 )
2226}
Original file line number Diff line number Diff line change 1+ 'use client'
2+
3+ import { useEffect , useState } from 'react'
4+
5+ export function MobileDetector ( ) {
6+ const [ isMobile , setIsMobile ] = useState ( false )
7+
8+ useEffect ( ( ) => {
9+ const checkMobile = ( ) => {
10+ const userAgent = navigator . userAgent . toLowerCase ( )
11+ const isMobileDevice = / m o b i l e | a n d r o i d | i p h o n e | i p a d | p h o n e | t a b l e t / i. test ( userAgent )
12+ const isSmallScreen = window . innerWidth < 768
13+ setIsMobile ( isMobileDevice || isSmallScreen )
14+ }
15+
16+ checkMobile ( )
17+ window . addEventListener ( 'resize' , checkMobile )
18+
19+ return ( ) => window . removeEventListener ( 'resize' , checkMobile )
20+ } , [ ] )
21+
22+ if ( ! isMobile ) return null
23+
24+ return (
25+ < div className = "fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-90 text-white" >
26+ < div className = "text-center p-8 max-w-md" >
27+ < div className = "text-6xl mb-4" > 🖥️</ div >
28+ < h1 className = "text-2xl font-bold mb-4" > Desktop Only</ h1 >
29+ < p className = "text-lg mb-6" >
30+ Crypto Racer is designed for desktop computers. Please open this app on a desktop or laptop for the best gaming experience.
31+ </ p >
32+ < div className = "text-sm text-gray-300" >
33+ < p > Mobile devices are not supported due to:</ p >
34+ < ul className = "mt-2 space-y-1" >
35+ < li > • Complex keyboard controls</ li >
36+ < li > • Performance requirements</ li >
37+ < li > • Screen size limitations</ li >
38+ </ ul >
39+ </ div >
40+ </ div >
41+ </ div >
42+ )
43+ }
You can’t perform that action at this time.
0 commit comments