Skip to content

Commit 1554bf1

Browse files
committed
Close side menu after app is chosen on landscape screen
1 parent b9ef7dd commit 1554bf1

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

web/components/explorer/app/app-explorer.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ExtensionPreview from "@/components/extension/extension-preview";
22
import { EditorContext } from "@/components/providers/editor-context-provider";
3+
import { useScreenSize } from "@/lib/hooks/use-screen-size";
34
import { useTabViewManager } from "@/lib/hooks/use-tab-view-manager";
45
import { AppViewConfig } from "@/lib/types";
56
import { Button } from "@heroui/react";
@@ -10,6 +11,7 @@ export default function AppExplorer() {
1011
const editorContext = useContext(EditorContext);
1112

1213
const { createAppViewInCanvasView } = useTabViewManager();
14+
const { isLandscape } = useScreenSize();
1315

1416
const extensions = editorContext?.persistSettings?.extensions ?? [];
1517

@@ -36,6 +38,13 @@ export default function AppExplorer() {
3638
recommendedWidth: ext.config.recommendedWidth,
3739
};
3840
createAppViewInCanvasView(config);
41+
console.log("Is Landscape:", isLandscape);
42+
if (!isLandscape) {
43+
editorContext?.setEditorStates((prev) => ({
44+
...prev,
45+
isSideMenuOpen: false,
46+
}));
47+
}
3948
}}
4049
/>
4150
</div>

web/components/interface/navigation/nav-side-menu.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import Tabs from "@/components/misc/tabs";
44
import ProjectSettingsModal from "@/components/modals/project-settings-modal";
55
import { EditorContext } from "@/components/providers/editor-context-provider";
66
import useExplorer from "@/lib/hooks/use-explorer";
7+
import { useScreenSize } from "@/lib/hooks/use-screen-size";
78
import { isWeb } from "@/lib/platform-api/platform-checker";
89
import { TabItem } from "@/lib/types";
910
import { Button } from "@heroui/react";
1011
import { AnimatePresence, motion } from "framer-motion";
1112
import { useContext, useState } from "react";
12-
import { useMediaQuery } from "react-responsive";
1313
import FileSystemExplorer from "../../explorer/file-system/fs-explorer";
1414
import Icon from "../../misc/icon";
1515

@@ -55,9 +55,7 @@ export default function NavSideMenu({
5555
}
5656

5757
function MenuPanel({ children }: { children?: React.ReactNode }) {
58-
const isLandscape = useMediaQuery({
59-
query: "(min-width: 768px)",
60-
});
58+
const { isLandscape } = useScreenSize();
6159

6260
return (
6361
<>

web/lib/hooks/use-screen-size.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { useMediaQuery } from "react-responsive";
2+
3+
export function useScreenSize() {
4+
const isLandscape = useMediaQuery({
5+
query: "(min-width: 768px)",
6+
});
7+
return { isLandscape };
8+
}

web/lib/platform-api/platform-checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { PlatformEnum } from "@/lib/types";
12
import { Capacitor } from "@capacitor/core";
23
import isElectron from "is-electron";
3-
import { PlatformEnum } from "@/lib/types";
44

55
export function getPlatform() {
66
// Capacitor

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "next build",
99
"lint": "next lint",
1010
"start": "serve ../build/next",
11-
"dev-https": "next dev --experimental-https"
11+
"dev-https": "next dev --experimental-https"
1212
},
1313
"dependencies": {
1414
"@capacitor-community/safe-area": "^7.0.0-alpha.1",

0 commit comments

Comments
 (0)