Skip to content

Commit e038dd1

Browse files
author
Hannah Dunsmore
committed
created button functionality and desktop styling
1 parent ed71787 commit e038dd1

File tree

10 files changed

+134
-22
lines changed

10 files changed

+134
-22
lines changed

src/App.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import React from "react";
22
import "./App.scss";
3-
import { useState } from "react";
4-
import MissionManifest, {
5-
rovers,
6-
} from "./Components/MissionManifest/MissionManifest";
3+
import RoverDetails from "./Components/RoverDetails/RoverDetails";
74

85
function App() {
9-
const [rover, setRover] = useState<rovers>(rovers.SPIRIT);
10-
11-
return <MissionManifest roverType={rover} />;
6+
return <RoverDetails />;
127
}
138

149
export default App;
87.8 KB
Loading
66.3 KB
Loading
84.5 KB
Loading

src/Components/MissionManifest/MissionManifest.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@use "../../App.scss" as AppCSS;
21
@import "../../Styles/GlobalStyles.scss";
32

43
body{
@@ -20,7 +19,6 @@ body{
2019
display: grid;
2120
grid-template-columns: 3fr 5fr;
2221
grid-auto-rows: auto;
23-
// border: 1px solid black;
2422
p {
2523
font-size: 0.8rem;
2624
border: 1px solid black;

src/Components/MissionManifest/MissionManifest.spec.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
2-
import { getByText, render, screen, waitFor } from "@testing-library/react";
3-
import App from "../../App";
2+
import { render, screen } from "@testing-library/react";
43
import MissionManifest, { rovers } from "./MissionManifest";
54

65
const mockManifestResponse = {
@@ -21,14 +20,13 @@ beforeEach(() => {
2120
});
2221
});
2322

24-
// Ensures component renders a loading state before data arrives
2523
test("renders loading message on initial render", () => {
2624
render(<MissionManifest roverType={rovers.SPIRIT} />);
2725
expect(screen.getByText("Loading...")).toBeInTheDocument();
2826
});
2927

3028
test("opportunity rover renders correct p elements", async () => {
31-
render(<MissionManifest roverType={rovers.OPP} />);
29+
render(<MissionManifest roverType={rovers.OPPORTUNIY} />);
3230
const expectedTexts = [
3331
"Rover Name: ",
3432
mockManifestResponse.photo_manifest.name,
@@ -59,12 +57,9 @@ test("opportunity rover renders correct p elements", async () => {
5957
});
6058

6159
test("opportunity rover renders correct Heading", async () => {
62-
render(<MissionManifest roverType={rovers.OPP} />);
60+
render(<MissionManifest roverType={rovers.OPPORTUNIY} />);
6361

64-
const missionManifestContainer = await screen.findByTestId(
65-
"mission-manifest-container",
66-
);
67-
const heading = screen.getByText("MISSION MANIFEST");
62+
const heading = await screen.findByText("MISSION MANIFEST");
6863

6964
expect(heading).toBeInTheDocument();
7065
});
@@ -85,7 +80,7 @@ test("invalid rover renders correct p elements", async () => {
8580
json: jest.fn().mockResolvedValue(mockInvalidFetchResponse),
8681
});
8782

88-
render(<MissionManifest roverType={rovers.OPP} />);
83+
render(<MissionManifest roverType={rovers.OPPORTUNIY} />);
8984

9085
const missionManifestContainer = await screen.findByTestId(
9186
"mission-manifest-container",

src/Components/MissionManifest/MissionManifest.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import React from "react";
12
import { useState } from "react";
23
import { useEffect } from "react";
3-
import { config } from "dotenv";
4-
import { json } from "stream/consumers";
54
import "./MissionManifest.scss";
65

76
export enum rovers {
87
CURIOSITY = "curiosity",
9-
OPP = "opportunity",
8+
OPPORTUNIY = "opportunity",
109
SPIRIT = "spirit",
1110
}
1211

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@import "../../Styles/GlobalStyles.scss";
2+
3+
#rover-information-container {
4+
5+
#rover-header {
6+
color: whitesmoke;
7+
display: flex;
8+
justify-content: center;
9+
margin: 40px auto;
10+
font-family: $MartianMono;
11+
}
12+
}
13+
14+
#rover-button-container {
15+
display: flex;
16+
justify-content: space-between;
17+
margin: 0 auto;
18+
width: 30vw;
19+
font-family: $PublicSans;
20+
button {
21+
all: unset;
22+
background: none;
23+
padding:0;
24+
display: flex;
25+
flex-direction: column;
26+
text-align: center;
27+
font-family: $PublicSans;
28+
cursor: pointer;
29+
span {
30+
margin: 10px 0;
31+
color: whitesmoke;
32+
}
33+
.selected-rover {
34+
span {
35+
text-decoration: underline;
36+
}
37+
}
38+
}
39+
img {
40+
width: 150px;
41+
}
42+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import React from "react";
2+
import { useState } from "react";
3+
import MissionManifest from "../MissionManifest/MissionManifest";
4+
import spiritButton from "../../Assets/Images/spirit_button.png";
5+
import curiosityButton from "../../Assets/Images/curiosity_button.png";
6+
import opportunityButton from "../../Assets/Images/Opportunity_button.png";
7+
import "./RoverDetails.scss";
8+
9+
export enum rovers {
10+
CURIOSITY = "curiosity",
11+
OPPORTUNIY = "opportunity",
12+
SPIRIT = "spirit",
13+
}
14+
15+
export interface MissionManifestProps {
16+
roverType: rovers;
17+
}
18+
19+
function RoverDetails() {
20+
const [rover, setRover] = useState<rovers>(rovers.SPIRIT);
21+
const [selectedRover, setSelectedRover] = useState<rovers>(rovers.SPIRIT);
22+
23+
const handleClick = (id: string) => {
24+
if (id === "spirit-button") {
25+
setRover(rovers.SPIRIT);
26+
setSelectedRover(rovers.SPIRIT);
27+
} else if (id === "curiosity-button") {
28+
setRover(rovers.CURIOSITY);
29+
setSelectedRover(rovers.CURIOSITY);
30+
} else if (id === "opportunity-button") {
31+
setRover(rovers.OPPORTUNIY);
32+
setSelectedRover(rovers.OPPORTUNIY);
33+
}
34+
};
35+
36+
return (
37+
<div id="rover-information-container">
38+
<h2 id="rover-header">CHOOSE A ROVER</h2>
39+
<div id="rover-button-container" className="button-carousel">
40+
<button
41+
className={rover === "spirit" ? "selected-rover" : "not-selected"}
42+
id="spirit-button"
43+
key="spirit-button"
44+
onClick={() => handleClick("spirit-button")}
45+
>
46+
<img src={spiritButton} />
47+
<span>SPIRIT</span>
48+
</button>
49+
<button
50+
className={rover === "curiosity" ? "selected-rover" : "not-selected"}
51+
id="curiosity-button"
52+
key="curiosity-button"
53+
>
54+
<img
55+
src={curiosityButton}
56+
onClick={() => handleClick("curiosity-button")}
57+
/>
58+
<span>CURIOSITY</span>
59+
</button>
60+
<button
61+
className={
62+
rover === "opportunity" ? "selected-rover" : "not-selected"
63+
}
64+
id="opportunity-button"
65+
key="opportunity-button"
66+
>
67+
<img
68+
src={opportunityButton}
69+
onClick={() => handleClick("opportunity-button")}
70+
/>
71+
<span>OPPORTUNITY</span>
72+
</button>
73+
</div>
74+
<MissionManifest roverType={rover} />
75+
</div>
76+
);
77+
}
78+
79+
export default RoverDetails;

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+
}

0 commit comments

Comments
 (0)