Files
streamwall/src/renderer/background.js
Max Goodhart cf73dcf604 WIP attempt to wire up electron-forge
I wasn't able to get this fully working, IIRC; the challenge was getting
the webpack build for web stuff to happen reliably.
2024-08-19 17:50:50 -07:00

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)