From 78d976302f60b5e57310f21dbf274af965afc0ae Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Thu, 15 Dec 2022 18:38:04 +0000 Subject: [PATCH] [playground] Remove mobile support This is mostly unused and there's just not enough benefit for now. We can re-add this if folks start using this site on mobile. Removing now to simplify the codebase. --- .../playground/components/Editor/index.tsx | 31 ++---------------- .../forget/packages/playground/hooks/index.ts | 1 - .../playground/hooks/useWindowSize.ts | 32 ------------------- 3 files changed, 3 insertions(+), 61 deletions(-) delete mode 100644 compiler/forget/packages/playground/hooks/useWindowSize.ts diff --git a/compiler/forget/packages/playground/components/Editor/index.tsx b/compiler/forget/packages/playground/components/Editor/index.tsx index 6b0140cb06..776aa5eeaa 100644 --- a/compiler/forget/packages/playground/components/Editor/index.tsx +++ b/compiler/forget/packages/playground/components/Editor/index.tsx @@ -5,13 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -import { useDrag } from "@use-gesture/react"; import type { Diagnostic } from "babel-plugin-react-forget"; import clsx from "clsx"; import invariant from "invariant"; import { useSnackbar } from "notistack"; import { useCallback, useDeferredValue, useState } from "react"; -import { useMountEffect, useWindowSize } from "../../hooks"; +import { useMountEffect } from "../../hooks"; import { defaultStore } from "../../lib/defaultStore"; import { createMessage, @@ -30,9 +29,6 @@ export default function Editor() { const deferredStore = useDeferredValue(store); const dispatchStore = useStoreDispatch(); const { enqueueSnackbar } = useSnackbar(); - const [showOutputOnMobile, setShowOutputOnMobile] = useState(false); - const { width: windowWidth } = useWindowSize(); - const isMobile = windowWidth < 640; const [diagnostics, setDiagnostics] = useState([]); const updateDiagnostics = useCallback( (newDiags: Diagnostic[]) => setDiagnostics(newDiags), @@ -40,9 +36,6 @@ export default function Editor() { ); const [tabsOpen, setTabsOpen] = useState>(new Map()); - /** - * Initialize store from encoded data or fallback to the default store. - */ useMountEffect(() => { let mountStore: Store; try { @@ -68,22 +61,10 @@ export default function Editor() { return ( <>
-
+
-
+
- ); } diff --git a/compiler/forget/packages/playground/hooks/index.ts b/compiler/forget/packages/playground/hooks/index.ts index 68113f46c4..fbb69cd5d3 100644 --- a/compiler/forget/packages/playground/hooks/index.ts +++ b/compiler/forget/packages/playground/hooks/index.ts @@ -3,4 +3,3 @@ */ export { default as useMountEffect } from "./useMountEffect"; -export { default as useWindowSize } from "./useWindowSize"; diff --git a/compiler/forget/packages/playground/hooks/useWindowSize.ts b/compiler/forget/packages/playground/hooks/useWindowSize.ts deleted file mode 100644 index 8a31037ee1..0000000000 --- a/compiler/forget/packages/playground/hooks/useWindowSize.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - */ - -import { useState } from "react"; -import useMountEffect from "./useMountEffect"; - -/** - * @returns the latest window width and height before/after - * resizing the window. - */ -export default function useWindowSize() { - const [windowSize, setWindowSize] = useState({ - width: 0, - height: 0, - }); - - useMountEffect(() => { - setWindowSize({ width: window.innerWidth, height: window.innerHeight }); - }); - - useMountEffect(() => { - function handleResize() { - setWindowSize({ width: window.innerWidth, height: window.innerHeight }); - } - - window.addEventListener("resize", handleResize); - return () => window.removeEventListener("resize", handleResize); - }); - - return windowSize; -}