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