From c9bf2ca2a6521cf6949641b8546cfd0ddb06b2dc Mon Sep 17 00:00:00 2001 From: Max Goodhart Date: Mon, 27 Jul 2020 14:33:33 -0700 Subject: [PATCH] Make stream list scrollable --- src/web/control.js | 196 ++++++++++++++++++++++++++------------------- 1 file changed, 115 insertions(+), 81 deletions(-) diff --git a/src/web/control.js b/src/web/control.js index e74d44e..9006671 100644 --- a/src/web/control.js +++ b/src/web/control.js @@ -7,7 +7,7 @@ import { patch as patchJSON } from 'jsondiffpatch' import { h, Fragment, render } from 'preact' import { useEffect, useState, useCallback, useRef } from 'preact/hooks' import { State } from 'xstate' -import styled, { css } from 'styled-components' +import styled, { createGlobalStyle } from 'styled-components' import { useHotkeys } from 'react-hotkeys-hook' import '../index.css' @@ -42,6 +42,17 @@ const hotkeyTriggers = [ 'p', ] +const GlobalStyle = createGlobalStyle` + html { + height: 100%; + } + + html, body { + display: flex; + flex: 1; + } +` + function useYDoc(keys) { const [doc, setDoc] = useState(new Y.Doc()) const [docValue, setDocValue] = useState() @@ -376,94 +387,111 @@ function App({ wsEndpoint }) { ) return ( -
-

Streamwall ({location.host})

-
- connection status: {isConnected ? 'connected' : 'connecting...'} -
- {delayState && ( - - )} - + + +

Streamwall ({location.host})

- {range(0, gridCount).map((y) => ( - - {range(0, gridCount).map((x) => { - const idx = gridCount * y + x - const { isListening = false, isBlurred = false, state } = - stateIdxMap.get(idx) || {} - const { streamId } = sharedState.views?.[idx] || '' - const isDragHighlighted = - dragStart !== undefined && - idxInBox(gridCount, dragStart, dragEnd, idx) - return ( - - ) - })} - - ))} + connection status: {isConnected ? 'connected' : 'connecting...'}
- -
- {isConnected - ? normalStreams.map((row) => ( - - )) - : 'loading...'} -
-

Custom Streams

-
- {/* + )} + +
+ {range(0, gridCount).map((y) => ( + + {range(0, gridCount).map((x) => { + const idx = gridCount * y + x + const { isListening = false, isBlurred = false, state } = + stateIdxMap.get(idx) || {} + const { streamId } = sharedState.views?.[idx] || '' + const isDragHighlighted = + dragStart !== undefined && + idxInBox(gridCount, dragStart, dragEnd, idx) + return ( + + ) + })} + + ))} +
+ +
+ + + +
+ {isConnected + ? normalStreams.map((row) => ( + + )) + : 'loading...'} +
+

Custom Streams

+
+ {/* Include an empty object at the end to create an extra input for a new custom stream. We need it to be part of the array (rather than JSX below) for DOM diffing to match the key and retain focus. */} - {[...customStreams, { link: '', label: '', kind: 'video' }].map( - ({ link, label, kind }, idx) => ( - - ), - )} -
-
-
+ {[...customStreams, { link: '', label: '', kind: 'video' }].map( + ({ link, label, kind }, idx) => ( + + ), + )} +
+ + + ) } +const Stack = styled.div` + display: flex; + flex-direction: column; + flex: ${({ flex }) => flex}; + ${({ scroll }) => scroll && `overflow-y: auto`}; +` + function StreamDelayBox({ delayState, setStreamCensored }) { const handleToggleStreamCensored = useCallback(() => { setStreamCensored(!delayState.isCensored) @@ -805,7 +833,13 @@ const StyledStreamLine = styled.div` function main() { const script = document.getElementById('main-script') - render(, document.body) + render( + <> + + + , + document.body, + ) } main()