From 976e4ce7ed4c80566434cf9f5bad98e5ff066a13 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Tue, 4 Jul 2023 11:33:35 +0800 Subject: [PATCH] feat: define drag areas in electron --- src/assets/index.css | 7 +++++++ src/components/BlankPlaceholder.tsx | 2 +- src/components/Modal.tsx | 1 + src/components/StyledSettingContainer.tsx | 10 ++++++---- src/routes/chat/GuestBlankPlaceholder.tsx | 2 +- src/routes/chat/Layout/index.tsx | 8 ++++---- src/routes/chat/VoiceFullscreen.tsx | 4 ++-- src/routes/chat/index.tsx | 4 +++- src/routes/home/Menu.tsx | 2 +- src/routes/home/User.tsx | 2 +- src/routes/home/index.tsx | 4 ++-- 11 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/assets/index.css b/src/assets/index.css index 27694566..f1f578df 100644 --- a/src/assets/index.css +++ b/src/assets/index.css @@ -7,6 +7,13 @@ } } @layer utilities { + /* for electron */ + .app-drag { + -webkit-app-region: drag; + } + .app-no-drag { + -webkit-app-region: no-drag; + } /* word break */ .wb { word-break: break-word; diff --git a/src/components/BlankPlaceholder.tsx b/src/components/BlankPlaceholder.tsx index 790592e7..6916ad04 100644 --- a/src/components/BlankPlaceholder.tsx +++ b/src/components/BlankPlaceholder.tsx @@ -46,7 +46,7 @@ const BlankPlaceholder: FC = ({ type = "chat" }) => { const chatHandler = type == "chat" ? toggleChannelModalVisible : toggleUserListVisible; return ( <> -
+

{t("title", { name: server.name })} diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index ef8ab016..e5af7ff0 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -17,6 +17,7 @@ const Modal: FC> = ({ id = "root-modal", mask = true, c } const wrapper = document.createElement("div"); wrapper.classList.add("wrapper"); + wrapper.classList.add("app-no-drag"); modalRoot.appendChild(wrapper); setWrapper(wrapper); return () => { diff --git a/src/components/StyledSettingContainer.tsx b/src/components/StyledSettingContainer.tsx index f3a92a9c..71777013 100644 --- a/src/components/StyledSettingContainer.tsx +++ b/src/components/StyledSettingContainer.tsx @@ -36,13 +36,14 @@ const StyledSettingContainer: FC> = ({

{title}

@@ -51,7 +52,7 @@ const StyledSettingContainer: FC> = ({
    {items.map(({ name, link, title }) => { if (link) @@ -91,7 +92,7 @@ const StyledSettingContainer: FC> = ({ ); })} {dangers.length ? ( -
      +
        {dangers.map((d) => { if (typeof d === "boolean" || !d) return null; const { title, handler } = d; @@ -110,6 +111,7 @@ const StyledSettingContainer: FC> = ({
> = ({

)} {/* */} - {children} +
{children}
{/*
*/}
diff --git a/src/routes/chat/GuestBlankPlaceholder.tsx b/src/routes/chat/GuestBlankPlaceholder.tsx index 8fd6e6ad..f88413e6 100644 --- a/src/routes/chat/GuestBlankPlaceholder.tsx +++ b/src/routes/chat/GuestBlankPlaceholder.tsx @@ -25,7 +25,7 @@ const GuestBlankPlaceholder = () => { }; const qrUrl = BASE_ORIGIN; return ( -
+

{t("welcome", { name: serverName })}

diff --git a/src/routes/chat/Layout/index.tsx b/src/routes/chat/Layout/index.tsx index 41475c6e..2801065d 100644 --- a/src/routes/chat/Layout/index.tsx +++ b/src/routes/chat/Layout/index.tsx @@ -94,10 +94,10 @@ const Layout: FC = ({ return ( <> -
-
+
+
{header} -
+
= ({ {aside && (
{aside} diff --git a/src/routes/chat/VoiceFullscreen.tsx b/src/routes/chat/VoiceFullscreen.tsx index 8e33657b..dc92f98c 100644 --- a/src/routes/chat/VoiceFullscreen.tsx +++ b/src/routes/chat/VoiceFullscreen.tsx @@ -63,9 +63,9 @@ const VoiceFullscreen = ({ id, context }: Props) => { const membersData = voicingMembers.byId; const hasPin = typeof pinUid !== "undefined"; return ( -
+
{/* top */} -
+
{_name}
{/* middle */} diff --git a/src/routes/chat/index.tsx b/src/routes/chat/index.tsx index 19710595..b15901ab 100644 --- a/src/routes/chat/index.tsx +++ b/src/routes/chat/index.tsx @@ -77,6 +77,7 @@ function ChatPage() { {usersModalVisible && }
@@ -99,6 +100,7 @@ function ChatPage() {
= () => { const { pathname } = useLocation(); return ( -
    +
    • diff --git a/src/routes/home/User.tsx b/src/routes/home/User.tsx index 1d6f3fed..ae1cb33d 100644 --- a/src/routes/home/User.tsx +++ b/src/routes/home/User.tsx @@ -14,7 +14,7 @@ const User: FC = ({ uid }) => { if (!user) return null; return ( -
      +
      {!guest && (