Skip to content

Commit 6822b51

Browse files
committed
Add current page indicator
1 parent 0c9d26f commit 6822b51

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/NavBar.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useTranslation } from 'react-i18next'
2+
import { useLocation } from 'react-router-dom'
23
import { Link } from 'react-router-dom'
34
import { useSurvey } from './hooks/useSurvey'
45
import {
@@ -11,12 +12,18 @@ import {
1112
Avatar
1213
} from '@mui/material'
1314
import { LanguageSelector } from './LanguageSelector';
15+
import { ReactElement } from 'react'
1416
const 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>

src/i18n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import i18n from 'i18next'
22
import i18nBackend from 'i18next-http-backend'
33
import { initReactI18next } from 'react-i18next'
44

5-
const getCurrentHost = process.env.NODE_ENV === 'development' ? 'http://localhost:5174': 'https://www.webdevtalks.mx'
5+
const getCurrentHost = process.env.NODE_ENV === 'development' ? 'http://localhost:5173': 'https://www.webdevtalks.mx'
66
i18n.use(i18nBackend)
77
.use(initReactI18next)
88
.init({

src/theme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const theme = createTheme({
44
palette: {
55
primary: {
66
main: '#1c1c17',
7+
hover: '',
78
},
89
secondary: {
910
main: '#3298cc',

0 commit comments

Comments
 (0)