Files
omni-tools/src/components/Navbar/index.tsx

130 lines
3.5 KiB
TypeScript
Raw Normal View History

2024-06-26 00:29:53 +01:00
import React, { useState } from 'react';
2024-06-19 19:10:14 +01:00
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import Button from '@mui/material/Button';
import IconButton from '@mui/material/IconButton';
2024-06-26 00:29:53 +01:00
import MenuIcon from '@mui/icons-material/Menu';
2024-06-22 22:06:16 +01:00
import { Link, useNavigate } from 'react-router-dom';
2025-02-23 14:11:21 +00:00
import logo from 'assets/logo.png';
2024-06-26 00:29:53 +01:00
import {
Drawer,
List,
2024-06-26 09:02:05 +01:00
ListItemButton,
2024-06-26 00:29:53 +01:00
ListItemText,
2024-06-26 09:02:05 +01:00
Stack
2024-06-26 00:29:53 +01:00
} from '@mui/material';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTheme } from '@mui/material/styles';
2024-06-19 19:10:14 +01:00
const Navbar: React.FC = () => {
2024-06-19 19:38:26 +01:00
const navigate = useNavigate();
2024-06-26 00:29:53 +01:00
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
const [drawerOpen, setDrawerOpen] = useState(false);
const toggleDrawer = (open: boolean) => () => {
setDrawerOpen(open);
};
2025-02-23 00:41:04 +01:00
const navItems: { label: string; path: string }[] = [
// { label: 'Features', path: '/features' }
// { label: 'About Us', path: '/about-us' }
];
2024-06-26 00:29:53 +01:00
const drawerList = (
<List>
2025-02-23 00:41:04 +01:00
{navItems.map((navItem) => (
<ListItemButton onClick={() => navigate(navItem.path)}>
<ListItemText primary={navItem.label} />
</ListItemButton>
))}
<iframe
src="https://ghbtns.com/github-btn.html?user=twbs&repo=bootstrap&type=star&count=true&size=large"
frameBorder="0"
scrolling="0"
width="170"
height="30"
title="GitHub"
></iframe>
2024-06-26 00:29:53 +01:00
</List>
);
2024-06-19 19:10:14 +01:00
return (
2024-06-22 22:06:16 +01:00
<AppBar
position="static"
2025-02-25 06:17:10 +00:00
style={{
backgroundColor: 'white',
color: 'black'
}}
2024-06-22 22:06:16 +01:00
>
2025-02-25 06:17:10 +00:00
<Toolbar
sx={{
justifyContent: 'space-between',
alignItems: 'center',
boxShadow: '0px 2px 2px #C8C9CE'
}}
>
2025-02-23 14:11:21 +00:00
<img
2024-06-22 22:06:16 +01:00
onClick={() => navigate('/')}
2025-02-23 14:11:21 +00:00
style={{ cursor: 'pointer' }}
src={logo}
width={isMobile ? '80px' : '150px'}
/>
2024-06-26 00:29:53 +01:00
{isMobile ? (
<>
2025-02-23 00:41:04 +01:00
<IconButton
color="inherit"
onClick={toggleDrawer(true)}
sx={{
'&:hover': {
backgroundColor: theme.palette.primary.main
}
}}
>
2024-06-26 00:29:53 +01:00
<MenuIcon />
</IconButton>
<Drawer
anchor="right"
open={drawerOpen}
onClose={toggleDrawer(false)}
2024-06-25 01:26:53 +01:00
>
2024-06-26 00:29:53 +01:00
{drawerList}
</Drawer>
</>
) : (
2025-02-23 00:41:04 +01:00
<Stack direction={'row'} spacing={2}>
{navItems.map((item) => (
<Button
key={item.label}
color="inherit"
sx={{
'&:hover': {
color: theme.palette.primary.main,
transition: 'color 0.3s ease',
backgroundColor: 'white'
}
}}
2024-06-26 00:29:53 +01:00
>
2025-02-23 00:41:04 +01:00
<Link
to={item.path}
style={{ textDecoration: 'none', color: 'inherit' }}
>
{item.label}
</Link>
</Button>
))}
<iframe
src="https://ghbtns.com/github-btn.html?user=iib0011&repo=omni-tools&type=star&count=true&size=large"
frameBorder="0"
scrolling="0"
width="170"
height="30"
title="GitHub"
></iframe>
2024-06-26 00:29:53 +01:00
</Stack>
)}
2024-06-19 19:10:14 +01:00
</Toolbar>
</AppBar>
);
};
export default Navbar;