From d745c1f97fe1d9ff039b020a29c4e331fa377752 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Tue, 4 Jun 2024 12:08:39 +0200 Subject: [PATCH] embedded url parameter to hide navbar --- src/Components/AppShell/NavBar.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Components/AppShell/NavBar.tsx b/src/Components/AppShell/NavBar.tsx index df0c1e10..c24e9394 100644 --- a/src/Components/AppShell/NavBar.tsx +++ b/src/Components/AppShell/NavBar.tsx @@ -1,5 +1,5 @@ import { useAuth } from "../Auth" -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import { toast } from "react-toastify"; import QuestionMarkIcon from '@heroicons/react/24/outline/QuestionMarkCircleIcon' import { useEffect, useRef, useState } from "react"; @@ -31,6 +31,16 @@ export default function NavBar({ appName}: { appName: string }) { nameRef && setNameWidth(nameRef.current.scrollWidth) }, [nameRef, appName]) + const location = useLocation(); + + const [showNav, setShowNav] = useState(true) + + + useEffect(() => { + let params = new URLSearchParams(location.search); + let embedded = params.get("embedded"); + embedded=="true" && setShowNav(false) + }, [location]); const onLogout = () => { @@ -53,7 +63,7 @@ export default function NavBar({ appName}: { appName: string }) { }); } - return ( + if(showNav) return ( <>