Skip to content

Commit

Permalink
add basic navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolaus-B committed Mar 24, 2024
1 parent 1fa502c commit 4713d19
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 2 deletions.
22 changes: 22 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"modern-normalize": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-loader-spinner": "^6.1.6",
"react-modal": "^3.16.1",
"react-redux": "^9.1.0",
"react-router-dom": "^6.22.3",
Expand Down
6 changes: 5 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import { lazy } from "react";
import { Route, Routes } from "react-router-dom";
import { AppLayout } from "./components/AppLayout/AppLayout";

const WelcomePage = lazy(() => import("./pages/WelcomePage"));
const HomePage = lazy(() => import("./pages/HomePage"));
const FavouritePage = lazy(() => import("./pages/FavouritePage"));
const NotFoundPage = lazy(() => import("./pages/NotFoundPage"));

function App() {
return (
<Routes>
<Route path="/" element={<AppLayout />}>
<Route index element={<HomePage />} />
<Route index element={<WelcomePage />} />
<Route path="/home" element={<HomePage />} />
<Route path="/favourite" element={<FavouritePage />} />
</Route>
<Route path="*" element={<NotFoundPage />} />
</Routes>
Expand Down
7 changes: 6 additions & 1 deletion src/components/AppLayout/AppLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Suspense, useEffect } from "react";
import { GlobalStyle } from "../GlobalStyle";
import { useDispatch } from "react-redux";
import { fetchCars } from "../../redux/cars/operations";
import { Header } from "../Header/Header";
import { Loader } from "../Loader/Loader";

export const AppLayout = () => {
const dispatch = useDispatch();
Expand All @@ -12,8 +14,11 @@ export const AppLayout = () => {

return (
<>
<header>
<Header />
</header>
<main>
<Suspense fallback={<div>Loader</div>}>
<Suspense fallback={<Loader />}>
<Outlet />
</Suspense>
</main>
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NavLink } from "react-router-dom";
import { HeaderContainer, HeaderNavigation } from "./Header.styled";

export const Header = () => {
return (
<HeaderContainer>
<HeaderNavigation>
<NavLink to="/">RentCamp</NavLink>
<NavLink to="/home">Rent</NavLink>
<NavLink to="/favourite">Favourite</NavLink>
</HeaderNavigation>
</HeaderContainer>
);
};
12 changes: 12 additions & 0 deletions src/components/Header/Header.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import styled from "styled-components";

export const HeaderContainer = styled.div`
margin: 0 auto;
padding: 30px 64px;
max-width: 1440px;
`;

export const HeaderNavigation = styled.nav`
display: flex;
gap: 20px;
`;
18 changes: 18 additions & 0 deletions src/components/Loader/Loader.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { RotatingLines } from "react-loader-spinner";
import { LoaderContainer, Backbrop } from "./Loader.styled";

export const Loader = () => {
return (
<Backbrop>
<LoaderContainer>
<RotatingLines
strokeColor="#4f58fd"
strokeWidth="5"
animationDuration="0.75"
width="96"
visible={true}
/>
</LoaderContainer>
</Backbrop>
);
};
19 changes: 19 additions & 0 deletions src/components/Loader/Loader.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import styled from "styled-components";

export const Backbrop = styled.div`
position: fixed;
top: 0;
left: 0;
z-index: 100;
width: 100%;
height: 100%;
background-color: rgba(46, 47, 66, 0.4);
`;

export const LoaderContainer = styled.div`
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
`;
7 changes: 7 additions & 0 deletions src/pages/FavouritePage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function FavouritePage() {
return (
<section className="container">
<h1>favourite</h1>
</section>
);
}
7 changes: 7 additions & 0 deletions src/pages/WelcomePage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function WelcomePage() {
return (
<section className="container">
<h1>WelcomePage</h1>
</section>
);
}

0 comments on commit 4713d19

Please sign in to comment.