diff --git a/frontend/components/BottomRightPanel.js b/frontend/components/BottomRightPanel.js index a3272e06a..76d7dd40f 100644 --- a/frontend/components/BottomRightPanel.js +++ b/frontend/components/BottomRightPanel.js @@ -78,6 +78,35 @@ export let BottomRightPanel = ({ const my_clock_is_ahead_by = useMyClockIsAheadBy({ connected }) + const on_popout_click = async () => { + // Open a Picture-in-Picture window, see https://developer.chrome.com/docs/web-platform/document-picture-in-picture/ + // @ts-ignore + const pip_window = await documentPictureInPicture.requestWindow() + + // Copy style sheets + ;[...document.styleSheets].forEach((styleSheet) => { + try { + const style = document.createElement("style") + style.textContent = [...styleSheet.cssRules].map((rule) => rule.cssText).join("") + pip_window.document.head.appendChild(style) + } catch (e) { + const link = document.createElement("link") + link.rel = "stylesheet" + link.type = styleSheet.type + // @ts-ignore + link.media = styleSheet.media + // @ts-ignore + link.href = styleSheet.href + pip_window.document.head.appendChild(link) + } + }) + pip_window.document.body.append(container_ref.current.firstElementChild) + pip_window.addEventListener("pagehide", (event) => { + const pipPlayer = event.target.querySelector("pluto-helpbox") + container_ref.current.append(pipPlayer) + }) + } + return html`