forked from shivansh-bhatnagar18/multiplayer-uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: navbar with its modules css
this commit adds a nabar. fixes: shivansh-bhatnagar18#19
- Loading branch information
1 parent
a4574ab
commit 9d90fb6
Showing
7 changed files
with
303 additions
and
203 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
body { | ||
transition: margin-right 0.3s; | ||
margin-right: 0; | ||
} | ||
|
||
body.menu-open { | ||
margin-right: 250px; | ||
} | ||
|
||
.sidebar { | ||
position: fixed; | ||
top: 0; | ||
right: -250px; | ||
width: 250px; | ||
height: 100%; | ||
background-color: #111; | ||
overflow-x: hidden; | ||
transition: right 0.3s; | ||
z-index: 1000; | ||
} | ||
|
||
.sidebar.open { | ||
right: 0; | ||
} | ||
|
||
.ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
.li { | ||
padding: 8px 16px; | ||
text-align: left; | ||
color: #818181; | ||
} | ||
|
||
.li:hover { | ||
background-color: #575757; | ||
color: #ffffff; | ||
} | ||
|
||
.a { | ||
text-decoration: none; | ||
color: inherit; | ||
display: block; | ||
} | ||
|
||
.a.active { | ||
color: yellow; | ||
} | ||
|
||
.menuButton { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
z-index: 1100; | ||
} | ||
|
||
.hidden { | ||
display: none; | ||
} | ||
|
||
.mainContent { | ||
transition: margin-right 0.3s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,100 @@ | ||
import './index.css'; | ||
import { useState, useEffect } from 'react'; | ||
import { Link, NavLink } from 'react-router-dom'; | ||
import { FaBars, FaTimes } from 'react-icons/fa'; | ||
import styles from './Navbar.module.css'; | ||
|
||
function Navbar() { | ||
return <div className="flex flex-row">Navbar</div>; | ||
interface NavbarProps { | ||
logoSrc?: string; | ||
bgColorFrom?: string; | ||
bgColorTo?: string; | ||
navLinks?: Array<{ title: string; link: string }>; | ||
} | ||
|
||
function Navbar(props: NavbarProps) { | ||
const { | ||
logoSrc = './assets/uno_csoc.png', // Default logo | ||
navLinks = [ | ||
{ title: 'Home', link: '/' }, | ||
{ title: 'Play', link: '/play' }, | ||
{ title: 'Game', link: '/game' }, | ||
{ title: 'About', link: '/about' }, | ||
], // Default navigation | ||
bgColorFrom = '#999999', | ||
bgColorTo = '#333333', | ||
// Default background colors | ||
} = props; | ||
|
||
const [open, setOpen] = useState(false); | ||
|
||
useEffect(() => { | ||
document.body.classList.toggle('menu-open', open); | ||
}, [open]); | ||
|
||
const handleMenu = () => { | ||
setOpen((prev) => !prev); | ||
}; | ||
const background = `linear-gradient(to right, ${bgColorFrom}, ${bgColorTo})`; | ||
|
||
return ( | ||
<header className="sticky top-0 z-50 flex flex-row"> | ||
<nav | ||
className="bg-opacity-90 border-gray-200 px-4 lg:px-6 py-2.5 w-full" | ||
style={{ background }} | ||
> | ||
<div className="flex flex-wrap items-center justify-between max-w-screen-xl mx-auto"> | ||
<Link to="/" className="flex items-center"> | ||
<img src={logoSrc} className="h-12 mr-3" alt="Logo" /> | ||
</Link> | ||
<div className="items-center justify-between hidden w-full md:flex md:w-auto md:order-1"> | ||
<ul className="flex flex-col mt-4 font-medium md:flex-row md:space-x-8 md:mt-0"> | ||
{navLinks.map((link, index) => ( | ||
<li key={index}> | ||
<NavLink | ||
to={link.link} | ||
className={({ isActive }) => | ||
`block py-2 pr-4 pl-3 duration-200 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 hover:text-yellow-400 lg:p-0 ${isActive ? 'text-yellow-400' : 'text-gray-300'}` | ||
} | ||
> | ||
{link.title} | ||
</NavLink> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
<div className={`flex md:hidden ${styles.menuButton}`}> | ||
<button | ||
type="button" | ||
onClick={handleMenu} | ||
className={`inline-flex items-center justify-center p-2 text-gray-400 rounded-md hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-white`} | ||
> | ||
<span className="sr-only">Toggle main menu</span> | ||
{open ? <FaTimes /> : <FaBars />} | ||
</button> | ||
</div> | ||
</div> | ||
</nav> | ||
<div | ||
id="sidebar" | ||
className={`${styles.sidebar} ${open ? styles.open : ''}`} | ||
> | ||
<ul className={styles.ul}> | ||
{navLinks.map((link, index) => ( | ||
<li key={index} className={styles.li}> | ||
<NavLink | ||
to={link.link} | ||
className={({ isActive }) => | ||
`${styles.a} ${isActive ? styles.active : ''}` | ||
} | ||
onClick={() => setOpen(false)} | ||
> | ||
{link.title} | ||
</NavLink> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</header> | ||
); | ||
} | ||
|
||
export default Navbar; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters