mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-02 01:12:49 +08:00
web: size popped-out stream tiles to the window, Discord-style
In the separate window the grid now picks the column count that makes the 16:9 tiles largest for the current window size and stream count, and re-picks on resize. The pop-out/back button moved from a bar above the grid into each tile header: in the corner the bar got pushed out of view once the tiles overflowed, and "align-content: end" made that overflow unreachable (now "safe end"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
8fbd591efa
commit
968a266684
2 files changed
+42
-24
No files matched your search
+1
-18
@@ -1670,30 +1670,13 @@
|
||||
z-index: 29;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--stream-cols, 1), minmax(0, 1fr));
|
||||
align-content: end;
|
||||
align-content: safe end;
|
||||
gap: 0.5rem;
|
||||
width: min(calc(var(--stream-cols, 1) * 480px), calc(100vw - 2rem));
|
||||
max-height: calc(100vh - 2rem);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.ts-stream-toolbar {
|
||||
grid-column: 1 / -1;
|
||||
order: -2;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.ts-stream-toolbar button {
|
||||
padding: 0.15rem 0.5rem;
|
||||
background: var(--bg-toolbar-1);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
color: inherit;
|
||||
font-size: 0.85em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ts-stream-panel-focused {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
+41
-6
@@ -9022,6 +9022,7 @@ function AppInner() {
|
||||
const [focusedStream, setFocusedStream] = useState<number | null>(null);
|
||||
/** Separate browser window the stream grid is portalled into, if popped out. */
|
||||
const [streamPopout, setStreamPopout] = useState<Window | null>(null);
|
||||
const [popoutSize, setPopoutSize] = useState({ width: 0, height: 0 });
|
||||
const [publishState, setPublishState] = useState<PublishState>("idle");
|
||||
const [publishViewers, setPublishViewers] = useState<number[]>([]);
|
||||
const [publishPending, setPublishPending] = useState<[number, string][]>([]);
|
||||
@@ -12169,6 +12170,9 @@ function AppInner() {
|
||||
...[...document.querySelectorAll('link[rel="stylesheet"], style')].map((node) => node.cloneNode(true)),
|
||||
);
|
||||
win.document.body.style.margin = "0";
|
||||
const measure = () => setPopoutSize({ width: win.innerWidth, height: win.innerHeight });
|
||||
measure();
|
||||
win.addEventListener("resize", measure);
|
||||
// Fires when the user closes the window; the grid then moves back in here.
|
||||
win.addEventListener("pagehide", () => setStreamPopout(null));
|
||||
setStreamPopout(win);
|
||||
@@ -12867,7 +12871,42 @@ function AppInner() {
|
||||
activeCustomTheme ? " ts-design-custom" : ""
|
||||
}`;
|
||||
|
||||
/**
|
||||
* Popped out and nothing focused: pick the column count that makes the 16:9
|
||||
* tiles largest for this window, like Discord's grid.
|
||||
*/
|
||||
const popoutGridStyle = ((): React.CSSProperties => {
|
||||
if (!streamPopout || focusedStream !== null) return {};
|
||||
const pad = 16, gap = 8, header = 30; // px: grid padding, gap, tile header
|
||||
const width = popoutSize.width - pad;
|
||||
const height = popoutSize.height - pad;
|
||||
let best = { cols: 1, tile: 0 };
|
||||
for (let cols = 1; cols <= streamTileCount; cols++) {
|
||||
const rows = Math.ceil(streamTileCount / cols);
|
||||
const tile = Math.min(
|
||||
(width - gap * (cols - 1)) / cols,
|
||||
((height - gap * (rows - 1)) / rows - header) * (16 / 9),
|
||||
);
|
||||
if (tile > best.tile) best = { cols, tile };
|
||||
}
|
||||
return {
|
||||
gridTemplateColumns: `repeat(${best.cols}, ${Math.max(160, Math.floor(best.tile))}px)`,
|
||||
justifyContent: "center",
|
||||
alignContent: "center",
|
||||
minHeight: "100vh",
|
||||
boxSizing: "border-box",
|
||||
};
|
||||
})();
|
||||
|
||||
const streamToggle = (id: number) => (
|
||||
<>
|
||||
<button
|
||||
className="ts-stream-panel-close"
|
||||
onClick={streamPopout ? closeStreamPopout : openStreamPopout}
|
||||
title={t(streamPopout ? "stream.popin" : "stream.popout")}
|
||||
>
|
||||
{streamPopout ? "⇲" : "⧉"}
|
||||
</button>
|
||||
<button
|
||||
className="ts-stream-panel-close"
|
||||
onClick={() => setFocusedStream((cur) => (cur === id ? null : id))}
|
||||
@@ -12875,6 +12914,7 @@ function AppInner() {
|
||||
>
|
||||
{focusedStream === id ? "⤡" : "⤢"}
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -14329,13 +14369,8 @@ function AppInner() {
|
||||
const grid = (
|
||||
<div
|
||||
className={`ts-stream-panels${streamPopout ? " ts-stream-panels-popout" : ""}`}
|
||||
style={{ "--stream-cols": Math.min(streamTileCount, 2) } as React.CSSProperties}
|
||||
style={{ "--stream-cols": Math.min(streamTileCount, 2), ...popoutGridStyle } as React.CSSProperties}
|
||||
>
|
||||
<div className="ts-stream-toolbar">
|
||||
<button onClick={streamPopout ? closeStreamPopout : openStreamPopout}>
|
||||
{streamPopout ? `⇲ ${t("stream.popin")}` : `⧉ ${t("stream.popout")}`}
|
||||
</button>
|
||||
</div>
|
||||
{publishState !== "idle" && publishState !== "stopped" && (
|
||||
<div className={`ts-stream-panel ts-stream-panel-publish${focusedStream === -1 ? " ts-stream-panel-focused" : ""}`}>
|
||||
<div className="ts-stream-panel-header">
|
||||
|
||||
Reference in new issue
Block a user