-
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.
Integrate routing and fix dark mode for mobile nav menu
- Loading branch information
Showing
22 changed files
with
534 additions
and
105 deletions.
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
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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
type Props = { | ||
children: ReactNode; | ||
}; | ||
|
||
function PageContainer({ children }: Props) { | ||
return ( | ||
<div className='mt-6 flex w-full justify-center justify-items-center items-center container mx-auto max-w-7xl px-6 flex-grow'> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
export { PageContainer }; |
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 @@ | ||
export * from './PageContainer'; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './containers'; | ||
export * from './navigation'; |
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,71 @@ | ||
import { | ||
Navbar, | ||
NavbarBrand, | ||
NavbarContent, | ||
NavbarItem, | ||
NavbarMenu, | ||
NavbarMenuToggle, | ||
} from '@nextui-org/react'; | ||
import { routes } from '../../routes'; | ||
import { ThemeSwitcher } from './ThemeSwitcher.tsx'; | ||
import { NavigationLink } from './NavigationLink.tsx'; | ||
|
||
function Navigation() { | ||
return ( | ||
<Navbar | ||
classNames={{ | ||
item: 'data-[active=true]:text-primary dark:data-[active=true]:text-primary-500 font-semibold', | ||
menuItem: 'data-[active=true]:text-primary dark:data-[active=true]:text-primary-500 font-semibold', | ||
wrapper: 'px-4 sm:px-6', | ||
}} | ||
height='60px' | ||
maxWidth='xl' | ||
isBlurred | ||
> | ||
<NavbarBrand> | ||
<NavbarMenuToggle className='mr-2 h-6 sm:hidden' /> | ||
<p className='font-bold text-inherit text-xl sm:text-2xl'> | ||
Siddharth Gupta | ||
</p> | ||
</NavbarBrand> | ||
|
||
<NavbarContent | ||
className='ml-4 hidden h-12 w-full max-w-fit gap-4 rounded-full bg-content2 px-4 sm:flex' | ||
justify='start' | ||
> | ||
{routes.map(r => ( | ||
<NavigationLink | ||
key={`nav-${r.path}`} | ||
path={r.path} | ||
text={r.navText} | ||
/> | ||
))} | ||
</NavbarContent> | ||
|
||
<NavbarContent | ||
className='ml-auto flex h-12 max-w-fit items-center gap-0 rounded-full p-0 lg:bg-content2 lg:px-1 lg:dark:bg-content1' | ||
justify='end' | ||
> | ||
<NavbarItem> | ||
<ThemeSwitcher /> | ||
</NavbarItem> | ||
</NavbarContent> | ||
|
||
{/* Mobile Menu */} | ||
<NavbarMenu | ||
portalContainer={document.body.getElementsByTagName('main')[0]} | ||
> | ||
{routes.map(r => ( | ||
<NavigationLink | ||
key={`nav-mobile-${r.path}`} | ||
path={r.path} | ||
text={r.navText} | ||
mobile | ||
/> | ||
))} | ||
</NavbarMenu> | ||
</Navbar> | ||
); | ||
} | ||
|
||
export { Navigation }; |
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,37 @@ | ||
import { NavbarItem, NavbarMenuItem } from '@nextui-org/react'; | ||
import { ReactNode } from 'react'; | ||
import { NavLink, Path, useMatch, useResolvedPath } from 'react-router-dom'; | ||
|
||
type Props = { | ||
path: string; | ||
text: ReactNode; | ||
mobile?: boolean; | ||
}; | ||
|
||
function NavigationLink({ path, text, mobile = false }: Props) { | ||
const resolvedPath: Path = useResolvedPath(path); | ||
const matchedPath = useMatch({ | ||
path: resolvedPath.pathname, | ||
end: true, | ||
}); | ||
|
||
if (mobile) { | ||
return ( | ||
<NavbarMenuItem isActive={matchedPath !== null}> | ||
<NavLink to={path} className='w-full'> | ||
{text} | ||
</NavLink> | ||
</NavbarMenuItem> | ||
); | ||
} | ||
|
||
return ( | ||
<NavbarItem isActive={matchedPath !== null}> | ||
<NavLink className='flex gap-2 text-inherit' to={path}> | ||
{text} | ||
</NavLink> | ||
</NavbarItem> | ||
); | ||
} | ||
|
||
export { NavigationLink }; |
File renamed without changes.
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,3 @@ | ||
export * from './NavigationLink'; | ||
export * from './Navigation'; | ||
export * from './ThemeSwitcher'; |
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,13 +1,16 @@ | ||
import { NextUIProvider } from '@nextui-org/react'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import App from './App.tsx'; | ||
import './index.css'; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
<React.StrictMode> | ||
<NextUIProvider> | ||
<App /> | ||
</NextUIProvider> | ||
<BrowserRouter> | ||
<NextUIProvider> | ||
<App /> | ||
</NextUIProvider> | ||
</BrowserRouter> | ||
</React.StrictMode> | ||
); |
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,8 @@ | ||
|
||
function Contact() { | ||
return ( | ||
<div>Contact</div> | ||
); | ||
} | ||
|
||
export { Contact }; |
Oops, something went wrong.