From 6c1ce1031e18fd4a9a6c531706e846c4a556b299 Mon Sep 17 00:00:00 2001 From: Philipp Adrian Date: Thu, 22 Dec 2022 16:19:30 -0500 Subject: [PATCH] Popup JS size reduction (#1959) --- packages/app-extension/src/index.tsx | 13 +++-- packages/app-extension/src/popup.html | 47 +++++++++++-------- .../src/components/base/Loading.tsx | 6 +-- packages/themes/src/index.tsx | 2 +- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/packages/app-extension/src/index.tsx b/packages/app-extension/src/index.tsx index a0fa12466..1a720e0f6 100644 --- a/packages/app-extension/src/index.tsx +++ b/packages/app-extension/src/index.tsx @@ -1,6 +1,8 @@ import React, { lazy, Suspense } from "react"; import ReactDOM from "react-dom"; -import { BACKPACK_FEATURE_POP_MODE, openPopupWindow } from "@coral-xyz/common"; +import { openPopupWindow } from "@coral-xyz/common/dist/esm/browser"; +import { BACKPACK_FEATURE_POP_MODE } from "@coral-xyz/common/dist/esm/generated-config"; +import { Loading } from "@coral-xyz/react-common/dist/esm/components/base/Loading"; import "./index.css"; @@ -19,8 +21,11 @@ document.addEventListener("keypress", async function onPress(event) { // if (BACKPACK_FEATURE_POP_MODE) { if (event.key === "g" && event.ctrlKey) { - await openPopupWindow("popup.html"); - window.close(); + const currentWindow = await chrome.windows.getCurrent(); + const popupWindow = await openPopupWindow("popup.html"); + if (currentWindow.id !== popupWindow.id) { + window.close(); + } } } }); @@ -30,7 +35,7 @@ document.addEventListener("keypress", async function onPress(event) { // ReactDOM.render( - + }> diff --git a/packages/app-extension/src/popup.html b/packages/app-extension/src/popup.html index c0a9f73eb..543ded828 100644 --- a/packages/app-extension/src/popup.html +++ b/packages/app-extension/src/popup.html @@ -1,23 +1,30 @@ - - - - - - - - -
- - - + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/packages/react-common/src/components/base/Loading.tsx b/packages/react-common/src/components/base/Loading.tsx index 9fb697141..92d9bc484 100644 --- a/packages/react-common/src/components/base/Loading.tsx +++ b/packages/react-common/src/components/base/Loading.tsx @@ -1,6 +1,6 @@ -import type { CustomTheme} from "@coral-xyz/themes"; -import { styles } from "@coral-xyz/themes"; -import { CircularProgress } from "@mui/material"; +import type { CustomTheme } from "@coral-xyz/themes"; +import { styles } from "@coral-xyz/themes/"; +import CircularProgress from "@mui/material/CircularProgress"; const useStyles = styles((theme: CustomTheme) => ({ circle: { stroke: "url(#linearColors)", diff --git a/packages/themes/src/index.tsx b/packages/themes/src/index.tsx index 5aca31f78..e21fe6f49 100644 --- a/packages/themes/src/index.tsx +++ b/packages/themes/src/index.tsx @@ -2,7 +2,7 @@ import createStyles from "@mui/styles/createStyles"; import _makeStyles from "@mui/styles/makeStyles"; import useTheme from "@mui/styles/useTheme"; import type { CreateMUIStyled, Theme } from "@mui/system"; -import { styled as muiStyled } from "@mui/system"; +import muiStyled from "@mui/system/styled"; export const HOVER_OPACITY = 0.8;