feat: define drag areas in electron
This commit is contained in:
@@ -7,6 +7,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@layer utilities {
|
@layer utilities {
|
||||||
|
/* for electron */
|
||||||
|
.app-drag {
|
||||||
|
-webkit-app-region: drag;
|
||||||
|
}
|
||||||
|
.app-no-drag {
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
|
}
|
||||||
/* word break */
|
/* word break */
|
||||||
.wb {
|
.wb {
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const BlankPlaceholder: FC<Props> = ({ type = "chat" }) => {
|
|||||||
const chatHandler = type == "chat" ? toggleChannelModalVisible : toggleUserListVisible;
|
const chatHandler = type == "chat" ? toggleChannelModalVisible : toggleUserListVisible;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex flex-col gap-8 -mt-[50px] dark:bg-gray-700">
|
<div className="flex flex-col gap-8 -mt-[50px] dark:bg-gray-700 app-no-drag">
|
||||||
<div className="flex flex-col gap-2 items-center group px-4">
|
<div className="flex flex-col gap-2 items-center group px-4">
|
||||||
<h2 className="text-center text-3xl text-slate-700 dark:text-white font-bold">
|
<h2 className="text-center text-3xl text-slate-700 dark:text-white font-bold">
|
||||||
{t("title", { name: server.name })}
|
{t("title", { name: server.name })}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const Modal: FC<PropsWithChildren<Props>> = ({ id = "root-modal", mask = true, c
|
|||||||
}
|
}
|
||||||
const wrapper = document.createElement("div");
|
const wrapper = document.createElement("div");
|
||||||
wrapper.classList.add("wrapper");
|
wrapper.classList.add("wrapper");
|
||||||
|
wrapper.classList.add("app-no-drag");
|
||||||
modalRoot.appendChild(wrapper);
|
modalRoot.appendChild(wrapper);
|
||||||
setWrapper(wrapper);
|
setWrapper(wrapper);
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -36,13 +36,14 @@ const StyledSettingContainer: FC<PropsWithChildren<Props>> = ({
|
|||||||
<div className="w-screen h-screen flex">
|
<div className="w-screen h-screen flex">
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
"app-drag",
|
||||||
"h-full w-full overflow-y-scroll md:max-w-[212px] px-4 py-8 bg-neutral-100 dark:bg-gray-800",
|
"h-full w-full overflow-y-scroll md:max-w-[212px] px-4 py-8 bg-neutral-100 dark:bg-gray-800",
|
||||||
nav && "hidden md:block"
|
nav && "hidden md:block"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<h2
|
<h2
|
||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
className="hidden md:flex gap-2 items-center text-sm md:text-base cursor-pointer mb-8 font-bold text-gray-800 dark:text-white"
|
className="app-no-drag hidden md:flex gap-2 items-center text-sm md:text-base cursor-pointer mb-8 font-bold text-gray-800 dark:text-white"
|
||||||
>
|
>
|
||||||
<IconBack className="dark:fill-gray-400" /> {title}
|
<IconBack className="dark:fill-gray-400" /> {title}
|
||||||
</h2>
|
</h2>
|
||||||
@@ -51,7 +52,7 @@ const StyledSettingContainer: FC<PropsWithChildren<Props>> = ({
|
|||||||
<ul
|
<ul
|
||||||
key={title}
|
key={title}
|
||||||
data-title={title}
|
data-title={title}
|
||||||
className="flex flex-col gap-0.5 mb-5 md:mb-9 before:md:pl-3 before:content-[attr(data-title)] before:font-bold before:text-xs before:text-gray-400"
|
className="app-no-drag flex flex-col gap-0.5 mb-5 md:mb-9 before:md:pl-3 before:content-[attr(data-title)] before:font-bold before:text-xs before:text-gray-400"
|
||||||
>
|
>
|
||||||
{items.map(({ name, link, title }) => {
|
{items.map(({ name, link, title }) => {
|
||||||
if (link)
|
if (link)
|
||||||
@@ -91,7 +92,7 @@ const StyledSettingContainer: FC<PropsWithChildren<Props>> = ({
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{dangers.length ? (
|
{dangers.length ? (
|
||||||
<ul className="flex flex-col gap-2 mb-9 md:text-sm font-semibold text-red-500 dark:text-red-400">
|
<ul className="app-no-drag flex flex-col gap-2 mb-9 md:text-sm font-semibold text-red-500 dark:text-red-400">
|
||||||
{dangers.map((d) => {
|
{dangers.map((d) => {
|
||||||
if (typeof d === "boolean" || !d) return null;
|
if (typeof d === "boolean" || !d) return null;
|
||||||
const { title, handler } = d;
|
const { title, handler } = d;
|
||||||
@@ -110,6 +111,7 @@ const StyledSettingContainer: FC<PropsWithChildren<Props>> = ({
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
"app-drag",
|
||||||
"relative bg-white w-full max-h-full overflow-auto px-4 md:px-8 py-2 md:py-8 dark:bg-gray-700",
|
"relative bg-white w-full max-h-full overflow-auto px-4 md:px-8 py-2 md:py-8 dark:bg-gray-700",
|
||||||
!nav ? "hidden md:block" : "!pb-4"
|
!nav ? "hidden md:block" : "!pb-4"
|
||||||
)}
|
)}
|
||||||
@@ -121,7 +123,7 @@ const StyledSettingContainer: FC<PropsWithChildren<Props>> = ({
|
|||||||
</h4>
|
</h4>
|
||||||
)}
|
)}
|
||||||
{/* <ErrorCatcher> */}
|
{/* <ErrorCatcher> */}
|
||||||
{children}
|
<div className="app-no-drag">{children}</div>
|
||||||
{/* </ErrorCatcher> */}
|
{/* </ErrorCatcher> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const GuestBlankPlaceholder = () => {
|
|||||||
};
|
};
|
||||||
const qrUrl = BASE_ORIGIN;
|
const qrUrl = BASE_ORIGIN;
|
||||||
return (
|
return (
|
||||||
<section className="flex flex-col items-center text-center">
|
<section className="flex flex-col items-center text-center app-no-drag">
|
||||||
<h2 className="text-3xl text-gray-600 dark:text-gray-50 font-bold">
|
<h2 className="text-3xl text-gray-600 dark:text-gray-50 font-bold">
|
||||||
{t("welcome", { name: serverName })}
|
{t("welcome", { name: serverName })}
|
||||||
</h2>
|
</h2>
|
||||||
|
|||||||
@@ -94,10 +94,10 @@ const Layout: FC<Props> = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ImagePreview container={messagesContainer.current} />
|
<ImagePreview container={messagesContainer.current} />
|
||||||
<section ref={drop} className={`relative h-full w-full rounded-r-2xl flex`}>
|
<section ref={drop} className={`app-no-drag relative h-full w-full rounded-r-2xl flex`}>
|
||||||
<main className="flex flex-col flex-1">
|
<main className="app-drag flex flex-col flex-1">
|
||||||
{header}
|
{header}
|
||||||
<div className="w-full h-full flex items-start justify-between relative">
|
<div className="app-no-drag w-full h-full flex items-start justify-between relative">
|
||||||
<div
|
<div
|
||||||
className="rounded-br-2xl flex flex-col absolute bottom-0 w-full h-full"
|
className="rounded-br-2xl flex flex-col absolute bottom-0 w-full h-full"
|
||||||
ref={messagesContainer}
|
ref={messagesContainer}
|
||||||
@@ -125,7 +125,7 @@ const Layout: FC<Props> = ({
|
|||||||
{aside && (
|
{aside && (
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"flex z-50 p-3 absolute right-0 top-14 md:right-0 md:top-0 md:translate-x-full flex-col"
|
"app-no-drag flex z-50 p-3 absolute right-0 top-14 md:right-0 md:top-0 md:translate-x-full flex-col"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{aside}
|
{aside}
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ const VoiceFullscreen = ({ id, context }: Props) => {
|
|||||||
const membersData = voicingMembers.byId;
|
const membersData = voicingMembers.byId;
|
||||||
const hasPin = typeof pinUid !== "undefined";
|
const hasPin = typeof pinUid !== "undefined";
|
||||||
return (
|
return (
|
||||||
<div className="h-full bg-black text-gray-300 flex flex-col justify-between rounded-r-2xl">
|
<div className="app-no-drag h-full bg-black text-gray-300 flex flex-col justify-between rounded-r-2xl">
|
||||||
{/* top */}
|
{/* top */}
|
||||||
<div className="px-7 py-6 flex justify-between">
|
<div className="app-drag px-7 py-6 flex justify-between">
|
||||||
<span className="text-sm font-semibold">{_name}</span>
|
<span className="text-sm font-semibold">{_name}</span>
|
||||||
</div>
|
</div>
|
||||||
{/* middle */}
|
{/* middle */}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ function ChatPage() {
|
|||||||
{usersModalVisible && <UsersModal closeModal={toggleUsersModalVisible} />}
|
{usersModalVisible && <UsersModal closeModal={toggleUsersModalVisible} />}
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
"app-drag",
|
||||||
`flex h-screen md:h-full md:pt-2 md:pb-2.5 md:pr-1`,
|
`flex h-screen md:h-full md:pt-2 md:pb-2.5 md:pr-1`,
|
||||||
isGuest ? "guest-container md:px-1" : "md:pr-12"
|
isGuest ? "guest-container md:px-1" : "md:pr-12"
|
||||||
)}
|
)}
|
||||||
@@ -89,7 +90,7 @@ function ChatPage() {
|
|||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"left-container flex-col md:rounded-l-2xl w-full h-screen md:h-full md:max-w-[250px] md:min-w-[268px] shadow-[rgb(0_0_0_/_10%)_-1px_0px_0px_inset] bg-white dark:!bg-gray-800",
|
"left-container app-no-drag flex-col md:rounded-l-2xl w-full h-screen md:h-full md:max-w-[250px] md:min-w-[268px] shadow-[rgb(0_0_0_/_10%)_-1px_0px_0px_inset] bg-white dark:!bg-gray-800",
|
||||||
isMainPath ? "flex" : "hidden md:flex"
|
isMainPath ? "flex" : "hidden md:flex"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -99,6 +100,7 @@ function ChatPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
"app-drag",
|
||||||
`right-container md:rounded-r-2xl w-full bg-white dark:!bg-gray-700`,
|
`right-container md:rounded-r-2xl w-full bg-white dark:!bg-gray-700`,
|
||||||
placeholderVisible && "h-full flex-center",
|
placeholderVisible && "h-full flex-center",
|
||||||
isMainPath && "hidden md:flex"
|
isMainPath && "hidden md:flex"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type Props = {};
|
|||||||
const Menu: FC<Props> = () => {
|
const Menu: FC<Props> = () => {
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
return (
|
return (
|
||||||
<ul className="flex flex-col absolute left-0 bottom-0 w-full px-3 py-2">
|
<ul className="app-no-drag flex flex-col absolute left-0 bottom-0 w-full px-3 py-2">
|
||||||
<li className="cursor-pointer flex items-center p-2.5 gap-2.5 link_navs">
|
<li className="cursor-pointer flex items-center p-2.5 gap-2.5 link_navs">
|
||||||
<NavLink className="link" to={`/setting/overview?f=${pathname}`}>
|
<NavLink className="link" to={`/setting/overview?f=${pathname}`}>
|
||||||
<Tooltip placement="right" tip="Settings">
|
<Tooltip placement="right" tip="Settings">
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const User: FC<Props> = ({ uid }) => {
|
|||||||
if (!user) return null;
|
if (!user) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-3 py-2.5 invisible md:visible">
|
<div className="app-no-drag px-3 py-2.5 invisible md:visible">
|
||||||
<NavLink to={`/setting/my_account?f=${pathname}`}>
|
<NavLink to={`/setting/my_account?f=${pathname}`}>
|
||||||
<div className="w-8 h-8">
|
<div className="w-8 h-8">
|
||||||
<Avatar
|
<Avatar
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ function HomePage() {
|
|||||||
>
|
>
|
||||||
{!guest && (
|
{!guest && (
|
||||||
<div
|
<div
|
||||||
className={`hidden md:flex h-full flex-col items-center relative w-16 transition-all`}
|
className={`app-drag hidden md:flex h-full flex-col items-center relative w-16 transition-all`}
|
||||||
>
|
>
|
||||||
{loginUid && <User uid={loginUid} />}
|
{loginUid && <User uid={loginUid} />}
|
||||||
<nav className="flex flex-col gap-1 px-3 py-6">
|
<nav className="app-no-drag flex flex-col gap-1 px-3 my-6">
|
||||||
<NavLink
|
<NavLink
|
||||||
className={({ isActive }) =>
|
className={({ isActive }) =>
|
||||||
`${linkClass} ${
|
`${linkClass} ${
|
||||||
|
|||||||
Reference in New Issue
Block a user