mirror of
https://github.com/streamwall/streamwall.git
synced 2026-04-15 10:12:03 -04:00
Make stream list scrollable
This commit is contained in:
@@ -7,7 +7,7 @@ import { patch as patchJSON } from 'jsondiffpatch'
|
|||||||
import { h, Fragment, render } from 'preact'
|
import { h, Fragment, render } from 'preact'
|
||||||
import { useEffect, useState, useCallback, useRef } from 'preact/hooks'
|
import { useEffect, useState, useCallback, useRef } from 'preact/hooks'
|
||||||
import { State } from 'xstate'
|
import { State } from 'xstate'
|
||||||
import styled, { css } from 'styled-components'
|
import styled, { createGlobalStyle } from 'styled-components'
|
||||||
import { useHotkeys } from 'react-hotkeys-hook'
|
import { useHotkeys } from 'react-hotkeys-hook'
|
||||||
|
|
||||||
import '../index.css'
|
import '../index.css'
|
||||||
@@ -42,6 +42,17 @@ const hotkeyTriggers = [
|
|||||||
'p',
|
'p',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const GlobalStyle = createGlobalStyle`
|
||||||
|
html {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
function useYDoc(keys) {
|
function useYDoc(keys) {
|
||||||
const [doc, setDoc] = useState(new Y.Doc())
|
const [doc, setDoc] = useState(new Y.Doc())
|
||||||
const [docValue, setDocValue] = useState()
|
const [docValue, setDocValue] = useState()
|
||||||
@@ -376,7 +387,8 @@ function App({ wsEndpoint }) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Stack flex="1">
|
||||||
|
<Stack>
|
||||||
<h1>Streamwall ({location.host})</h1>
|
<h1>Streamwall ({location.host})</h1>
|
||||||
<div>
|
<div>
|
||||||
connection status: {isConnected ? 'connected' : 'connecting...'}
|
connection status: {isConnected ? 'connected' : 'connecting...'}
|
||||||
@@ -433,10 +445,18 @@ function App({ wsEndpoint }) {
|
|||||||
/>
|
/>
|
||||||
Show stream debug tools
|
Show stream debug tools
|
||||||
</label>
|
</label>
|
||||||
|
</StyledDataContainer>
|
||||||
|
</Stack>
|
||||||
|
<Stack flex="1" scroll={true}>
|
||||||
|
<StyledDataContainer isConnected={isConnected}>
|
||||||
<div>
|
<div>
|
||||||
{isConnected
|
{isConnected
|
||||||
? normalStreams.map((row) => (
|
? normalStreams.map((row) => (
|
||||||
<StreamLine id={row._id} row={row} onClickId={handleClickId} />
|
<StreamLine
|
||||||
|
id={row._id}
|
||||||
|
row={row}
|
||||||
|
onClickId={handleClickId}
|
||||||
|
/>
|
||||||
))
|
))
|
||||||
: 'loading...'}
|
: 'loading...'}
|
||||||
</div>
|
</div>
|
||||||
@@ -460,10 +480,18 @@ function App({ wsEndpoint }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</StyledDataContainer>
|
</StyledDataContainer>
|
||||||
</div>
|
</Stack>
|
||||||
|
</Stack>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Stack = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: ${({ flex }) => flex};
|
||||||
|
${({ scroll }) => scroll && `overflow-y: auto`};
|
||||||
|
`
|
||||||
|
|
||||||
function StreamDelayBox({ delayState, setStreamCensored }) {
|
function StreamDelayBox({ delayState, setStreamCensored }) {
|
||||||
const handleToggleStreamCensored = useCallback(() => {
|
const handleToggleStreamCensored = useCallback(() => {
|
||||||
setStreamCensored(!delayState.isCensored)
|
setStreamCensored(!delayState.isCensored)
|
||||||
@@ -805,7 +833,13 @@ const StyledStreamLine = styled.div`
|
|||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
const script = document.getElementById('main-script')
|
const script = document.getElementById('main-script')
|
||||||
render(<App wsEndpoint={script.dataset.wsEndpoint} />, document.body)
|
render(
|
||||||
|
<>
|
||||||
|
<GlobalStyle />
|
||||||
|
<App wsEndpoint={script.dataset.wsEndpoint} />
|
||||||
|
</>,
|
||||||
|
document.body,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user