Skip to content

Commit f8fada8

Browse files
committed
fix: build
1 parent a4f52b3 commit f8fada8

File tree

12 files changed

+139
-15
lines changed

12 files changed

+139
-15
lines changed

package-lock.json

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"globals": "^16.5.0",
2828
"postcss": "^8.5.6",
2929
"tailwindcss": "^4.1.17",
30+
"terser": "^5.44.1",
3031
"typescript": "~5.9.3",
3132
"typescript-eslint": "^8.46.4",
3233
"vite": "^7.2.4"

src/App.tsx

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,55 @@ import { GameStateProvider, useGameState } from '@context/GameStateContext';
44
import { GenreEditorProvider } from '@context/GenreEditorContext';
55
import { ThemeToggle } from '@components/ui/ThemeToggle';
66
import { Button } from '@components/ui/Button';
7+
import { Modal } from '@components/ui/Modal';
78
import { GenreSelector } from '@components/game/GenreSelector';
89
import { QuestionFlow } from '@components/game/QuestionFlow';
910
import { BingoBoard } from '@components/game/BingoBoard';
1011
import { GenreEditor } from '@components/editor/GenreEditor';
11-
import { handleSharedGenreOnLoad } from '@utils/shareGenre';
12+
import { getSharedGenreFromUrl, handleSharedGenreImport, clearShareUrl } from '@utils/shareGenre';
13+
import type { Genre } from '@data/types';
1214

1315
type AppMode = 'game' | 'editor';
1416

1517
function AppContent() {
1618
const { selectedGenre, board } = useGameState();
1719
const [mode, setMode] = useState<AppMode>('game');
20+
const [sharedGenre, setSharedGenre] = useState<Genre | null>(null);
21+
const [importModal, setImportModal] = useState(false);
22+
const [successModal, setSuccessModal] = useState<string>('');
23+
const [errorModal, setErrorModal] = useState<string>('');
1824

1925
// Handle shared genre links on mount
2026
useEffect(() => {
21-
handleSharedGenreOnLoad();
27+
const genre = getSharedGenreFromUrl();
28+
if (genre) {
29+
setSharedGenre(genre);
30+
setImportModal(true);
31+
}
2232
}, []);
2333

34+
const handleImportConfirm = () => {
35+
if (sharedGenre) {
36+
handleSharedGenreImport(
37+
sharedGenre,
38+
(message) => {
39+
setImportModal(false);
40+
setSuccessModal(message);
41+
},
42+
(message) => {
43+
setImportModal(false);
44+
setErrorModal(message);
45+
}
46+
);
47+
}
48+
};
49+
50+
const handleImportCancel = () => {
51+
setImportModal(false);
52+
setSharedGenre(null);
53+
clearShareUrl();
54+
};
55+
2456
if (mode === 'editor') {
2557
return (
2658
<div className="min-h-screen bg-[var(--color-bg)] text-[var(--color-text)] transition-colors duration-200">
@@ -64,6 +96,33 @@ function AppContent() {
6496
{/* Board generated - show bingo board */}
6597
{selectedGenre && board && <BingoBoard />}
6698
</main>
99+
100+
{/* Shared Genre Import Modals */}
101+
<Modal
102+
isOpen={importModal}
103+
onClose={handleImportCancel}
104+
onConfirm={handleImportConfirm}
105+
title="Import Shared Genre"
106+
message={`Import shared genre "${sharedGenre?.name}"?\n\nThis will save it to your browser and make it available in the genre selector.`}
107+
type="confirm"
108+
confirmText="Import"
109+
/>
110+
111+
<Modal
112+
isOpen={!!successModal}
113+
onClose={() => setSuccessModal('')}
114+
title="Success"
115+
message={successModal}
116+
type="alert"
117+
/>
118+
119+
<Modal
120+
isOpen={!!errorModal}
121+
onClose={() => setErrorModal('')}
122+
title="Error"
123+
message={errorModal}
124+
type="alert"
125+
/>
67126
</div>
68127
);
69128
}

src/components/editor/BasicInfoEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import { useState } from 'react';
22
import { useGenreEditor } from '@context/GenreEditorContext';
33
import { Button } from '@components/ui/Button';
44
import { COLOR_PALETTES, generateRandomPalette, type ColorPalette } from '@utils/colorPalettes';

src/components/editor/GenreEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useRef, useCallback } from 'react';
1+
import { useState, useRef, useCallback } from 'react';
22
import { useGenreEditor } from '@context/GenreEditorContext';
33
import { getAllGenres } from '@data/genres';
44
import type { Genre } from '@data/types';
@@ -7,7 +7,7 @@ import { Modal } from '@components/ui/Modal';
77
import { BasicInfoEditor } from './BasicInfoEditor';
88
import { QuestionsEditor } from './QuestionsEditor';
99
import { TropeSetsEditor } from './TropeSetsEditor';
10-
import { saveCustomGenre, isCustomGenre } from '@utils/customGenres';
10+
import { saveCustomGenre } from '@utils/customGenres';
1111
import { createShareUrl } from '@utils/shareGenre';
1212

1313
function EditorTabs() {

src/components/editor/QuestionsEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import { useState } from 'react';
22
import { useGenreEditor } from '@context/GenreEditorContext';
33
import type { Question, QuestionOption } from '@data/types';
44
import { Button } from '@components/ui/Button';

src/components/editor/TropeSetsEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import { useState } from 'react';
22
import { useGenreEditor } from '@context/GenreEditorContext';
33
import type { TropeSet, Trope } from '@data/types';
44
import { Button } from '@components/ui/Button';
@@ -21,7 +21,7 @@ export function TropeSetsEditor() {
2121
const generateSetId = (filters: Record<string, string | string[]>): string => {
2222
const parts: string[] = [];
2323

24-
for (const [key, value] of Object.entries(filters)) {
24+
for (const [, value] of Object.entries(filters)) {
2525
if (value === undefined) continue;
2626

2727
if (Array.isArray(value)) {

src/components/game/GenreSelector.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getAllGenres } from '@data/genres';
22
import { useGameState } from '@context/GameStateContext';
3-
import { Button } from '@components/ui/Button';
43

54
export function GenreSelector() {
65
const genres = getAllGenres();

src/components/ui/Modal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Button } from './Button';
32

43
interface ModalProps {
@@ -62,4 +61,4 @@ export function Modal({
6261
</div>
6362
</div>
6463
);
65-
}
64+
}

src/context/GameStateContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { createContext, useContext, useEffect, useState, type PropsWithChildren } from 'react';
2-
import type { GameState, Trope, Genre } from '@data/types';
1+
import { createContext, useContext, useEffect, useState, type PropsWithChildren } from 'react';
2+
import type { GameState, Genre } from '@data/types';
33
import { getGenreById } from '@data/genres';
44
import { selectTropes, generateBoard } from '@utils/tropes';
55
import { generateSeed } from '@utils/shuffle';

0 commit comments

Comments
 (0)