mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Fix Connect dialog closing on text-selection drag; add mobile layout
Backdrop click-to-close now requires the mousedown to also start on the backdrop, so selecting text inside any dialog and releasing the drag outside it no longer closes the dialog. Add a responsive breakpoint that stacks the tree/side/chat panels and dialogs into a single column on narrow viewports instead of clipping the fixed-width desktop layout.
This commit is contained in:
1 parent
42f82d49aa
commit
fcbf3ea40d
2 files changed
+158
-5
No files matched your search
+134
@@ -1252,3 +1252,137 @@
|
||||
.ts-poke-notice button:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Mobile layout */
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.ts-menubar {
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ts-toolbar {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.ts-toolbar-icons {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 0.3rem;
|
||||
}
|
||||
|
||||
.ts-icon-slider input[type="range"] {
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.ts-icon-select select {
|
||||
max-width: 110px;
|
||||
}
|
||||
|
||||
.ts-app-logo {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.ts-toolbar-fields {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 0.4rem;
|
||||
}
|
||||
|
||||
.ts-toolbar-fields input:not([type="range"]),
|
||||
.ts-toolbar-fields select {
|
||||
max-width: 40vw;
|
||||
}
|
||||
|
||||
.ts-body {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.ts-upper {
|
||||
height: auto !important;
|
||||
flex-direction: column;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.ts-tree-panel {
|
||||
width: 100% !important;
|
||||
max-height: 35vh;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.ts-resize-handle-vertical,
|
||||
.ts-resize-handle-horizontal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ts-side-panel {
|
||||
max-height: 40vh;
|
||||
}
|
||||
|
||||
.ts-banner-panel {
|
||||
max-height: 25vh;
|
||||
}
|
||||
|
||||
.ts-chat-panel {
|
||||
min-height: 260px;
|
||||
}
|
||||
|
||||
.ts-chat-tabs {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
.ts-dialog {
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.ts-connect-dialog,
|
||||
.ts-favorites-dialog,
|
||||
.ts-away-dialog,
|
||||
.ts-options-dialog {
|
||||
width: 92vw !important;
|
||||
}
|
||||
|
||||
.ts-dialog-row {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.ts-dialog-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.ts-favorites-body,
|
||||
.ts-options-body {
|
||||
flex-direction: column;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.ts-favorites-list-col,
|
||||
.ts-favorites-profile-col {
|
||||
width: 100%;
|
||||
border-right: none;
|
||||
border-left: none;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.ts-options-sidebar {
|
||||
width: 100%;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.ts-options-columns {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.ts-poke-compose {
|
||||
flex-wrap: wrap;
|
||||
max-width: 92vw;
|
||||
}
|
||||
|
||||
.ts-poke-compose input {
|
||||
min-width: 160px;
|
||||
}
|
||||
}
|
||||
+24
-5
@@ -1,5 +1,19 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import "./App.css";
|
||||
|
||||
/** Only dismiss on a genuine backdrop click, not a text-selection drag that
|
||||
* starts inside the dialog and releases over the backdrop. */
|
||||
function useBackdropDismiss(onDismiss: () => void) {
|
||||
const mouseDownOnBackdrop = useRef(false);
|
||||
return {
|
||||
onMouseDown: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
mouseDownOnBackdrop.current = e.target === e.currentTarget;
|
||||
},
|
||||
onClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (mouseDownOnBackdrop.current && e.target === e.currentTarget) onDismiss();
|
||||
},
|
||||
};
|
||||
}
|
||||
import {
|
||||
AudioPlayer,
|
||||
MicCapture,
|
||||
@@ -430,8 +444,9 @@ function ConnectDialog({
|
||||
onCancel: () => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const backdrop = useBackdropDismiss(onCancel);
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" onClick={onCancel}>
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
<div className="ts-dialog ts-connect-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="ts-dialog-titlebar">
|
||||
<span>{t("connect.title")}</span>
|
||||
@@ -590,8 +605,9 @@ function FavoritesDialog({
|
||||
setSelectedId(null);
|
||||
};
|
||||
|
||||
const backdrop = useBackdropDismiss(onClose);
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" onClick={onClose}>
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
<div className="ts-dialog ts-favorites-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="ts-dialog-titlebar">
|
||||
<span>{t("favorites.title")}</span>
|
||||
@@ -763,8 +779,9 @@ function AwayDialog({
|
||||
onCancel: () => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const backdrop = useBackdropDismiss(onCancel);
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" onClick={onCancel}>
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
<div className="ts-dialog ts-away-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="ts-dialog-titlebar">
|
||||
<span>{t("away.dialog.title")}</span>
|
||||
@@ -1302,8 +1319,9 @@ function OptionsDialog({
|
||||
}) {
|
||||
const t = useT();
|
||||
const active = OPTIONS_SECTIONS.find((s) => s.id === section) ?? OPTIONS_SECTIONS[0];
|
||||
const backdrop = useBackdropDismiss(onClose);
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" onClick={onClose}>
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
<div className="ts-dialog ts-options-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="ts-dialog-titlebar">
|
||||
<span>{t("options.title")}</span>
|
||||
@@ -1385,6 +1403,7 @@ function AppInner() {
|
||||
const [pokes, setPokes] = useState<PokeNotice[]>([]);
|
||||
const [pokeTarget, setPokeTarget] = useState<{ id: number; name: string } | null>(null);
|
||||
const [pokeMessage, setPokeMessage] = useState("");
|
||||
const pokeBackdrop = useBackdropDismiss(() => setPokeTarget(null));
|
||||
const [activeTab, setActiveTab] = useState<ActiveTab>("channel");
|
||||
const [theme, setTheme] = useState<"light" | "dark">(() =>
|
||||
window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
||||
@@ -2519,7 +2538,7 @@ function AppInner() {
|
||||
)}
|
||||
|
||||
{pokeTarget && (
|
||||
<div className="ts-poke-compose-backdrop" onClick={() => setPokeTarget(null)}>
|
||||
<div className="ts-poke-compose-backdrop" {...pokeBackdrop}>
|
||||
<div className="ts-poke-compose" onClick={(e) => e.stopPropagation()}>
|
||||
<span>
|
||||
👉 {t("poke.title")} <strong>{pokeTarget.name}</strong>
|
||||
|
||||
Reference in new issue
Block a user