2025-04-28 18:06:52 -04:00
|
|
|
import { useEffect, useState } from 'react';
|
2025-04-27 17:55:11 -04:00
|
|
|
import { NavLink } from 'react-router-dom';
|
|
|
|
import homeIcon from '../assets/icons/home.svg';
|
|
|
|
import cacheIcon from '../assets/icons/cache.svg';
|
|
|
|
import apiIcon from '../assets/icons/api.svg';
|
|
|
|
import testPlayerIcon from '../assets/icons/testplayer.svg';
|
|
|
|
import discordIcon from '../assets/icons/discord.svg';
|
|
|
|
import telegramIcon from '../assets/icons/telegram.svg';
|
|
|
|
import giteaIcon from '../assets/icons/gitea.svg';
|
|
|
|
|
|
|
|
function NavBar() {
|
2025-04-28 18:06:52 -04:00
|
|
|
const [externalLinks, setExternalLinks] = useState({
|
|
|
|
discord: '#',
|
|
|
|
telegram: '#',
|
|
|
|
gitea: '#',
|
|
|
|
});
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
fetch('/api/links')
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => setExternalLinks(data))
|
|
|
|
.catch(error => console.error('Error fetching links:', error));
|
|
|
|
}, []);
|
|
|
|
|
2025-04-27 17:55:11 -04:00
|
|
|
return (
|
|
|
|
<div className="flex flex-col w-full h-full bg-white/1">
|
|
|
|
<div>
|
2025-04-27 20:18:01 -04:00
|
|
|
<p className='text-white text-2xl font-bold p-3 text-center mb-5'>
|
2025-04-28 18:06:52 -04:00
|
|
|
<a href='/'>CDRM-Project</a>
|
2025-04-27 17:55:11 -04:00
|
|
|
</p>
|
|
|
|
</div>
|
2025-04-28 18:06:52 -04:00
|
|
|
|
2025-04-27 17:55:11 -04:00
|
|
|
<div className='overflow-y-auto grow'>
|
2025-04-28 18:06:52 -04:00
|
|
|
{/* Static routes */}
|
|
|
|
{[{
|
|
|
|
to: '/',
|
|
|
|
label: 'Home',
|
|
|
|
icon: homeIcon,
|
|
|
|
color: 'sky'
|
|
|
|
}, {
|
|
|
|
to: '/cache',
|
|
|
|
label: 'Cache',
|
|
|
|
icon: cacheIcon,
|
|
|
|
color: 'emerald'
|
|
|
|
}, {
|
|
|
|
to: '/api',
|
|
|
|
label: 'API',
|
|
|
|
icon: apiIcon,
|
|
|
|
color: 'indigo'
|
|
|
|
}, {
|
|
|
|
to: '/testplayer',
|
|
|
|
label: 'Test Player',
|
|
|
|
icon: testPlayerIcon,
|
|
|
|
color: 'rose-700'
|
|
|
|
}].map(({ to, label, icon, color }) => (
|
|
|
|
<NavLink
|
|
|
|
key={label}
|
|
|
|
to={to}
|
|
|
|
className={({ isActive }) =>
|
|
|
|
`flex flex-row p-3 border-l-3 ${
|
|
|
|
isActive
|
|
|
|
? `border-l-${color}-500/50 bg-black/50`
|
|
|
|
: `hover:border-l-${color}-500/50 hover:bg-white/5`
|
|
|
|
}`
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<button className='w-1/3 p-3 flex flex-col items-center justify-center cursor-pointer'>
|
|
|
|
<img src={icon} alt={label} className='w-1/2 cursor-pointer' />
|
|
|
|
</button>
|
|
|
|
<p className='grow text-white md:text-2xl font-bold flex items-center justify-start'>
|
|
|
|
{label}
|
|
|
|
</p>
|
|
|
|
</NavLink>
|
|
|
|
))}
|
2025-04-27 17:55:11 -04:00
|
|
|
</div>
|
2025-04-28 18:06:52 -04:00
|
|
|
|
|
|
|
{/* External links */}
|
2025-04-27 17:55:11 -04:00
|
|
|
<div className='flex flex-row w-full h-16 self-end bg-black/25'>
|
|
|
|
<a
|
2025-04-28 18:06:52 -04:00
|
|
|
href={externalLinks.discord}
|
2025-04-27 17:55:11 -04:00
|
|
|
target='_blank'
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
className='w-1/3 p-3 flex flex-col items-center justify-center cursor-pointer hover:bg-blue-950 group'
|
|
|
|
>
|
2025-04-28 18:06:52 -04:00
|
|
|
<img src={discordIcon} alt="Discord" className='w-1/2 group-hover:animate-bounce' />
|
2025-04-27 17:55:11 -04:00
|
|
|
</a>
|
|
|
|
<a
|
2025-04-28 18:06:52 -04:00
|
|
|
href={externalLinks.telegram}
|
2025-04-27 17:55:11 -04:00
|
|
|
target='_blank'
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
className='w-1/3 p-3 flex flex-col items-center justify-center cursor-pointer hover:bg-blue-400 group'
|
|
|
|
>
|
2025-04-28 18:06:52 -04:00
|
|
|
<img src={telegramIcon} alt="Telegram" className='w-1/2 group-hover:animate-bounce' />
|
2025-04-27 17:55:11 -04:00
|
|
|
</a>
|
|
|
|
<a
|
2025-04-28 18:06:52 -04:00
|
|
|
href={externalLinks.gitea}
|
2025-04-27 17:55:11 -04:00
|
|
|
target='_blank'
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
className='w-1/3 p-3 flex flex-col items-center justify-center cursor-pointer hover:bg-green-700 group'
|
|
|
|
>
|
2025-04-28 18:06:52 -04:00
|
|
|
<img src={giteaIcon} alt="Gitea" className='w-1/2 group-hover:animate-bounce' />
|
2025-04-27 17:55:11 -04:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default NavBar;
|