Skip to content

Commit

Permalink
Fixed home active link
Browse files Browse the repository at this point in the history
  • Loading branch information
karelklima committed Nov 13, 2023
1 parent 01e149e commit 42f9f90
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions www/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<li>
<a href={url} class={linkClass}>
Expand Down

0 comments on commit 42f9f90

Please sign in to comment.