fix: render toolbar via portal to body so it stays visible in fullscreen
This commit is contained in:
1 parent
2a727b2a71
commit
e464fac102
1 file changed
+21
-8
@@ -3,7 +3,13 @@
|
||||
import { LogOut } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { signOut } from "next-auth/react";
|
||||
import { type ReactNode, useCallback, useEffect, useState } from "react";
|
||||
import {
|
||||
type ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useState,
|
||||
} from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
|
||||
function ToolbarBtn({
|
||||
onClick,
|
||||
@@ -91,12 +97,11 @@ export function ClientView({
|
||||
const sep = base.includes("?") ? "&" : "?";
|
||||
const clientSrc = `${base}${sep}sso=${encodeURIComponent(ticket)}`;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="relative w-screen h-screen overflow-hidden"
|
||||
style={{ backgroundColor: "var(--color-background)" }}
|
||||
>
|
||||
<div className="fixed top-2 sm:top-4 left-2 sm:left-4 z-50 flex items-center gap-1 sm:gap-2">
|
||||
const [mounted, setMounted] = useState(false);
|
||||
useEffect(() => { setMounted(true); }, []);
|
||||
|
||||
const toolbar = (
|
||||
<div className="fixed top-2 sm:top-4 left-2 sm:left-4 z-[9999] flex items-center gap-1 sm:gap-2">
|
||||
<ToolbarBtn href="/" title="Home">
|
||||
<svg
|
||||
width="14"
|
||||
@@ -188,13 +193,21 @@ export function ClientView({
|
||||
<LogOut size={14} />
|
||||
</ToolbarBtn>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="relative w-screen h-screen overflow-hidden"
|
||||
style={{ backgroundColor: "var(--color-background)" }}
|
||||
>
|
||||
{mounted && createPortal(toolbar, document.body)}
|
||||
|
||||
<iframe
|
||||
id="nitro"
|
||||
src={clientSrc}
|
||||
className="absolute inset-0 w-full h-full border-0 m-0 p-0 overflow-hidden"
|
||||
title={hotelName}
|
||||
allow="autoplay; fullscreen; gamepad"
|
||||
allow="autoplay; gamepad"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user