Files
omni-tools/src/components/Navbar/index.tsx
Ibrahima G. Coulibaly 62f084eb45 fix: ctrl v
2025-02-23 00:41:04 +01:00

129 lines
3.6 KiB
TypeScript

import React, { useState } from 'react';
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
import IconButton from '@mui/material/IconButton';
import MenuIcon from '@mui/icons-material/Menu';
import { Link, useNavigate } from 'react-router-dom';
import githubIcon from '@assets/github-mark.png'; // Adjust the path to your GitHub icon
import {
Drawer,
List,
ListItemButton,
ListItemText,
Stack
} from '@mui/material';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTheme } from '@mui/material/styles';
const Navbar: React.FC = () => {
const navigate = useNavigate();
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
const [drawerOpen, setDrawerOpen] = useState(false);
const toggleDrawer = (open: boolean) => () => {
setDrawerOpen(open);
};
const navItems: { label: string; path: string }[] = [
// { label: 'Features', path: '/features' }
// { label: 'About Us', path: '/about-us' }
];
const drawerList = (
<List>
{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>
</List>
);
return (
<AppBar
position="static"
style={{ backgroundColor: 'white', color: 'black' }}
>
<Toolbar sx={{ justifyContent: 'space-between', alignItems: 'center' }}>
<Typography
onClick={() => navigate('/')}
fontSize={25}
sx={{
cursor: 'pointer',
fontWeight: 600,
textShadow: '1px 1px 2px rgba(0,0,0,0.2)'
}}
color={'primary'}
>
OmniTools
</Typography>
{isMobile ? (
<>
<IconButton
color="inherit"
onClick={toggleDrawer(true)}
sx={{
'&:hover': {
backgroundColor: theme.palette.primary.main
}
}}
>
<MenuIcon />
</IconButton>
<Drawer
anchor="right"
open={drawerOpen}
onClose={toggleDrawer(false)}
>
{drawerList}
</Drawer>
</>
) : (
<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'
}
}}
>
<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>
</Stack>
)}
</Toolbar>
</AppBar>
);
};
export default Navbar;