@littlepartytime/dev-kit 1.22.1 → 1.22.3
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/dist/webapp/pages/Mobile.tsx +50 -14
- package/package.json +1 -1
|
@@ -5,13 +5,7 @@ import PlatformTakeover from '../components/PlatformTakeover';
|
|
|
5
5
|
declare const __SOCKET_PORT__: number;
|
|
6
6
|
declare const __DEV_KIT_MODE__: string;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Root container mirrors the platform's room page:
|
|
10
|
-
* <div class="h-[100dvh] flex flex-col overflow-hidden">
|
|
11
|
-
* No position:fixed — uses 100dvh which shrinks with mobile keyboard.
|
|
12
|
-
*/
|
|
13
|
-
const rootStyle: React.CSSProperties = {
|
|
14
|
-
height: '100dvh',
|
|
8
|
+
const baseStyle: React.CSSProperties = {
|
|
15
9
|
display: 'flex',
|
|
16
10
|
flexDirection: 'column',
|
|
17
11
|
overflow: 'hidden',
|
|
@@ -20,17 +14,59 @@ const rootStyle: React.CSSProperties = {
|
|
|
20
14
|
fontFamily: 'system-ui, -apple-system, sans-serif',
|
|
21
15
|
};
|
|
22
16
|
|
|
23
|
-
/**
|
|
24
|
-
* Game outer wrapper mirrors the platform's flex-1 scrollable area:
|
|
25
|
-
* <div class="flex-1 min-h-0 overflow-y-auto">
|
|
26
|
-
*/
|
|
27
17
|
const gameOuterStyle: React.CSSProperties = {
|
|
28
18
|
flex: 1,
|
|
29
19
|
minHeight: 0,
|
|
30
20
|
overflowY: 'auto',
|
|
31
21
|
};
|
|
32
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Track actual visible height via VisualViewport API.
|
|
25
|
+
*
|
|
26
|
+
* On iOS Safari (non-PWA), 100dvh does NOT shrink when the keyboard opens.
|
|
27
|
+
* We use visualViewport.height to detect the keyboard and override the
|
|
28
|
+
* container height only while it's open. When the keyboard closes, we
|
|
29
|
+
* revert to 100dvh so Safari toolbar/address bar changes don't leave
|
|
30
|
+
* a dead zone at the bottom.
|
|
31
|
+
*/
|
|
32
|
+
function useViewportHeight(): string {
|
|
33
|
+
const [height, setHeight] = useState('100dvh');
|
|
34
|
+
const initialHeight = useRef(0);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const vv = window.visualViewport;
|
|
38
|
+
if (!vv) return;
|
|
39
|
+
|
|
40
|
+
// Capture the full viewport height on first load (no keyboard)
|
|
41
|
+
initialHeight.current = vv.height;
|
|
42
|
+
|
|
43
|
+
const KEYBOARD_THRESHOLD = 100; // px — if viewport shrinks by more than this, keyboard is open
|
|
44
|
+
|
|
45
|
+
const update = () => {
|
|
46
|
+
window.scrollTo(0, 0);
|
|
47
|
+
const shrunk = initialHeight.current - vv.height;
|
|
48
|
+
if (shrunk > KEYBOARD_THRESHOLD) {
|
|
49
|
+
// Keyboard is open: use exact pixel height so content compresses
|
|
50
|
+
setHeight(`${vv.height}px`);
|
|
51
|
+
} else {
|
|
52
|
+
// Keyboard is closed: use 100dvh to fill the screen fully
|
|
53
|
+
setHeight('100dvh');
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
vv.addEventListener('resize', update);
|
|
58
|
+
vv.addEventListener('scroll', update);
|
|
59
|
+
return () => {
|
|
60
|
+
vv.removeEventListener('resize', update);
|
|
61
|
+
vv.removeEventListener('scroll', update);
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
return height;
|
|
66
|
+
}
|
|
67
|
+
|
|
33
68
|
export default function Mobile() {
|
|
69
|
+
const viewportHeight = useViewportHeight();
|
|
34
70
|
const [socket, setSocket] = useState<Socket | null>(null);
|
|
35
71
|
const [nickname, setNickname] = useState('');
|
|
36
72
|
const [joined, setJoined] = useState(false);
|
|
@@ -121,7 +157,7 @@ export default function Mobile() {
|
|
|
121
157
|
// Join screen
|
|
122
158
|
if (!joined) {
|
|
123
159
|
return (
|
|
124
|
-
<div style={{ ...
|
|
160
|
+
<div style={{ ...baseStyle, height: viewportHeight, alignItems: 'center', justifyContent: 'center' }}>
|
|
125
161
|
<div style={{ width: '85%', maxWidth: 320 }}>
|
|
126
162
|
<h2 style={{ fontSize: 20, fontWeight: 700, marginBottom: 16, textAlign: 'center' }}>Join Game</h2>
|
|
127
163
|
<input
|
|
@@ -146,7 +182,7 @@ export default function Mobile() {
|
|
|
146
182
|
// Lobby
|
|
147
183
|
if (room.phase === 'lobby' || room.phase === 'ready') {
|
|
148
184
|
return (
|
|
149
|
-
<div style={{ ...
|
|
185
|
+
<div style={{ ...baseStyle, height: viewportHeight, padding: 16 }}>
|
|
150
186
|
<h2 style={{ fontSize: 20, fontWeight: 700, marginBottom: 16 }}>Lobby</h2>
|
|
151
187
|
<div style={{ flex: 1, overflow: 'auto', display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
152
188
|
{room.players.map((p: any) => (
|
|
@@ -187,7 +223,7 @@ export default function Mobile() {
|
|
|
187
223
|
// div.flex-1.min-h-0.overflow-y-auto (game outer)
|
|
188
224
|
// div.game-sandbox (safe area padding)
|
|
189
225
|
return (
|
|
190
|
-
<div style={
|
|
226
|
+
<div style={{ ...baseStyle, height: viewportHeight }}>
|
|
191
227
|
<div style={gameOuterStyle}>
|
|
192
228
|
<div className="game-sandbox">
|
|
193
229
|
{gameOver ? (
|