From 42f9f90c5eac1f94c5da6e49bc683bf35b72dcfa Mon Sep 17 00:00:00 2001 From: karelklima Date: Mon, 13 Nov 2023 23:03:32 +0100 Subject: [PATCH] Fixed home active link --- www/components/Header.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/www/components/Header.tsx b/www/components/Header.tsx index 7ee506b..7ca4dc6 100644 --- a/www/components/Header.tsx +++ b/www/components/Header.tsx @@ -65,14 +65,19 @@ function Menu() { const baseLinkClass = "table-cell align-middle h-14 px-4 border-b-2 hover:border-black dark:hover:border-red-700 dark:hover:text-white border-transparent"; -const activeLinkClass = +const activeCurrentLinkClass = + `${baseLinkClass} [data-current]:border-black [data-current]:dark:border-red-700 [data-current]:bg-gray-50 [data-current]:dark:bg-gray-800`; + +const activeAncestorLinkClass = `${baseLinkClass} [data-ancestor]:border-black [data-ancestor]:dark:border-red-700 [data-ancestor]:bg-gray-50 [data-ancestor]:dark:bg-gray-800`; function Link({ url, children }: { url: string; children: ComponentChildren; }) { - const linkClass = url === "/" ? baseLinkClass : activeLinkClass; + const linkClass = url === "/" + ? activeCurrentLinkClass + : activeAncestorLinkClass; return (