Skip to content

Commit 7c3c9a4

Browse files
the-duckchildSathya Sreenivasaneleanorscott97
authored
Add nav bar (#25)
Co-authored-by: Sathya Sreenivasan <sathya.sreenivasan@softwire.com> Co-authored-by: Eleanor <eleanor.scott@softwire.com>
1 parent 9ff9258 commit 7c3c9a4

File tree

9 files changed

+144
-16
lines changed

9 files changed

+144
-16
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,30 @@ import "./App.scss";
33
import { Link, Route, BrowserRouter as Router, Routes } from "react-router";
44
import PhotoOfTheDay from "./Components/photoOfTheDay/photoOfTheDay";
55
import ProfilePage from "./pages/Profile/ProfilePage";
6+
import NavBar from "./Components/AddNavBar/NavBar";
67

78
function App() {
89
return (
9-
<Router>
10-
<Routes>
11-
<Route path="/" element={<PhotoOfTheDay />} />
12-
<Route path="/profile" element={<ProfilePage />} />
13-
<Route
14-
path="*"
15-
element={
16-
<div>
17-
Sorry, that page does not exist, try these:
10+
<div>
11+
<Router>
12+
<NavBar />
13+
<Routes>
14+
<Route path="/" element={<PhotoOfTheDay />} />
15+
<Route path="/profile" element={<ProfilePage />} />
16+
<Route
17+
path="*"
18+
element={
1819
<div>
19-
<Link to="/profile">Profile Page</Link>
20+
Sorry, that page does not exist, try these:
21+
<div>
22+
<Link to="/profile">Profile Page</Link>
23+
</div>
2024
</div>
21-
</div>
22-
}
23-
/>
24-
</Routes>
25-
</Router>
25+
}
26+
/>
27+
</Routes>
28+
</Router>
29+
</div>
2630
);
2731
}
2832

273 KB
Loading
1.41 MB
Loading
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@import "../../Styles/GlobalStyles.scss";
2+
3+
body {
4+
background-color: $blueBackground;
5+
font-family: $PublicSans;
6+
}
7+
8+
.navBarContainer {
9+
display: flex;
10+
background: $blueBackground;
11+
justify-content: space-between;
12+
13+
}
14+
15+
.homeButton {
16+
display: flex;
17+
flex-direction: column;
18+
align-items: center;
19+
}
20+
21+
.profilePageButton {
22+
display: flex;
23+
flex-direction: column;
24+
align-items: center;
25+
26+
}
27+
28+
#astroButton {
29+
width: 5vw;
30+
min-width: 50px;
31+
32+
}
33+
34+
#earthButton {
35+
width: 5vw;
36+
min-width: 50px;
37+
38+
}
39+
40+
a {
41+
margin: 15px 10px 10px 10px;
42+
color: $orangeBackground;
43+
padding: 2.5px 20px;
44+
border: solid 2px $orangeBackground;
45+
text-decoration: none;
46+
border-radius: 25px;
47+
}
48+
49+
50+
51+
a:hover {
52+
53+
color: $whiteFontColor;
54+
box-shadow: 0px 0px 3px 3px $greyBackground;
55+
}
56+
57+
a:active {
58+
box-shadow: none;
59+
color: $orangeBackground;
60+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import "@testing-library/jest-dom";
2+
import { render, screen } from "@testing-library/react";
3+
import userEvent from "@testing-library/user-event";
4+
import React from "react";
5+
import NavBar from "./NavBar";
6+
import { BrowserRouter } from "react-router";
7+
8+
describe(NavBar, () => {
9+
it("Should change current location to profile when link is clicked", () => {
10+
render(
11+
<BrowserRouter>
12+
<NavBar />
13+
</BrowserRouter>,
14+
);
15+
const linkProfile = screen.getByText("Profile");
16+
userEvent.click(linkProfile);
17+
});
18+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from "react";
2+
import "./NavBar.scss";
3+
import { Link } from "react-router";
4+
import imageAstro from "./Images/astronautcartoon.png";
5+
import imageEarth from "./Images/cartoon earth.png";
6+
7+
export default function NavBar() {
8+
return (
9+
<div>
10+
<header className="navBarHeader">
11+
<nav className="navBarContainer">
12+
<div>
13+
<Link to="/" className="homeButton" id="homeLink">
14+
<img src={imageEarth} alt="imageEarth" id="earthButton" />
15+
Home
16+
</Link>
17+
</div>
18+
<div>
19+
<Link to="/profile" className="profilePageButton" id="profileLink">
20+
<img
21+
src={imageAstro}
22+
alt="cartoon astronaut illustration"
23+
id="astroButton"
24+
/>
25+
Profile
26+
</Link>
27+
</div>
28+
</nav>
29+
</header>
30+
</div>
31+
);
32+
}

src/custom.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*.png" {
2+
const value: string;
3+
export default value;
4+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
"jsx": "react-jsx"
2222
},
2323
"include": [
24-
"src"
24+
"src",
2525
]
2626
}

0 commit comments

Comments
 (0)