mirror of
https://github.com/streamwall/streamwall.git
synced 2025-12-06 01:45:37 -05:00
I wasn't able to get this fully working, IIRC; the challenge was getting the webpack build for web stuff to happen reliably.
46 lines
873 B
JavaScript
46 lines
873 B
JavaScript
import { h, render } from 'preact'
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
import styled from 'styled-components'
|
|
|
|
import '../index.css'
|
|
|
|
function Background({ streams }) {
|
|
const backgrounds = streams.filter((s) => s.kind === 'background')
|
|
return (
|
|
<div>
|
|
{backgrounds.map((s) => (
|
|
<BackgroundIFrame
|
|
key={s._id}
|
|
src={s.link}
|
|
sandbox="allow-scripts allow-same-origin"
|
|
allow="autoplay"
|
|
/>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function App() {
|
|
const [state, setState] = useState({
|
|
streams: [],
|
|
})
|
|
|
|
useEffect(() => {
|
|
streamwall.onState(setState)
|
|
}, [])
|
|
|
|
const { streams } = state
|
|
return <Background streams={streams} />
|
|
}
|
|
|
|
const BackgroundIFrame = styled.iframe`
|
|
position: fixed;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
border: none;
|
|
`
|
|
|
|
render(<App />, document.body)
|