Skip to content

Commit 3be85c7

Browse files
authored
Merge pull request #28 from scottlu/claude/lock-screen-rotation-home-UCThh
2 parents 702af0a + 1b6d5a1 commit 3be85c7

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

src/app.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useCallback, useEffect, useRef, useMemo } from 'react';
1+
import { useState, useCallback, useEffect, useRef } from 'react';
22
import { Screen, GameStatus } from './types/game';
33
import { useMinesweeper } from './hooks/useMinesweeper';
44
import { useSettings } from './hooks/useSettings';
@@ -49,24 +49,8 @@ export default function App() {
4949
setScreen(Screen.Game);
5050
}, [game.newGame]);
5151

52-
const rotationStyle = useMemo(() => {
53-
if (!isLandscape) {
54-
return undefined;
55-
}
56-
return {
57-
transform: 'rotate(-90deg)',
58-
transformOrigin: 'top left',
59-
width: window.innerHeight,
60-
height: window.innerWidth,
61-
position: 'fixed' as const,
62-
top: window.innerHeight,
63-
left: 0,
64-
overflow: 'hidden',
65-
};
66-
}, [isLandscape]);
67-
6852
return (
69-
<div className="flex flex-col h-full" style={rotationStyle}>
53+
<div className="app-root flex flex-col h-full">
7054
{screen === Screen.Game && (
7155
<>
7256
<Header

src/index.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,18 @@ html, body, #root {
1717
-webkit-user-select: none;
1818
user-select: none;
1919
-webkit-touch-callout: none;
20+
}
21+
22+
/* Force portrait layout when device is in landscape on phones */
23+
@media (orientation: landscape) and (max-height: 500px) {
24+
.app-root {
25+
transform: rotate(-90deg);
26+
transform-origin: top left;
27+
width: 100dvh;
28+
height: 100dvw;
29+
position: fixed;
30+
top: 100dvh;
31+
left: 0;
32+
overflow: hidden;
33+
}
2034
}

0 commit comments

Comments
 (0)