@react-text-game/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +297 -0
- package/dist/components/DevModeDrawer/CopyButton.d.ts +4 -0
- package/dist/components/DevModeDrawer/CopyButton.d.ts.map +1 -0
- package/dist/components/DevModeDrawer/CopyButton.js +17 -0
- package/dist/components/DevModeDrawer/CopyButton.js.map +1 -0
- package/dist/components/DevModeDrawer/CurrentPassageData.d.ts +4 -0
- package/dist/components/DevModeDrawer/CurrentPassageData.d.ts.map +1 -0
- package/dist/components/DevModeDrawer/CurrentPassageData.js +23 -0
- package/dist/components/DevModeDrawer/CurrentPassageData.js.map +1 -0
- package/dist/components/DevModeDrawer/DevModeDrawer.d.ts +7 -0
- package/dist/components/DevModeDrawer/DevModeDrawer.d.ts.map +1 -0
- package/dist/components/DevModeDrawer/DevModeDrawer.js +29 -0
- package/dist/components/DevModeDrawer/DevModeDrawer.js.map +1 -0
- package/dist/components/DevModeDrawer/GameData.d.ts +4 -0
- package/dist/components/DevModeDrawer/GameData.d.ts.map +1 -0
- package/dist/components/DevModeDrawer/GameData.js +22 -0
- package/dist/components/DevModeDrawer/GameData.js.map +1 -0
- package/dist/components/DevModeDrawer/JumpToPassage.d.ts +2 -0
- package/dist/components/DevModeDrawer/JumpToPassage.d.ts.map +1 -0
- package/dist/components/DevModeDrawer/JumpToPassage.js +15 -0
- package/dist/components/DevModeDrawer/JumpToPassage.js.map +1 -0
- package/dist/components/DevModeDrawer/RefreshButton.d.ts +4 -0
- package/dist/components/DevModeDrawer/RefreshButton.d.ts.map +1 -0
- package/dist/components/DevModeDrawer/RefreshButton.js +5 -0
- package/dist/components/DevModeDrawer/RefreshButton.js.map +1 -0
- package/dist/components/DevModeDrawer/index.d.ts +2 -0
- package/dist/components/DevModeDrawer/index.d.ts.map +1 -0
- package/dist/components/DevModeDrawer/index.js +2 -0
- package/dist/components/DevModeDrawer/index.js.map +1 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +22 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js +135 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js.map +1 -0
- package/dist/components/ErrorBoundary/index.d.ts +2 -0
- package/dist/components/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/components/ErrorBoundary/index.js +2 -0
- package/dist/components/ErrorBoundary/index.js.map +1 -0
- package/dist/components/ErrorBoundary/types.d.ts +12 -0
- package/dist/components/ErrorBoundary/types.d.ts.map +1 -0
- package/dist/components/ErrorBoundary/types.js +2 -0
- package/dist/components/ErrorBoundary/types.js.map +1 -0
- package/dist/components/GameProvider/AppIconMenu.d.ts +8 -0
- package/dist/components/GameProvider/AppIconMenu.d.ts.map +1 -0
- package/dist/components/GameProvider/AppIconMenu.js +12 -0
- package/dist/components/GameProvider/AppIconMenu.js.map +1 -0
- package/dist/components/GameProvider/GameProvider.d.ts +12 -0
- package/dist/components/GameProvider/GameProvider.d.ts.map +1 -0
- package/dist/components/GameProvider/GameProvider.js +36 -0
- package/dist/components/GameProvider/GameProvider.js.map +1 -0
- package/dist/components/GameProvider/SaveLoadMenuContext.d.ts +11 -0
- package/dist/components/GameProvider/SaveLoadMenuContext.d.ts.map +1 -0
- package/dist/components/GameProvider/SaveLoadMenuContext.js +3 -0
- package/dist/components/GameProvider/SaveLoadMenuContext.js.map +1 -0
- package/dist/components/GameProvider/SaveLoadMenuProvider.d.ts +4 -0
- package/dist/components/GameProvider/SaveLoadMenuProvider.d.ts.map +1 -0
- package/dist/components/GameProvider/SaveLoadMenuProvider.js +32 -0
- package/dist/components/GameProvider/SaveLoadMenuProvider.js.map +1 -0
- package/dist/components/GameProvider/index.d.ts +2 -0
- package/dist/components/GameProvider/index.d.ts.map +1 -0
- package/dist/components/GameProvider/index.js +2 -0
- package/dist/components/GameProvider/index.js.map +1 -0
- package/dist/components/InteractiveMapComponent/Hotspot.d.ts +9 -0
- package/dist/components/InteractiveMapComponent/Hotspot.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/Hotspot.js +30 -0
- package/dist/components/InteractiveMapComponent/Hotspot.js.map +1 -0
- package/dist/components/InteractiveMapComponent/HotspotMap.d.ts +8 -0
- package/dist/components/InteractiveMapComponent/HotspotMap.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/HotspotMap.js +37 -0
- package/dist/components/InteractiveMapComponent/HotspotMap.js.map +1 -0
- package/dist/components/InteractiveMapComponent/HotspotMenu.d.ts +9 -0
- package/dist/components/InteractiveMapComponent/HotspotMenu.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/HotspotMenu.js +37 -0
- package/dist/components/InteractiveMapComponent/HotspotMenu.js.map +1 -0
- package/dist/components/InteractiveMapComponent/ImageHotspot.d.ts +7 -0
- package/dist/components/InteractiveMapComponent/ImageHotspot.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/ImageHotspot.js +23 -0
- package/dist/components/InteractiveMapComponent/ImageHotspot.js.map +1 -0
- package/dist/components/InteractiveMapComponent/InteractiveMapComponent.d.ts +7 -0
- package/dist/components/InteractiveMapComponent/InteractiveMapComponent.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/InteractiveMapComponent.js +23 -0
- package/dist/components/InteractiveMapComponent/InteractiveMapComponent.js.map +1 -0
- package/dist/components/InteractiveMapComponent/LabelHotspot.d.ts +7 -0
- package/dist/components/InteractiveMapComponent/LabelHotspot.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/LabelHotspot.js +10 -0
- package/dist/components/InteractiveMapComponent/LabelHotspot.js.map +1 -0
- package/dist/components/InteractiveMapComponent/SideHotspot.d.ts +7 -0
- package/dist/components/InteractiveMapComponent/SideHotspot.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/SideHotspot.js +11 -0
- package/dist/components/InteractiveMapComponent/SideHotspot.js.map +1 -0
- package/dist/components/InteractiveMapComponent/helpers.d.ts +11 -0
- package/dist/components/InteractiveMapComponent/helpers.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/helpers.js +34 -0
- package/dist/components/InteractiveMapComponent/helpers.js.map +1 -0
- package/dist/components/InteractiveMapComponent/index.d.ts +2 -0
- package/dist/components/InteractiveMapComponent/index.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/index.js +2 -0
- package/dist/components/InteractiveMapComponent/index.js.map +1 -0
- package/dist/components/InteractiveMapComponent/types.d.ts +19 -0
- package/dist/components/InteractiveMapComponent/types.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/types.js +2 -0
- package/dist/components/InteractiveMapComponent/types.js.map +1 -0
- package/dist/components/InteractiveMapComponent/useHotspotMapSize.d.ts +3 -0
- package/dist/components/InteractiveMapComponent/useHotspotMapSize.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/useHotspotMapSize.js +74 -0
- package/dist/components/InteractiveMapComponent/useHotspotMapSize.js.map +1 -0
- package/dist/components/InteractiveMapComponent/useSortHotspots.d.ts +16 -0
- package/dist/components/InteractiveMapComponent/useSortHotspots.d.ts.map +1 -0
- package/dist/components/InteractiveMapComponent/useSortHotspots.js +13 -0
- package/dist/components/InteractiveMapComponent/useSortHotspots.js.map +1 -0
- package/dist/components/MainMenu.d.ts +2 -0
- package/dist/components/MainMenu.d.ts.map +1 -0
- package/dist/components/MainMenu.js +15 -0
- package/dist/components/MainMenu.js.map +1 -0
- package/dist/components/PassageController/PassageController.d.ts +2 -0
- package/dist/components/PassageController/PassageController.d.ts.map +1 -0
- package/dist/components/PassageController/PassageController.js +25 -0
- package/dist/components/PassageController/PassageController.js.map +1 -0
- package/dist/components/PassageController/index.d.ts +2 -0
- package/dist/components/PassageController/index.d.ts.map +1 -0
- package/dist/components/PassageController/index.js +2 -0
- package/dist/components/PassageController/index.js.map +1 -0
- package/dist/components/ReloadButton.d.ts +15 -0
- package/dist/components/ReloadButton.d.ts.map +1 -0
- package/dist/components/ReloadButton.js +10 -0
- package/dist/components/ReloadButton.js.map +1 -0
- package/dist/components/SaveButton.d.ts +21 -0
- package/dist/components/SaveButton.d.ts.map +1 -0
- package/dist/components/SaveButton.js +10 -0
- package/dist/components/SaveButton.js.map +1 -0
- package/dist/components/SaveLoadModal/SaveLoadModal.d.ts +9 -0
- package/dist/components/SaveLoadModal/SaveLoadModal.d.ts.map +1 -0
- package/dist/components/SaveLoadModal/SaveLoadModal.js +52 -0
- package/dist/components/SaveLoadModal/SaveLoadModal.js.map +1 -0
- package/dist/components/SaveLoadModal/index.d.ts +2 -0
- package/dist/components/SaveLoadModal/index.d.ts.map +1 -0
- package/dist/components/SaveLoadModal/index.js +2 -0
- package/dist/components/SaveLoadModal/index.js.map +1 -0
- package/dist/components/StoryComponent/StoryComponent.d.ts +7 -0
- package/dist/components/StoryComponent/StoryComponent.d.ts.map +1 -0
- package/dist/components/StoryComponent/StoryComponent.js +30 -0
- package/dist/components/StoryComponent/StoryComponent.js.map +1 -0
- package/dist/components/StoryComponent/components/Actions.d.ts +7 -0
- package/dist/components/StoryComponent/components/Actions.d.ts.map +1 -0
- package/dist/components/StoryComponent/components/Actions.js +6 -0
- package/dist/components/StoryComponent/components/Actions.js.map +1 -0
- package/dist/components/StoryComponent/components/Conversation.d.ts +7 -0
- package/dist/components/StoryComponent/components/Conversation.d.ts.map +1 -0
- package/dist/components/StoryComponent/components/Conversation.js +53 -0
- package/dist/components/StoryComponent/components/Conversation.js.map +1 -0
- package/dist/components/StoryComponent/components/Header.d.ts +7 -0
- package/dist/components/StoryComponent/components/Header.d.ts.map +1 -0
- package/dist/components/StoryComponent/components/Header.js +12 -0
- package/dist/components/StoryComponent/components/Header.js.map +1 -0
- package/dist/components/StoryComponent/components/Image.d.ts +5 -0
- package/dist/components/StoryComponent/components/Image.d.ts.map +1 -0
- package/dist/components/StoryComponent/components/Image.js +31 -0
- package/dist/components/StoryComponent/components/Image.js.map +1 -0
- package/dist/components/StoryComponent/components/Text.d.ts +7 -0
- package/dist/components/StoryComponent/components/Text.d.ts.map +1 -0
- package/dist/components/StoryComponent/components/Text.js +4 -0
- package/dist/components/StoryComponent/components/Text.js.map +1 -0
- package/dist/components/StoryComponent/components/Video.d.ts +7 -0
- package/dist/components/StoryComponent/components/Video.d.ts.map +1 -0
- package/dist/components/StoryComponent/components/Video.js +4 -0
- package/dist/components/StoryComponent/components/Video.js.map +1 -0
- package/dist/components/StoryComponent/components/index.d.ts +7 -0
- package/dist/components/StoryComponent/components/index.d.ts.map +1 -0
- package/dist/components/StoryComponent/components/index.js +7 -0
- package/dist/components/StoryComponent/components/index.js.map +1 -0
- package/dist/components/StoryComponent/index.d.ts +2 -0
- package/dist/components/StoryComponent/index.d.ts.map +1 -0
- package/dist/components/StoryComponent/index.js +2 -0
- package/dist/components/StoryComponent/index.js.map +1 -0
- package/dist/components/common/Button.d.ts +8 -0
- package/dist/components/common/Button.d.ts.map +1 -0
- package/dist/components/common/Button.js +64 -0
- package/dist/components/common/Button.js.map +1 -0
- package/dist/components/common/Spinner.d.ts +2 -0
- package/dist/components/common/Spinner.d.ts.map +1 -0
- package/dist/components/common/Spinner.js +3 -0
- package/dist/components/common/Spinner.js.map +1 -0
- package/dist/components/common/Tooltip.d.ts +12 -0
- package/dist/components/common/Tooltip.d.ts.map +1 -0
- package/dist/components/common/Tooltip.js +28 -0
- package/dist/components/common/Tooltip.js.map +1 -0
- package/dist/components/common/index.d.ts +4 -0
- package/dist/components/common/index.d.ts.map +1 -0
- package/dist/components/common/index.js +4 -0
- package/dist/components/common/index.js.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useLocalStorage.d.ts +2 -0
- package/dist/hooks/useLocalStorage.d.ts.map +1 -0
- package/dist/hooks/useLocalStorage.js +44 -0
- package/dist/hooks/useLocalStorage.js.map +1 -0
- package/dist/hooks/useSaveLoadMenu.d.ts +2 -0
- package/dist/hooks/useSaveLoadMenu.d.ts.map +1 -0
- package/dist/hooks/useSaveLoadMenu.js +11 -0
- package/dist/hooks/useSaveLoadMenu.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/styles/index.css +1809 -0
- package/dist/tests/ErrorBoundary.test.d.ts +2 -0
- package/dist/tests/ErrorBoundary.test.d.ts.map +1 -0
- package/dist/tests/ErrorBoundary.test.js +317 -0
- package/dist/tests/ErrorBoundary.test.js.map +1 -0
- package/dist/tests/dexie.mock.d.ts +56 -0
- package/dist/tests/dexie.mock.d.ts.map +1 -0
- package/dist/tests/dexie.mock.js +113 -0
- package/dist/tests/dexie.mock.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# @react-text-game/ui
|
|
2
|
+
|
|
3
|
+
UI components library for react-text-game built with React 19, TypeScript, and Tailwind CSS v4.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Development
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Build once
|
|
15
|
+
bun run build
|
|
16
|
+
|
|
17
|
+
# Watch mode
|
|
18
|
+
bun run dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Theme Customization
|
|
22
|
+
|
|
23
|
+
This package uses **Tailwind CSS v4** with semantic color tokens that can be easily customized to match your game's design system.
|
|
24
|
+
|
|
25
|
+
### How It Works
|
|
26
|
+
|
|
27
|
+
All components use semantic color names (like `primary`, `secondary`, `success`, etc.) instead of hardcoded colors. This means you can completely customize the look and feel by overriding these color variables in your application.
|
|
28
|
+
|
|
29
|
+
### Available Semantic Colors
|
|
30
|
+
|
|
31
|
+
#### Brand Colors
|
|
32
|
+
- `primary-*` (50-950) - Main brand color
|
|
33
|
+
- `secondary-*` (50-950) - Secondary brand color
|
|
34
|
+
|
|
35
|
+
#### Semantic State Colors
|
|
36
|
+
- `success-*` (50-950) - Success states
|
|
37
|
+
- `warning-*` (50-950) - Warning states
|
|
38
|
+
- `danger-*` (50-950) - Error/danger states
|
|
39
|
+
- `info-*` (50-950) - Informational states
|
|
40
|
+
|
|
41
|
+
#### Neutral/UI Colors
|
|
42
|
+
- `muted-*` (50-950) - Muted/subtle UI elements
|
|
43
|
+
- `background` - Main background color
|
|
44
|
+
- `foreground` - Main text color
|
|
45
|
+
- `card` / `card-foreground` - Card backgrounds and text
|
|
46
|
+
- `popover` / `popover-foreground` - Popover backgrounds and text
|
|
47
|
+
- `border` - Border color
|
|
48
|
+
- `input` - Input border color
|
|
49
|
+
- `ring` - Focus ring color
|
|
50
|
+
- `accent` / `accent-foreground` - Accent backgrounds and text
|
|
51
|
+
- `destructive` / `destructive-foreground` - Destructive action colors
|
|
52
|
+
|
|
53
|
+
### Customizing the Theme
|
|
54
|
+
|
|
55
|
+
You can override any theme color in your application's CSS file:
|
|
56
|
+
|
|
57
|
+
#### Example 1: Custom Brand Colors
|
|
58
|
+
|
|
59
|
+
```css
|
|
60
|
+
@import "@react-text-game/ui/styles";
|
|
61
|
+
|
|
62
|
+
@theme {
|
|
63
|
+
/* Override primary brand color to purple */
|
|
64
|
+
--color-primary-50: oklch(0.98 0.02 300);
|
|
65
|
+
--color-primary-100: oklch(0.95 0.05 300);
|
|
66
|
+
--color-primary-200: oklch(0.90 0.10 300);
|
|
67
|
+
--color-primary-300: oklch(0.82 0.15 300);
|
|
68
|
+
--color-primary-400: oklch(0.72 0.20 300);
|
|
69
|
+
--color-primary-500: oklch(0.62 0.24 300);
|
|
70
|
+
--color-primary-600: oklch(0.52 0.22 300);
|
|
71
|
+
--color-primary-700: oklch(0.44 0.18 300);
|
|
72
|
+
--color-primary-800: oklch(0.36 0.14 300);
|
|
73
|
+
--color-primary-900: oklch(0.28 0.10 300);
|
|
74
|
+
--color-primary-950: oklch(0.18 0.06 300);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### Example 2: Complete Custom Theme
|
|
79
|
+
|
|
80
|
+
```css
|
|
81
|
+
@import "@react-text-game/ui/styles";
|
|
82
|
+
|
|
83
|
+
@theme {
|
|
84
|
+
/* Replace entire color palette */
|
|
85
|
+
--color-*: initial;
|
|
86
|
+
|
|
87
|
+
/* Custom brand colors */
|
|
88
|
+
--color-primary-500: oklch(0.65 0.25 265);
|
|
89
|
+
--color-secondary-500: oklch(0.70 0.20 180);
|
|
90
|
+
|
|
91
|
+
/* Custom UI colors */
|
|
92
|
+
--color-background: oklch(0.98 0.002 264);
|
|
93
|
+
--color-foreground: oklch(0.20 0.01 264);
|
|
94
|
+
--color-border: oklch(0.88 0.005 264);
|
|
95
|
+
|
|
96
|
+
/* Success/Error colors */
|
|
97
|
+
--color-success-500: oklch(0.65 0.18 150);
|
|
98
|
+
--color-danger-500: oklch(0.65 0.22 30);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Example 3: Dark Mode Custom Colors
|
|
103
|
+
|
|
104
|
+
```css
|
|
105
|
+
@import "@react-text-game/ui/styles";
|
|
106
|
+
|
|
107
|
+
/* Override dark mode colors */
|
|
108
|
+
@media (prefers-color-scheme: dark) {
|
|
109
|
+
@theme {
|
|
110
|
+
--color-background: oklch(0.10 0.01 264);
|
|
111
|
+
--color-foreground: oklch(0.95 0.002 264);
|
|
112
|
+
--color-primary-500: oklch(0.70 0.25 265);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Using in Your Application
|
|
118
|
+
|
|
119
|
+
1. **Import the styles** in your main CSS file:
|
|
120
|
+
|
|
121
|
+
```css
|
|
122
|
+
@import "@react-text-game/ui/styles";
|
|
123
|
+
|
|
124
|
+
/* Your custom theme overrides here */
|
|
125
|
+
@theme {
|
|
126
|
+
--color-primary-500: your-custom-color;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
2. **Import components** in your React code:
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { Button, MainMenu, StoryComponent } from '@react-text-game/ui';
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Color Format: oklch()
|
|
137
|
+
|
|
138
|
+
This package uses the `oklch()` color format from Tailwind CSS v4, which provides:
|
|
139
|
+
- **Perceptually uniform** colors
|
|
140
|
+
- **Better dark mode** transitions
|
|
141
|
+
- **Predictable lightness** control
|
|
142
|
+
|
|
143
|
+
Format: `oklch(lightness chroma hue)`
|
|
144
|
+
- `lightness`: 0-1 (0 = black, 1 = white)
|
|
145
|
+
- `chroma`: 0-0.4 (saturation intensity)
|
|
146
|
+
- `hue`: 0-360 (color angle)
|
|
147
|
+
|
|
148
|
+
Use [oklch.com](https://oklch.com) to pick and convert colors.
|
|
149
|
+
|
|
150
|
+
### Component Customization
|
|
151
|
+
|
|
152
|
+
Components also accept `className` props for additional styling:
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
<Button
|
|
156
|
+
variant="solid"
|
|
157
|
+
color="primary"
|
|
158
|
+
className="custom-additional-styles"
|
|
159
|
+
>
|
|
160
|
+
Click me
|
|
161
|
+
</Button>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Tips
|
|
165
|
+
|
|
166
|
+
1. **Start small**: Override just `primary-500` and `secondary-500` to quickly brand your game
|
|
167
|
+
2. **Use the scale**: The `-50` to `-950` scale provides consistent light/dark variants
|
|
168
|
+
3. **Test dark mode**: Always test your custom colors in both light and dark modes
|
|
169
|
+
4. **Maintain contrast**: Ensure sufficient contrast between foreground and background colors
|
|
170
|
+
|
|
171
|
+
## ⚠️ Theme Variable Conflicts
|
|
172
|
+
|
|
173
|
+
### Potential Issue
|
|
174
|
+
|
|
175
|
+
This package uses **global CSS variables** (like `--color-primary-500`, `--color-background`, etc.) that may conflict with other design systems if you're mixing multiple component libraries.
|
|
176
|
+
|
|
177
|
+
**Example conflict:**
|
|
178
|
+
```css
|
|
179
|
+
/* Both systems try to define the same variables */
|
|
180
|
+
@import "@react-text-game/ui/styles"; /* Uses --color-primary-500 */
|
|
181
|
+
@import "@shadcn/ui/styles"; /* Also uses --color-primary-500 */
|
|
182
|
+
|
|
183
|
+
@theme {
|
|
184
|
+
--color-primary-500: oklch(...); /* Which library does this affect? Both! */
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Solutions
|
|
189
|
+
|
|
190
|
+
#### Option 1: Use as Primary Design System (Recommended)
|
|
191
|
+
|
|
192
|
+
This package is designed to be your **primary UI system** for game interfaces. If you're building a game, use `@react-text-game/ui` as your main component library and avoid mixing with other design systems.
|
|
193
|
+
|
|
194
|
+
#### Option 2: Scope Your Game UI
|
|
195
|
+
|
|
196
|
+
If you **must** mix with other design systems (e.g., using shadcn for admin panels and our UI for the game), wrap the game in a dedicated container:
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
// App.tsx
|
|
200
|
+
import '@react-text-game/ui/styles';
|
|
201
|
+
|
|
202
|
+
function App() {
|
|
203
|
+
return (
|
|
204
|
+
<>
|
|
205
|
+
{/* Admin UI with shadcn */}
|
|
206
|
+
<AdminPanel />
|
|
207
|
+
|
|
208
|
+
{/* Game UI isolated in a scope */}
|
|
209
|
+
<div className="game-container">
|
|
210
|
+
<GameProvider>
|
|
211
|
+
{/* Our components here */}
|
|
212
|
+
</GameProvider>
|
|
213
|
+
</div>
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Then create scoped overrides:
|
|
220
|
+
```css
|
|
221
|
+
/* app.css */
|
|
222
|
+
@import "@react-text-game/ui/styles";
|
|
223
|
+
|
|
224
|
+
/* Scoped theme for game only */
|
|
225
|
+
.game-container {
|
|
226
|
+
/* Override game theme variables specifically */
|
|
227
|
+
--color-primary-500: oklch(0.65 0.25 300);
|
|
228
|
+
--color-background: oklch(0.05 0.01 280);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
#### Option 3: CSS Layers for Priority Control
|
|
233
|
+
|
|
234
|
+
Use CSS `@layer` to control which system takes precedence:
|
|
235
|
+
|
|
236
|
+
```css
|
|
237
|
+
@import "@react-text-game/ui/styles" layer(game-ui);
|
|
238
|
+
@import "@shadcn/ui/styles" layer(admin-ui);
|
|
239
|
+
|
|
240
|
+
/* Define layer priority */
|
|
241
|
+
@layer game-ui, admin-ui;
|
|
242
|
+
|
|
243
|
+
/* game-ui variables will override admin-ui */
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### Option 4: Manual Variable Remapping (Advanced)
|
|
247
|
+
|
|
248
|
+
If you need fine-grained control, manually remap variables:
|
|
249
|
+
|
|
250
|
+
```css
|
|
251
|
+
@import "@react-text-game/ui/styles";
|
|
252
|
+
|
|
253
|
+
@theme {
|
|
254
|
+
/* Remap our variables to avoid conflicts */
|
|
255
|
+
--rtg-primary: var(--color-primary-500);
|
|
256
|
+
--rtg-background: var(--color-background);
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Then create wrapper components:
|
|
261
|
+
```tsx
|
|
262
|
+
// CustomButton.tsx
|
|
263
|
+
import { Button as RTGButton } from '@react-text-game/ui';
|
|
264
|
+
|
|
265
|
+
export const GameButton = (props) => (
|
|
266
|
+
<div style={{
|
|
267
|
+
'--color-primary-500': 'var(--rtg-primary)',
|
|
268
|
+
'--color-background': 'var(--rtg-background)'
|
|
269
|
+
}}>
|
|
270
|
+
<RTGButton {...props} />
|
|
271
|
+
</div>
|
|
272
|
+
);
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Best Practices
|
|
276
|
+
|
|
277
|
+
✅ **DO**: Use this as your primary design system for game UIs
|
|
278
|
+
✅ **DO**: Override theme variables at the root for global customization
|
|
279
|
+
✅ **DO**: Use scoped containers when mixing with other libraries
|
|
280
|
+
❌ **DON'T**: Mix multiple design systems in the same view without scoping
|
|
281
|
+
❌ **DON'T**: Import multiple `@theme` definitions at the same level without layers
|
|
282
|
+
|
|
283
|
+
## Components
|
|
284
|
+
|
|
285
|
+
- `Button` - Customizable button with multiple variants (solid, faded, bordered, light, flat, ghost, shadow)
|
|
286
|
+
- `Spinner` - Loading spinner
|
|
287
|
+
- `GameProvider` - Main game wrapper with dev tools
|
|
288
|
+
- `MainMenu` - Game menu with save/load functionality
|
|
289
|
+
- `StoryComponent` - Story passage renderer
|
|
290
|
+
- `InteractiveMapComponent` - Interactive map renderer
|
|
291
|
+
- `SaveLoadModal` - Save/Load game modal
|
|
292
|
+
- `Tooltip` - Tooltip component
|
|
293
|
+
- And more...
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.d.ts","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/CopyButton.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,GAAI,gBAAgB;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,4CAgDhE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
export const CopyButton = ({ textToCopy }) => {
|
|
4
|
+
const [showCopied, setShowCopied] = useState(false);
|
|
5
|
+
const handleCopy = async () => {
|
|
6
|
+
try {
|
|
7
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
8
|
+
setShowCopied(true);
|
|
9
|
+
setTimeout(() => setShowCopied(false), 1000);
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
console.error("Failed to copy:", err);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { className: "ml-1 text-sm cursor-pointer text-card-foreground", onClick: handleCopy, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 -.5 25 25", height: 24, width: 24, className: "inline-block", children: _jsxs("g", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5", children: [_jsx("path", { d: "M17.68 14.25a2.93 2.93 0 0 1-2.93 2.93H7.43a2.93 2.93 0 0 1-2.93-2.93V6.93A2.93 2.93 0 0 1 7.43 4h7.32a2.93 2.93 0 0 1 2.93 2.93v7.32Z", clipRule: "evenodd" }), _jsx("path", { d: "M10.25 20h7.32a2.93 2.93 0 0 0 2.93-2.93V9.75" })] }) }) }), showCopied && (_jsx("span", { className: "ml-2 text-xs text-success-600", children: "copied" }))] }));
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=CopyButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.js","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/CopyButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,UAAU,EAA0B,EAAE,EAAE;IACjE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC1B,IAAI,CAAC;YACD,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAChD,aAAa,CAAC,IAAI,CAAC,CAAC;YACpB,UAAU,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CACH,8BACI,iBACI,SAAS,EAAC,kDAAkD,EAC5D,OAAO,EAAE,UAAU,YAEnB,cACI,KAAK,EAAC,4BAA4B,EAClC,IAAI,EAAC,MAAM,EACX,OAAO,EAAC,aAAa,EACrB,MAAM,EAAE,EAAE,EACV,KAAK,EAAE,EAAE,EACT,SAAS,EAAC,cAAc,YAExB,aACI,MAAM,EAAC,cAAc,EACrB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,WAAW,EAAC,KAAK,aAEjB,eACI,CAAC,EAAC,wIAAwI,EAC1I,QAAQ,EAAC,SAAS,GACpB,EACF,eAAM,CAAC,EAAC,+CAA+C,GAAG,IAC1D,GACF,GACD,EACR,UAAU,IAAI,CACX,eAAM,SAAS,EAAC,+BAA+B,uBAExC,CACV,IACF,CACN,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrentPassageData.d.ts","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/CurrentPassageData.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,GAAI,YAAY;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,4CA2CjE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Game } from "@react-text-game/core";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { CopyButton } from "./CopyButton";
|
|
5
|
+
import { RefreshButton } from "./RefreshButton";
|
|
6
|
+
export const CurrentPassageData = ({ isOpen }) => {
|
|
7
|
+
const [currentPassageData, setCurrentPassageData] = useState("");
|
|
8
|
+
const [showPassageDataRefreshed, setShowPassageDataRefreshed] = useState(false);
|
|
9
|
+
const onReloadPassageData = () => {
|
|
10
|
+
const psg = Game.currentPassage;
|
|
11
|
+
const data = JSON.stringify({ passage: psg, data: psg?.display() }, null, 2);
|
|
12
|
+
setCurrentPassageData(data);
|
|
13
|
+
setShowPassageDataRefreshed(true);
|
|
14
|
+
setTimeout(() => setShowPassageDataRefreshed(false), 500);
|
|
15
|
+
};
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (isOpen) {
|
|
18
|
+
onReloadPassageData();
|
|
19
|
+
}
|
|
20
|
+
}, [isOpen]);
|
|
21
|
+
return (_jsxs("div", { className: "w-full", children: [_jsxs("div", { children: [_jsx("label", { htmlFor: "current-passage", className: "text-sm text-card-foreground", children: "Current Passage data" }), _jsx(RefreshButton, { onClick: onReloadPassageData }), _jsx(CopyButton, { textToCopy: currentPassageData }), showPassageDataRefreshed && (_jsx("span", { className: "ml-2 text-xs text-success-600", children: "refreshed" }))] }), _jsx("textarea", { id: "current-passage", disabled: true, className: "w-full h-30 bg-muted/20 border border-input rounded px-2 text-sm text-muted-foreground cursor-default resize-none", value: currentPassageData })] }));
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=CurrentPassageData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrentPassageData.js","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/CurrentPassageData.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAuB,EAAE,EAAE;IAClE,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjE,MAAM,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhF,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7E,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC5B,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAClC,UAAU,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,MAAM,EAAE,CAAC;YACT,mBAAmB,EAAE,CAAC;QAC1B,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACH,eAAK,SAAS,EAAC,QAAQ,aACnB,0BACI,gBACI,OAAO,EAAC,iBAAiB,EACzB,SAAS,EAAC,8BAA8B,qCAGpC,EACR,KAAC,aAAa,IAAC,OAAO,EAAE,mBAAmB,GAAI,EAC/C,KAAC,UAAU,IAAC,UAAU,EAAE,kBAAkB,GAAI,EAC7C,wBAAwB,IAAI,CACzB,eAAM,SAAS,EAAC,+BAA+B,0BAExC,CACV,IACC,EACN,mBACI,EAAE,EAAC,iBAAiB,EACpB,QAAQ,QACR,SAAS,EAAC,mHAAmH,EAC7H,KAAK,EAAE,kBAAkB,GAC3B,IACA,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NewOptions } from "@react-text-game/core";
|
|
2
|
+
type DevModeDrawerProps = Readonly<{
|
|
3
|
+
options: NewOptions;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const DevModeDrawer: ({ options }: DevModeDrawerProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=DevModeDrawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevModeDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/DevModeDrawer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,UAAU,EAAqB,MAAM,uBAAuB,CAAC;AAU5E,KAAK,kBAAkB,GAAG,QAAQ,CAAC;IAC/B,OAAO,EAAE,UAAU,CAAC;CACvB,CAAC,CAAC;AAEH,eAAO,MAAM,aAAa,GAAI,aAAa,kBAAkB,mDAgF5D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Game, useCurrentPassage } from "@react-text-game/core";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { twMerge } from "tailwind-merge";
|
|
6
|
+
import { useLocalStorage } from "../../hooks";
|
|
7
|
+
import { CurrentPassageData } from "./CurrentPassageData";
|
|
8
|
+
import { GameData } from "./GameData";
|
|
9
|
+
import { JumpToPassage } from "./JumpToPassage";
|
|
10
|
+
export const DevModeDrawer = ({ options }) => {
|
|
11
|
+
const { isDevMode } = options;
|
|
12
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
13
|
+
const passage = useCurrentPassage();
|
|
14
|
+
const [saveStateOnReload, setSaveStateOnReload] = useLocalStorage("saveStateOnReload", true);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!saveStateOnReload) {
|
|
17
|
+
console.log("Disabling autosave for this session");
|
|
18
|
+
Game.disableAutoSave();
|
|
19
|
+
Game.clearAutoSave();
|
|
20
|
+
}
|
|
21
|
+
}, [saveStateOnReload]);
|
|
22
|
+
if (!isDevMode) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return (_jsx("div", { className: "fixed bottom-0 left-1/2 -translate-x-1/2 z-100000000", children: _jsxs("div", { className: twMerge("bg-card border border-border rounded-t-lg shadow-lg transition-all duration-300", isOpen
|
|
26
|
+
? "translate-y-0 w-screen md:w-[60vw]"
|
|
27
|
+
: "translate-y-[calc(100%-1rem)] w-auto"), children: [_jsx("button", { onClick: () => setIsOpen(!isOpen), className: "w-full py-2 px-6 flex justify-center items-center cursor-pointer bg-primary-500 hover:bg-primary-600 rounded-t-lg", children: _jsx("div", { className: "w-12 h-1 bg-muted-400 rounded-full" }) }), isOpen && (_jsxs("div", { className: "p-4 border-t border-border", children: [_jsx("h3", { className: "text-lg font-semibold mb-3 text-card-foreground", children: "Dev Mode" }), _jsx("div", { className: "space-y-2", children: _jsxs("div", { className: "flex items-center flex-wrap gap-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("input", { type: "checkbox", id: "save-state-on-reload", checked: saveStateOnReload, onChange: (e) => setSaveStateOnReload(e.target.checked) }), _jsx("label", { htmlFor: "save-state-on-reload", className: "text-card-foreground", children: "Save state on reload" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("label", { htmlFor: "current-passage-id", className: "text-card-foreground", children: "Current passage ID" }), _jsx("input", { id: "current-passage-id", type: "text", value: passage?.id || "none", readOnly: true, className: "max-w-40 bg-muted/20 border border-input rounded px-2 text-sm text-muted-foreground cursor-default" })] }), _jsx(JumpToPassage, {}), _jsx(GameData, { isOpen: isOpen }), _jsx(CurrentPassageData, { isOpen: isOpen })] }) })] }))] }) }));
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=DevModeDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevModeDrawer.js","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/DevModeDrawer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAc,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAsB,EAAE,EAAE;IAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,eAAe,CAC7D,mBAAmB,EACnB,IAAI,CACP,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC;IACL,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CACH,cAAK,SAAS,EAAC,sDAAsD,YACjE,eACI,SAAS,EAAE,OAAO,CACd,iFAAiF,EACjF,MAAM;gBACF,CAAC,CAAC,oCAAoC;gBACtC,CAAC,CAAC,sCAAsC,CAC/C,aAED,iBACI,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EACjC,SAAS,EAAC,mHAAmH,YAE7H,cAAK,SAAS,EAAC,oCAAoC,GAAG,GACjD,EAER,MAAM,IAAI,CACP,eAAK,SAAS,EAAC,4BAA4B,aACvC,aAAI,SAAS,EAAC,iDAAiD,yBAAc,EAC7E,cAAK,SAAS,EAAC,WAAW,YACtB,eAAK,SAAS,EAAC,mCAAmC,aAC9C,eAAK,SAAS,EAAC,yBAAyB,aACpC,gBACI,IAAI,EAAC,UAAU,EACf,EAAE,EAAC,sBAAsB,EACzB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACZ,oBAAoB,CAChB,CAAC,CAAC,MAAM,CAAC,OAAO,CACnB,GAEP,EACF,gBAAO,OAAO,EAAC,sBAAsB,EAAC,SAAS,EAAC,sBAAsB,qCAE9D,IACN,EACN,eAAK,SAAS,EAAC,yBAAyB,aACpC,gBAAO,OAAO,EAAC,oBAAoB,EAAC,SAAS,EAAC,sBAAsB,mCAE5D,EACR,gBACI,EAAE,EAAC,oBAAoB,EACvB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,MAAM,EAC5B,QAAQ,QACR,SAAS,EAAC,oGAAoG,GAChH,IACA,EACN,KAAC,aAAa,KAAG,EACjB,KAAC,QAAQ,IAAC,MAAM,EAAE,MAAM,GAAI,EAC5B,KAAC,kBAAkB,IAAC,MAAM,EAAE,MAAM,GAAI,IACpC,GACJ,IACJ,CACT,IACC,GACJ,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GameData.d.ts","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/GameData.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,GAAI,YAAY;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,4CA0CvD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Game } from "@react-text-game/core";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { CopyButton } from "./CopyButton";
|
|
5
|
+
import { RefreshButton } from "./RefreshButton";
|
|
6
|
+
export const GameData = ({ isOpen }) => {
|
|
7
|
+
const [gameState, setGameState] = useState("");
|
|
8
|
+
const [showRefreshed, setShowRefreshed] = useState(false);
|
|
9
|
+
const onReloadGameState = () => {
|
|
10
|
+
const state = JSON.stringify(Game._getAllProxiedObjects(), null, 2);
|
|
11
|
+
setGameState(state);
|
|
12
|
+
setShowRefreshed(true);
|
|
13
|
+
setTimeout(() => setShowRefreshed(false), 500);
|
|
14
|
+
};
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (isOpen) {
|
|
17
|
+
onReloadGameState();
|
|
18
|
+
}
|
|
19
|
+
}, [isOpen]);
|
|
20
|
+
return (_jsxs("div", { className: "w-full", children: [_jsxs("div", { children: [_jsx("label", { htmlFor: "current-state", className: "text-sm text-card-foreground", children: "Current state" }), _jsx(RefreshButton, { onClick: onReloadGameState }), _jsx(CopyButton, { textToCopy: gameState }), showRefreshed && (_jsx("span", { className: "ml-2 text-xs text-success-600", children: "refreshed" }))] }), _jsx("textarea", { id: "current-state", disabled: true, className: "w-full h-30 bg-muted/20 border border-input rounded px-2 text-sm text-muted-foreground cursor-default resize-none", value: gameState })] }));
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=GameData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GameData.js","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/GameData.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,MAAM,EAAuB,EAAE,EAAE;IACxD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1D,MAAM,iBAAiB,GAAG,GAAG,EAAE;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACpE,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,MAAM,EAAE,CAAC;YACT,iBAAiB,EAAE,CAAC;QACxB,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACH,eAAK,SAAS,EAAC,QAAQ,aACnB,0BACI,gBACI,OAAO,EAAC,eAAe,EACvB,SAAS,EAAC,8BAA8B,8BAGpC,EACR,KAAC,aAAa,IAAC,OAAO,EAAE,iBAAiB,GAAI,EAC7C,KAAC,UAAU,IAAC,UAAU,EAAE,SAAS,GAAI,EACpC,aAAa,IAAI,CACd,eAAM,SAAS,EAAC,+BAA+B,0BAExC,CACV,IACC,EACN,mBACI,EAAE,EAAC,eAAe,EAClB,QAAQ,QACR,SAAS,EAAC,mHAAmH,EAC7H,KAAK,EAAE,SAAS,GAClB,IACA,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JumpToPassage.d.ts","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/JumpToPassage.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,+CA0CzB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Game } from "@react-text-game/core";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
export const JumpToPassage = () => {
|
|
5
|
+
const [passageToJumpTo, setPassageToJumpTo] = useState("");
|
|
6
|
+
const onJumpPassageSubmit = (e) => {
|
|
7
|
+
e.preventDefault();
|
|
8
|
+
if (passageToJumpTo) {
|
|
9
|
+
Game.jumpTo(passageToJumpTo);
|
|
10
|
+
setPassageToJumpTo("");
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
return (_jsx("div", { children: _jsxs("form", { onSubmit: onJumpPassageSubmit, children: [_jsx("label", { htmlFor: "jump-to-passage-id", className: "mr-2 text-card-foreground", children: "Jump to passage ID:" }), _jsx("input", { id: "jump-to-passage-id", type: "text", value: passageToJumpTo, onChange: (e) => setPassageToJumpTo(e.target.value), placeholder: "Enter passage ID", className: "bg-muted/20 border border-input rounded px-2 text-sm text-foreground" }), _jsx("button", { type: "submit", disabled: !passageToJumpTo, className: "ml-2 bg-primary-500 text-primary-foreground px-2 rounded hover:bg-primary-600 transition-colors active:scale-95 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-primary-500 disabled:active:scale-100", children: "Go" })] }) }));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=JumpToPassage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JumpToPassage.js","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/JumpToPassage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAa,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAC9B,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IAEnE,MAAM,mBAAmB,GAAG,CAAC,CAA6B,EAAE,EAAE;QAC1D,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,IAAI,eAAe,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAC7B,kBAAkB,CAAC,EAAE,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CACH,wBACI,gBAAM,QAAQ,EAAE,mBAAmB,aAC/B,gBACI,OAAO,EAAC,oBAAoB,EAC5B,SAAS,EAAC,2BAA2B,oCAGjC,EACR,gBACI,EAAE,EAAC,oBAAoB,EACvB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACZ,kBAAkB,CACd,CAAC,CAAC,MAAM,CAAC,KAAK,CACjB,EAEL,WAAW,EAAC,kBAAkB,EAC9B,SAAS,EAAC,sEAAsE,GAClF,EACF,iBACI,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,eAAe,EAC1B,SAAS,EAAC,wOAAwO,mBAG7O,IACN,GACL,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefreshButton.d.ts","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/RefreshButton.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,aAAa;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,4CAqBjE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const RefreshButton = ({ onClick }) => {
|
|
3
|
+
return (_jsx("button", { className: "ml-1 text-sm cursor-pointer text-card-foreground", onClick: onClick, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", height: 24, width: 24, className: "inline-block", children: _jsx("path", { fill: "currentColor", d: "M4.4 12a.75.75 0 0 0 1.5 0H4.4Zm1.89-3.89.63.4-.63-.4Zm3.05-2.58-.3-.69.3.7Zm3.92-.4.15-.73-.15.73Zm3.47 1.92-.54.52.54-.52Zm.98 3.16a.75.75 0 0 0 1.45-.42l-1.45.42Zm0-.4a.75.75 0 1 0 1.45.38l-1.45-.38Zm2.16-2.35a.75.75 0 1 0-1.45-.38l1.45.38Zm-1.63 3.26a.75.75 0 0 0 .4-1.44l-.4 1.44Zm-2.25-2.17a.75.75 0 1 0-.4 1.44l.4-1.44Zm3.9 3.45a.75.75 0 1 0-1.5 0h1.5ZM18 15.89l-.63-.4.63.4Zm-3.04 2.58.29.69-.3-.7Zm-3.93.4-.15.73.15-.73Zm-3.47-1.92.54-.52-.54.52Zm-.98-3.16a.75.75 0 0 0-1.45.42l1.45-.42Zm0 .4a.75.75 0 1 0-1.45-.38l1.45.38Zm-2.16 2.35a.75.75 0 1 0 1.45.38l-1.45-.38Zm1.63-3.26a.75.75 0 0 0-.4 1.44l.4-1.44Zm2.25 2.18A.75.75 0 0 0 8.7 14l-.4 1.45ZM5.9 12a6.4 6.4 0 0 1 1.02-3.48L5.66 7.7A7.9 7.9 0 0 0 4.4 12h1.5Zm1.02-3.48a6.09 6.09 0 0 1 2.71-2.3l-.6-1.38a7.59 7.59 0 0 0-3.37 2.87l1.26.8Zm2.71-2.3c1.1-.47 2.3-.59 3.48-.35l.3-1.47a7.35 7.35 0 0 0-4.37.44l.59 1.38Zm3.47-.35c1.18.24 2.26.84 3.09 1.7l1.08-1.04a7.48 7.48 0 0 0-3.86-2.13l-.3 1.47Zm3.1 1.7a6.3 6.3 0 0 1 1.51 2.64l1.45-.42a7.8 7.8 0 0 0-1.9-3.26L16.2 7.57Zm2.96 2.62.71-2.73-1.45-.38-.71 2.73 1.45.38Zm-.53-.91L16 8.55l-.4 1.44 2.65.73.4-1.44ZM18.4 12a6.4 6.4 0 0 1-1.03 3.48l1.26.82A7.9 7.9 0 0 0 19.9 12h-1.5Zm-1.03 3.48a6.09 6.09 0 0 1-2.71 2.3l.6 1.38a7.59 7.59 0 0 0 3.37-2.86l-1.26-.82Zm-2.71 2.3c-1.1.47-2.3.6-3.48.35l-.3 1.47c1.47.3 3 .15 4.37-.44l-.59-1.38Zm-3.47.35a5.98 5.98 0 0 1-3.09-1.7l-1.08 1.04a7.47 7.47 0 0 0 3.86 2.13l.3-1.47Zm-3.1-1.7a6.3 6.3 0 0 1-1.51-2.64l-1.45.42a7.8 7.8 0 0 0 1.9 3.26l1.07-1.04ZM5.14 13.8l-.71 2.73 1.45.38.71-2.73-1.45-.38Zm.53.91 2.64.74.4-1.45-2.65-.73-.4 1.44Z" }) }) }));
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=RefreshButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefreshButton.js","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/RefreshButton.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAA2B,EAAE,EAAE;IAClE,OAAO,CACH,iBACI,SAAS,EAAC,kDAAkD,EAC5D,OAAO,EAAE,OAAO,YAEhB,cACI,KAAK,EAAC,4BAA4B,EAClC,IAAI,EAAC,MAAM,EACX,OAAO,EAAC,WAAW,EACnB,MAAM,EAAE,EAAE,EACV,KAAK,EAAE,EAAE,EACT,SAAS,EAAC,cAAc,YAExB,eACI,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,gjDAAgjD,GACpjD,GACA,GACD,CACZ,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DevModeDrawer/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Component, ErrorInfo, ReactNode } from "react";
|
|
2
|
+
import { ErrorBoundaryProps, ErrorBoundaryState } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* ErrorBoundary catches all JavaScript errors in the application:
|
|
5
|
+
* - Rendering errors
|
|
6
|
+
* - Event handler errors
|
|
7
|
+
* - Async errors (promises, setTimeout)
|
|
8
|
+
* - Global uncaught errors
|
|
9
|
+
*/
|
|
10
|
+
export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
11
|
+
constructor(props: ErrorBoundaryProps);
|
|
12
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
13
|
+
componentDidMount(): void;
|
|
14
|
+
componentWillUnmount(): void;
|
|
15
|
+
handleGlobalError: (event: ErrorEvent) => void;
|
|
16
|
+
handlePromiseRejection: (event: PromiseRejectionEvent) => void;
|
|
17
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
18
|
+
reset: () => void;
|
|
19
|
+
copyErrorToClipboard: () => Promise<void>;
|
|
20
|
+
render(): ReactNode;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorBoundary/ErrorBoundary.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIxD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,SAAS,CACxC,kBAAkB,EAClB,kBAAkB,CACrB;gBACe,KAAK,EAAE,kBAAkB;IAUrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI1E,iBAAiB,IAAI,IAAI;IAWzB,oBAAoB,IAAI,IAAI;IAQ5B,iBAAiB,GAAI,OAAO,UAAU,KAAG,IAAI,CAiC3C;IAEF,sBAAsB,GAAI,OAAO,qBAAqB,KAAG,IAAI,CAqB3D;IAEF,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAY3D,KAAK,QAAO,IAAI,CAMd;IAEF,oBAAoB,QAAa,OAAO,CAAC,IAAI,CAAC,CAuB5C;IAEF,MAAM,IAAI,SAAS;CA+HtB"}
|