diff --git a/web/src/App.css b/web/src/App.css index 3640992..fb3c326 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -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; } diff --git a/web/src/App.tsx b/web/src/App.tsx index 9030cb3..2c6dc49 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -9022,6 +9022,7 @@ function AppInner() { const [focusedStream, setFocusedStream] = useState(null); /** Separate browser window the stream grid is portalled into, if popped out. */ const [streamPopout, setStreamPopout] = useState(null); + const [popoutSize, setPopoutSize] = useState({ width: 0, height: 0 }); const [publishState, setPublishState] = useState("idle"); const [publishViewers, setPublishViewers] = useState([]); 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) => ( + <> + + ); return ( @@ -14329,13 +14369,8 @@ function AppInner() { const grid = (
-
- -
{publishState !== "idle" && publishState !== "stopped" && (