-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making simple header componenet with theme toggle and github repo lin…
…k and setup react routers
- Loading branch information
Showing
11 changed files
with
147 additions
and
43 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Button } from "@/components/ui/button" | ||
import PropTypes from 'prop-types'; | ||
|
||
function NavLinks(props) { | ||
|
||
return( | ||
<a target="_blank" href={props.link} rel="noopener" tabIndex="-1"> | ||
<Button variant="ghost" size='icon'> | ||
<img className="size-4" src={props.logo} alt={props.name} /> | ||
<span className="sr-only">{props.name}</span> | ||
</Button> | ||
</a> | ||
) | ||
} | ||
|
||
NavLinks.propTypes = { | ||
link: PropTypes.string.isRequired, | ||
logo: PropTypes.string.isRequired, | ||
name: PropTypes.string.isRequired | ||
} | ||
|
||
export default NavLinks |
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 |
---|---|---|
@@ -1,4 +1,57 @@ | ||
// Assets | ||
import githubLogoDark from '../assets/svg/github-mark-white.svg'; | ||
import githubLogoLight from '../assets/svg/github-mark.svg'; | ||
|
||
export default Header() { | ||
|
||
} | ||
// Components | ||
import { useEffect } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { ModeToggle } from '@/components/mode-toggle'; | ||
import NavLinks from '@/components/ui/NavLinks'; | ||
import { useTheme } from '@/components/theme-provider'; | ||
|
||
function Header() { | ||
const { theme, setTheme } = useTheme(); | ||
|
||
useEffect(() => { | ||
// Set the theme based on system preference | ||
if (theme === 'system') { | ||
// Use the system's color scheme preference | ||
setTheme(window.matchMedia('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light'); | ||
} | ||
}); | ||
|
||
return ( | ||
<header className="container px-6 py-3 flex justify-between items-center backdrop-blur-3xl"> | ||
<Logo /> | ||
<Navigation /> | ||
</header> | ||
); | ||
} | ||
|
||
function Logo() { | ||
return ( | ||
<div className="logo"> | ||
<Link className="focusing" to="React-Project/"> | ||
<span className="font-mono">React</span> | ||
<span className="font-micro text-[24px] text-primary ps-[1px]">Project</span> | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
function Navigation() { | ||
const { theme } = useTheme(); | ||
|
||
return ( | ||
<nav className="flex items-center gap-6"> | ||
<NavLinks | ||
logo={theme === 'dark' ? githubLogoDark : githubLogoLight} | ||
name="Github" | ||
link="https://github.com/No0ne003/React-Project" | ||
/> | ||
<ModeToggle /> | ||
</nav> | ||
); | ||
} | ||
|
||
export default Header; |
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,11 @@ | ||
|
||
|
||
function Home() { | ||
return ( | ||
<> | ||
<h1>Home</h1> | ||
</> | ||
) | ||
} | ||
|
||
export default Home |
Empty file.
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