-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathApp.tsx
More file actions
51 lines (47 loc) · 1.47 KB
/
App.tsx
File metadata and controls
51 lines (47 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Page } from '@hotandcold/classic-shared';
import { PlayPage } from './pages/PlayPage';
import { StatsPage } from './pages/StatsPage';
import { WinPage } from './pages/WinPage';
import { usePage } from './hooks/usePage';
import { Progress } from './components/progress';
import { useGame } from './hooks/useGame';
import { cn } from '@hotandcold/webview-common/utils';
import { Header } from './components/header';
import { LoadingPage } from './pages/LoadingPage';
const getPage = (page: Page) => {
switch (page) {
case 'play':
return <PlayPage />;
case 'stats':
return <StatsPage />;
case 'win':
return <WinPage />;
case 'loading':
return <LoadingPage />;
default:
throw new Error(`Invalid page: ${String(page satisfies never)}`);
}
};
export const App = () => {
const page = usePage();
const { mode, hardcoreModeAccess } = useGame();
if (mode === 'hardcore' && hardcoreModeAccess?.status === 'inactive') {
return <div>UNLOCK HARDCORE</div>;
}
return (
<div
className={cn(
'relative flex h-full min-h-0 flex-1 flex-col p-6',
mode === 'hardcore' &&
'bg-[url(/assets/hardcore_background.png)] bg-cover bg-center bg-no-repeat bg-blend-multiply'
)}
>
<div className="mb-4 sm:mb-6">
<Header />
</div>
{getPage(page)}
<Progress />
{/* <FriendsModal isOpen={friendsModalOpen} onClose={() => setFriendsModalOpen(false)} /> */}
</div>
);
};