Skip to content

Commit

Permalink
+ spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
Irina-anat committed Feb 22, 2024
1 parent ce8b605 commit 75afaee
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 29 deletions.
255 changes: 229 additions & 26 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"notiflix": "^3.2.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-loader-spinner": "^6.1.6",
"react-router-dom": "^6.14.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.3"
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="Movie search website"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
Expand Down
4 changes: 3 additions & 1 deletion src/components/Layout/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NavLink, Outlet } from "react-router-dom";
import { Suspense } from "react";
import css from './Layout.module.css'
import Loader from "components/Loader/Loader";


export const Layout = () => {
Expand All @@ -12,7 +13,8 @@ export const Layout = () => {
</nav>
</header>
<main>
<Suspense fallback={<div>Loading...</div>}>
<Suspense fallback={<Loader />}>
{/* <Suspense fallback={<div>Loading...</div>}> */}
<Outlet />
</Suspense>
</main>
Expand Down
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 { FallingLines } from 'react-loader-spinner';


const Loader = () => {
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
<FallingLines
color="#4fa94d"
width="100"
visible={true}
ariaLabel="falling-circles-loading"
/>
</div>
)
};

export default Loader;

4 changes: 3 additions & 1 deletion src/pages/MovieDetails/MovieDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
import { Suspense, useEffect, useRef, useState } from 'react';
import { fetchMovieDetails } from 'Services/Api';
import css from './MovieDetails.module.css';
import Loader from 'components/Loader/Loader';

const MovieDetails = () => {
const { movieId } = useParams();
Expand Down Expand Up @@ -75,7 +76,8 @@ const MovieDetails = () => {
</div>
</div>
)}
<Suspense fallback={<div>Loading...</div>}>
{/* <Suspense fallback={<div>Loading...</div>}> */}
<Suspense fallback={<Loader/>}>
<Outlet />
</Suspense>
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/pages/MovieDetails/MovieDetails.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
border-radius: 10px;
}


@media (max-width: 600px) {
.movie__box {
flex-direction: column;
}
}


.movie__image{
margin-right: 20px;
border-radius: 10px;
Expand Down

0 comments on commit 75afaee

Please sign in to comment.