Skip to content

Commit

Permalink
dynamic routing fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
DonyaElbanna committed Jan 4, 2023
1 parent 962ae77 commit ce979c0
Show file tree
Hide file tree
Showing 8 changed files with 17,585 additions and 14,210 deletions.
31,742 changes: 17,563 additions & 14,179 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@
},
"overrides": {
"autoprefixer": "10.4.5"
},
"resolutions": {
"autoprefixer": "10.4.5"
}
}
17 changes: 6 additions & 11 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,20 @@
}

.navbar-nav {
align-items: center;
margin: 5px auto;
font-size: 1.6rem;
font-size: 1.54rem;
}

.accent {
color: #80ff00;
}

.nav-links {
display: flex;
justify-content: space-between;
color: white;
align-items: center;
.active {
color: #80ff00 !important;
font-weight: bold !important;
}


/* Home */

.containers {
Expand All @@ -54,10 +52,7 @@ h2 {
margin-bottom: 4%;
}

.active {
color: #80ff00 !important;
font-weight: bold;
}


/* Search */

Expand Down
15 changes: 7 additions & 8 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ThemeProvider, createTheme } from "@mui/material/styles";
import Home from "./components/Home";
import Episodes from "./components/Episodes";
import Locations from "./components/Locations";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import ToTopBtn from "./components/ToTopBtn";
import Navigation from "./components/Navigation";

Expand Down Expand Up @@ -65,6 +65,7 @@ function App() {
})
);
setEpisodeCharacters(charactersData);
setLoading(false);
})();
}, [episodeApi]);

Expand Down Expand Up @@ -112,19 +113,16 @@ function App() {

return (
<div className="App">

<Router>
<BrowserRouter>
<ThemeProvider theme={theme}>
{/* <CssBaseline /> */}
<Navigation clearAll={clearAll}/>

<Navigation clearAll={clearAll} />
<ToTopBtn />
<Routes>
<Route
path="/"
element={
<Home
results={results ? results : "loading"}
results={loading ? "loading" : results}
page={page}
setPage={setPage}
stat={status}
Expand All @@ -137,6 +135,7 @@ function App() {
searchInput={searchInput}
setSearchInput={setSearchInput}
info={info}
loading={loading}
/>
}
/>
Expand Down Expand Up @@ -166,7 +165,7 @@ function App() {
/>
</Routes>
</ThemeProvider>
</Router>
</BrowserRouter>
</div>
);
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Episodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ const Episodes = ({
}) => {
return (
<div className="containers">
<div className="episode-heading" style={{marginBottom: "47px"}}>
<div className="episode-heading" style={{ marginBottom: "4.5%" }}>
<h1>
{episodeData.episode}:{" "}
<span className="accent">{episodeData.name}</span>
</h1>
<h2 >Air date: {episodeData.air_date}</h2>
<h2>Air date: {episodeData.air_date}</h2>
</div>

<Grid container spacing={5} className="grid-container">
<Grid xs={12} sm={4} md={3}>
<DropDown
Expand Down
3 changes: 2 additions & 1 deletion src/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Home = ({
searchInput,
setSearchInput,
info,
loading
}) => {
return (
<div className="containers">
Expand All @@ -38,7 +39,7 @@ const Home = ({
clearSearch={clearSearch}
></Filter>
</Grid>
<CardItem results={results} />
<CardItem results={results ? results: null} />
</Grid>
<PaginationBar info={info ? info : ""} page={page} setPage={setPage} />
</div>
Expand Down
1 change: 0 additions & 1 deletion src/components/Locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const Episodes = ({
</h2>
</div>
</div>

<Grid container spacing={5} className="grid-container">
<Grid xs={12} sm={4} md={3}>
<DropDown
Expand Down
9 changes: 2 additions & 7 deletions src/components/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Nav, Navbar, NavLink } from "react-bootstrap";
import { Link } from "react-router-dom";
import { NavLink as Link } from "react-router-dom";

const Navigation = ({ clearAll }) => {
return (
Expand All @@ -15,12 +15,7 @@ const Navigation = ({ clearAll }) => {
/>
<Navbar.Collapse id="navbarScroll">
<Nav onClick={clearAll}>
<NavLink
eventKey="1"
as={Link}
to="/"
className={({ isActive }) => (isActive ? "active" : "inactive")}
>
<NavLink eventKey="1" as={Link} to="/">
Characters
</NavLink>
<NavLink eventKey="2" as={Link} to="/episode">
Expand Down

0 comments on commit ce979c0

Please sign in to comment.