Skip to content

Commit

Permalink
Setting Routes & Layout
Browse files Browse the repository at this point in the history
  • Loading branch information
tin0312 committed Aug 9, 2023
1 parent 0a1def5 commit 7dbfd7e
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 5 deletions.
64 changes: 63 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"dependencies": {
"boostrap": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router": "^6.14.2",
"react-router-dom": "^6.14.2"
},
"devDependencies": {
"@types/react": "^18.2.15",
Expand Down
3 changes: 1 addition & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
box-sizing: border-box;
}
body {
color: #fff;
background-color: black;
color: black;
}
18 changes: 17 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import React from 'react'
import { BrowserRouter, Routes, Route} from "react-router-dom"
import './App.css'
import Layout from "./Components/Layout"
import About from "./Pages/About"
import Home from "./Pages/Home"
import Projects from "./Pages/Projects"
import Album from "./Pages/Album"


export default function App() {

return (
<>
<h1>Justin Hoang</h1>
<BrowserRouter>
<Routes>
<Route path = '/' element = {<Layout />}>
<Route index element = {<Home/>} />
<Route path = '/about' element = {<About/>} />
<Route path = '/projects' element = {<Projects/>}/>
<Route path = '/album' element = {<Album/>}/>
</Route>
</Routes>
</BrowserRouter>
</>
)
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "React"


export default function Footer() {
return (
<footer>
<p>© 2023 - Developeed by Hoang Nhat Truong</p>
</footer>
)
}
28 changes: 28 additions & 0 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react"
import { NavLink } from "react-router-dom"


export default function Header() {
const isActiveLink= {
textDecoration: "underline",
fontWeight: "bold",
color: "green"

}
return (
<header>
<NavLink to = "/home" style = {({isActive}) => isActive ? isActiveLink : null } >
Home
</NavLink>
<NavLink to = "/about" style = {({isActive}) => isActive ? isActiveLink : null }>
About
</NavLink>
<NavLink to = "/projects" style = {({isActive}) => isActive ? isActiveLink : null } >
Projects
</NavLink>
<NavLink to = "/album" style = {({isActive}) => isActive ? isActiveLink : null }>
Album
</NavLink>
</header>
)
}
16 changes: 16 additions & 0 deletions src/components/Layout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react"
import { Outlet } from "react-router-dom"
import Header from "./Header"
import Footer from "./Footer"

export default function Layout() {
return (
<div className=" site-wrapper">
<Header />
<main>
<Outlet />
</main>
<Footer />
</div>
)
}

0 comments on commit 7dbfd7e

Please sign in to comment.