11import { useTranslation } from 'react-i18next'
2+ import { useLocation } from 'react-router-dom'
23import { Link } from 'react-router-dom'
34import { useSurvey } from './hooks/useSurvey'
45import {
@@ -11,12 +12,18 @@ import {
1112 Avatar
1213} from '@mui/material'
1314import { LanguageSelector } from './LanguageSelector' ;
15+ import { ReactElement } from 'react'
1416const LOGO = 'src/assets/images/logo.png'
1517
16- function NavBar ( { selected = null } ) {
18+ const NavBar = ( ) : ReactElement => {
19+ const location = useLocation ( )
1720 const { openSurvey } = useSurvey ( )
1821 const { t } = useTranslation ( )
1922
23+ const isActive = ( path : string ) : boolean => {
24+ return location . pathname . includes ( path )
25+ }
26+
2027 return (
2128 < >
2229 < AppBar position = "sticky" color = "default" >
@@ -26,12 +33,12 @@ function NavBar({ selected = null }) {
2633 < Avatar src = { LOGO } alt = "Logo WDT" sx = { { width : '100%' , height : '100%' , maxWidth : '50px' } } />
2734 </ Link >
2835 < Link to = "/sponsorship" style = { { textDecoration : 'none' , height : '100%' } } >
29- < Button sx = { { height : '100%' } } >
36+ < Button sx = { { height : '100%' , backgroundColor : isActive ( '/sponsorship' ) ? '#c1c1c1' : 'transparent' } } >
3037 < Typography > { t ( "navbar.sponsorship" , "¿Te interesa patrocinar?" ) } </ Typography >
3138 </ Button >
3239 </ Link >
3340 < Link to = "/about" style = { { textDecoration : 'none' , height : '100%' } } >
34- < Button sx = { { height : '100%' } } >
41+ < Button sx = { { height : '100%' , backgroundColor : isActive ( '/about' ) ? '#c1c1c1' : 'transparent' } } >
3542 < Typography > { t ( "navbar.aboutUs" , "Acerca de nosotros" ) } </ Typography >
3643 </ Button >
3744 </ Link >
0 commit comments