From f9082223d77b09561c535820ae5533d13c4a1b53 Mon Sep 17 00:00:00 2001 From: Jacopo Gasparetto <jacopo.gasparetto@cnaf.infn.it> Date: Thu, 6 Apr 2023 12:27:30 +0200 Subject: [PATCH] Add hover on current path selection to sidebar --- frontend/src/components/Drawer.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Drawer.tsx b/frontend/src/components/Drawer.tsx index bd6a31b..8e9a44f 100644 --- a/frontend/src/components/Drawer.tsx +++ b/frontend/src/components/Drawer.tsx @@ -1,13 +1,14 @@ -import React from 'react'; import { routes } from '../routes'; import { Link } from 'react-router-dom'; export const Drawer = () => { - + const path = window.location.pathname; const links = routes.map(route => { + let className = "h-10 hover:bg-neutral-300 rounded-lg p-2"; + className += route.path === path ? " bg-neutral-200" : ""; return ( - <li key={route.path}> - <Link to={route.path}>{route.title}</Link> + <li className={className} key={route.path}> + <Link className="block h-10" to={route.path}>{route.title}</Link> </li> ) }); -- GitLab