-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made a navbar #37
Closed
RashiJyotishi
wants to merge
2
commits into
shivansh-bhatnagar18:master
from
RashiJyotishi:RJ-navbar
Closed
Made a navbar #37
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on the props!