├── .gitattributes
├── public
├── favicon.ico
├── logo192.png
├── logo512.png
├── tmovie.png
├── robots.txt
├── manifest.json
└── index.html
├── src
├── assets
│ ├── tmovie.png
│ ├── footer-bg.jpg
│ └── boxicons-2.0.7
│ │ ├── fonts
│ │ ├── boxicons.eot
│ │ ├── boxicons.ttf
│ │ ├── boxicons.woff
│ │ └── boxicons.woff2
│ │ ├── LICENSE.txt
│ │ └── css
│ │ ├── transformations.css
│ │ ├── animations.css
│ │ └── boxicons.min.css
├── scss
│ ├── _index.scss
│ ├── _mixin.scss
│ ├── _breakpoint.scss
│ └── _variables.scss
├── index.js
├── components
│ ├── input
│ │ ├── input.scss
│ │ └── Input.jsx
│ ├── movie-list
│ │ ├── movie-list.scss
│ │ └── MovieList.jsx
│ ├── page-header
│ │ ├── PageHeader.jsx
│ │ └── page-header.scss
│ ├── button
│ │ ├── Button.jsx
│ │ └── button.scss
│ ├── movie-grid
│ │ ├── movie-grid.scss
│ │ └── MovieGrid.jsx
│ ├── movie-card
│ │ ├── MovieCard.jsx
│ │ └── movie-card.scss
│ ├── footer
│ │ ├── footer.scss
│ │ └── Footer.jsx
│ ├── modal
│ │ ├── modal.scss
│ │ └── Modal.jsx
│ ├── header
│ │ ├── Header.jsx
│ │ └── header.scss
│ └── hero-slide
│ │ ├── hero-slide.scss
│ │ └── HeroSlide.jsx
├── api
│ ├── apiConfig.js
│ ├── axiosClient.js
│ └── tmdbApi.js
├── App.js
├── pages
│ ├── Catalog.jsx
│ ├── detail
│ │ ├── CastList.jsx
│ │ ├── VideoList.jsx
│ │ ├── detail.scss
│ │ └── Detail.jsx
│ └── Home.jsx
├── config
│ └── Routes.jsx
└── App.scss
├── .gitignore
├── README.md
└── package.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/public/tmovie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/public/tmovie.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/assets/tmovie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/src/assets/tmovie.png
--------------------------------------------------------------------------------
/src/assets/footer-bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/src/assets/footer-bg.jpg
--------------------------------------------------------------------------------
/src/scss/_index.scss:
--------------------------------------------------------------------------------
1 | @forward "./variables";
2 | @forward "./mixin";
3 | @forward "./breakpoint";
4 |
--------------------------------------------------------------------------------
/src/assets/boxicons-2.0.7/fonts/boxicons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/src/assets/boxicons-2.0.7/fonts/boxicons.eot
--------------------------------------------------------------------------------
/src/assets/boxicons-2.0.7/fonts/boxicons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/src/assets/boxicons-2.0.7/fonts/boxicons.ttf
--------------------------------------------------------------------------------
/src/assets/boxicons-2.0.7/fonts/boxicons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/src/assets/boxicons-2.0.7/fonts/boxicons.woff
--------------------------------------------------------------------------------
/src/assets/boxicons-2.0.7/fonts/boxicons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hicmtrex/Tmovies/HEAD/src/assets/boxicons-2.0.7/fonts/boxicons.woff2
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 |
5 | ReactDOM.render(
6 |
7 |
8 | ,
9 | document.getElementById('root')
10 | );
11 |
--------------------------------------------------------------------------------
/src/scss/_mixin.scss:
--------------------------------------------------------------------------------
1 | @mixin flex($aligin-item, $justify-content) {
2 | display: flex;
3 | align-items: $aligin-item;
4 | justify-content: $justify-content;
5 | }
6 |
7 | @mixin overlay {
8 | background-color: rgba($color: #000000, $alpha: 0.6);
9 | }
10 |
--------------------------------------------------------------------------------
/src/components/input/input.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/variables" as *;
2 |
3 | input {
4 | border: 0;
5 | background-color: $black;
6 | padding: 0.5rem 1.5rem;
7 | font-size: 1rem;
8 | border-radius: $border-radius;
9 | color: $txt-color;
10 | font-family: $font-family;
11 | }
12 |
--------------------------------------------------------------------------------
/src/scss/_breakpoint.scss:
--------------------------------------------------------------------------------
1 | @use "./variables" as *;
2 |
3 | @mixin mobile {
4 | @media only screen and (max-width: $mobile-width) {
5 | @content;
6 | }
7 | }
8 |
9 | @mixin tablet {
10 | @media only screen and (max-width: $tablet-width) {
11 | @content;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/components/movie-list/movie-list.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/breakpoint" as *;
2 |
3 | .movie-list {
4 | .swiper-slide {
5 | width: 15%;
6 |
7 | @include tablet {
8 | width: 30%;
9 | }
10 |
11 | @include mobile {
12 | width: 40%;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/api/apiConfig.js:
--------------------------------------------------------------------------------
1 | const apiConfig = {
2 | baseUrl: 'https://api.themoviedb.org/3/',
3 | apiKey: process.env.REACT_APP_API_KEY,
4 | originalImage: (imgPath) => `https://image.tmdb.org/t/p/original/${imgPath}`,
5 | w500Image: (imgPath) => `https://image.tmdb.org/t/p/w500/${imgPath}`,
6 | };
7 |
8 | export default apiConfig;
9 |
--------------------------------------------------------------------------------
/src/scss/_variables.scss:
--------------------------------------------------------------------------------
1 | $body-bg: #0f0f0f;
2 | $main-color: #ff0000;
3 | $txt-color: #fff;
4 |
5 | $white: #fff;
6 | $black: #000;
7 |
8 | $box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
9 |
10 | $header-height: 8rem;
11 | $header-shrink-height: 5rem;
12 | $border-radius: 30px;
13 |
14 | $mobile-width: 600px;
15 | $tablet-width: 1024px;
16 |
17 | $font-family: "Montserrat", sans-serif;
18 |
--------------------------------------------------------------------------------
/src/assets/boxicons-2.0.7/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Boxicons License
2 | -------------------------Boxicons is an open source project , you can use them in your commercial projects too.
3 | The icons (.svg) files are free to download are licensed under CC 4.0 .
4 | The fonts files are licensed under SIL OFL 1.1
5 | Attribution is not required but is appreciated
6 | Other files which are not fonts or icons are licensed under the MIT License
--------------------------------------------------------------------------------
/src/components/input/Input.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import './input.scss';
4 |
5 | const Input = props => {
6 | return (
7 | props.onChange(e) : null}
12 | />
13 | );
14 | }
15 |
16 | export default Input;
17 |
--------------------------------------------------------------------------------
/src/components/page-header/PageHeader.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import './page-header.scss';
4 |
5 | import bg from '../../assets/footer-bg.jpg';
6 |
7 | const PageHeader = props => {
8 | return (
9 |
10 |
{props.children}
11 |
12 | );
13 | }
14 |
15 |
16 | export default PageHeader;
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env
18 | .env.development.local
19 | .env.test.local
20 | .env.production.local
21 |
22 | npm-debug.log*
23 | yarn-debug.log*
24 | yarn-error.log*
25 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import 'swiper/swiper.min.css';
2 | import './assets/boxicons-2.0.7/css/boxicons.min.css';
3 | import './App.scss';
4 |
5 | import { BrowserRouter, Route } from 'react-router-dom';
6 |
7 | import Header from './components/header/Header';
8 | import Footer from './components/footer/Footer';
9 |
10 | import Routes from './config/Routes';
11 |
12 | function App() {
13 | return (
14 |
15 | (
17 | <>
18 |
19 |
20 |
21 | >
22 | )}
23 | />
24 |
25 | );
26 | }
27 |
28 | export default App;
29 |
--------------------------------------------------------------------------------
/src/components/page-header/page-header.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/variables" as *;
2 |
3 | .page-header {
4 | padding: $header-height 0 2rem;
5 | text-align: center;
6 | margin-bottom: 2rem;
7 |
8 | position: relative;
9 |
10 | background-position: top;
11 | background-size: cover;
12 | background-repeat: no-repeat;
13 |
14 | h2 {
15 | position: relative;
16 | z-index: 99;
17 | }
18 |
19 | &::after {
20 | content: "";
21 | position: absolute;
22 | bottom: 0;
23 | left: 0;
24 | width: 100%;
25 | height: 100px;
26 | background-image: linear-gradient(to top, $body-bg, rgba($black, 0));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/api/axiosClient.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 | import queryString from 'query-string';
3 |
4 | import apiConfig from './apiConfig';
5 |
6 | const axiosClient = axios.create({
7 | baseURL: apiConfig.baseUrl,
8 | headers: {
9 | 'Content-Type': 'application/json'
10 | },
11 | paramsSerializer: params => queryString.stringify({...params, api_key: apiConfig.apiKey})
12 | });
13 |
14 | axiosClient.interceptors.request.use(async (config) => config);
15 |
16 | axiosClient.interceptors.response.use((response) => {
17 | if (response && response.data) {
18 | return response.data;
19 | }
20 |
21 | return response;
22 | }, (error) => {
23 | throw error;
24 | });
25 |
26 | export default axiosClient;
--------------------------------------------------------------------------------
/src/pages/Catalog.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import { useParams } from 'react-router';
4 |
5 | import PageHeader from '../components/page-header/PageHeader';
6 |
7 | import { category as cate } from '../api/tmdbApi';
8 | import MovieGrid from '../components/movie-grid/MovieGrid';
9 |
10 | const Catalog = () => {
11 |
12 | const { category } = useParams();
13 |
14 | return (
15 | <>
16 |
17 | {category === cate.movie ? 'Movies' : 'TV Series'}
18 |
19 |
24 | >
25 | );
26 | }
27 |
28 | export default Catalog;
29 |
--------------------------------------------------------------------------------
/src/assets/boxicons-2.0.7/css/transformations.css:
--------------------------------------------------------------------------------
1 | .bx-rotate-90
2 | {
3 | transform: rotate(90deg);
4 |
5 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=1)';
6 | }
7 | .bx-rotate-180
8 | {
9 | transform: rotate(180deg);
10 |
11 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2)';
12 | }
13 | .bx-rotate-270
14 | {
15 | transform: rotate(270deg);
16 |
17 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=3)';
18 | }
19 | .bx-flip-horizontal
20 | {
21 | transform: scaleX(-1);
22 |
23 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)';
24 | }
25 | .bx-flip-vertical
26 | {
27 | transform: scaleY(-1);
28 |
29 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)';
30 | }
31 |
--------------------------------------------------------------------------------
/src/components/button/Button.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | import './button.scss';
5 |
6 | const Button = props => {
7 | return (
8 |
14 | );
15 | }
16 |
17 | export const OutlineButton = props => {
18 | return (
19 |
25 | );
26 | }
27 |
28 | Button.propTypes = {
29 | onClick: PropTypes.func
30 | }
31 |
32 | export default Button;
33 |
--------------------------------------------------------------------------------
/src/components/movie-grid/movie-grid.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/" as *;
2 |
3 | .movie-grid {
4 | display: grid;
5 | grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
6 | gap: 20px;
7 | margin-bottom: 3rem;
8 |
9 | @include tablet {
10 | grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
11 | }
12 |
13 | &__loadmore {
14 | text-align: center;
15 | }
16 | }
17 |
18 | .movie-search {
19 | position: relative;
20 | width: 100%;
21 | max-width: 500px;
22 |
23 | input {
24 | width: 100%;
25 | padding-right: 8rem;
26 | }
27 |
28 | button {
29 | position: absolute;
30 | right: 0;
31 | top: 2px;
32 |
33 | @include mobile {
34 | right: 1px;
35 | top: 1px;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/config/Routes.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import { Route, Switch } from 'react-router-dom';
4 |
5 | import Home from '../pages/Home';
6 | import Catalog from '../pages/Catalog';
7 | import Detail from '../pages/detail/Detail';
8 |
9 | const Routes = () => {
10 | return (
11 |
12 |
16 |
20 |
24 |
29 |
30 | );
31 | }
32 |
33 | export default Routes;
34 |
--------------------------------------------------------------------------------
/src/components/movie-card/MovieCard.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import './movie-card.scss';
4 |
5 | import { Link } from 'react-router-dom';
6 |
7 | import Button from '../button/Button';
8 |
9 | import { category } from '../../api/tmdbApi';
10 | import apiConfig from '../../api/apiConfig';
11 |
12 | const MovieCard = props => {
13 |
14 | const item = props.item;
15 |
16 | const link = '/' + category[props.category] + '/' + item.id;
17 |
18 | const bg = apiConfig.w500Image(item.poster_path || item.backdrop_path);
19 |
20 | return (
21 |
22 |
23 |
26 |
27 | {item.title || item.name}
28 |
29 | );
30 | }
31 |
32 | export default MovieCard;
33 |
--------------------------------------------------------------------------------
/src/components/footer/footer.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/" as *;
2 |
3 | .footer {
4 | position: relative;
5 | padding: 6rem 2rem;
6 | background-position: top;
7 | background-size: cover;
8 | background-repeat: no-repeat;
9 |
10 | &__content {
11 | max-width: 1000px;
12 |
13 | &__logo {
14 | @include flex(center, center);
15 | margin-bottom: 3rem;
16 | }
17 |
18 | &__menus {
19 | display: grid;
20 | grid-template-columns: repeat(3, 1fr);
21 |
22 | @include mobile {
23 | grid-template-columns: repeat(2, 1fr);
24 | }
25 | }
26 |
27 | &__menu {
28 | @include flex(flex-start, flex-start);
29 | flex-direction: column;
30 | margin-top: 1rem;
31 |
32 | font-size: 1.5rem;
33 | font-weight: 600;
34 |
35 | & > * ~ * {
36 | margin-top: 1rem;
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/components/button/button.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/" as *;
2 |
3 | button {
4 | cursor: pointer;
5 | font-family: $font-family;
6 | }
7 |
8 | .btn {
9 | border: 4px solid transparent;
10 | background-color: $main-color;
11 | color: $white;
12 | border-radius: $border-radius;
13 | padding: 0.5rem 1.8rem;
14 | font-size: 1.5rem;
15 | font-weight: 600;
16 | box-shadow: 0px 0px 7px 8px #ff00004d;
17 | transition: box-shadow 0.3s ease;
18 | position: relative;
19 | }
20 |
21 | .btn:hover {
22 | box-shadow: 0px 0px 7px 15px #ff00004d;
23 | }
24 |
25 | .btn-outline {
26 | border: 3px solid $white;
27 | background-color: transparent;
28 | color: $white;
29 | box-shadow: unset;
30 | transition: color 0.3s ease, background-color 0.3s ease;
31 | }
32 |
33 | .btn-outline:hover {
34 | box-shadow: unset;
35 | color: $main-color;
36 | background-color: $white;
37 | }
38 |
39 | .btn.small {
40 | border-width: 2px;
41 | padding: 0.25rem 1.5rem;
42 | font-size: 1rem;
43 | }
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-movie
2 |
3 | Responsive React Movies App With API
4 |
5 | # Resource
6 |
7 | Google font: https://fonts.google.com/
8 |
9 | Boxicons: https://boxicons.com/
10 |
11 | Images: https://unsplash.com/
12 |
13 | API: https://www.themoviedb.org/
14 |
15 | # Preview
16 |
17 | 
18 |
19 | 
20 |
21 | 
22 |
23 | 
24 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tmovies",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.14.1",
7 | "@testing-library/react": "^11.2.7",
8 | "@testing-library/user-event": "^12.8.3",
9 | "axios": "^0.22.0",
10 | "query-string": "^7.0.1",
11 | "react": "^17.0.2",
12 | "react-dom": "^17.0.2",
13 | "react-router-dom": "^5.3.0",
14 | "react-scripts": "4.0.3",
15 | "sass": "^1.42.1",
16 | "swiper": "^6.8.4",
17 | "web-vitals": "^1.1.2"
18 | },
19 | "scripts": {
20 | "start": "react-scripts start",
21 | "build": "react-scripts build",
22 | "test": "react-scripts test",
23 | "eject": "react-scripts eject"
24 | },
25 | "eslintConfig": {
26 | "extends": [
27 | "react-app",
28 | "react-app/jest"
29 | ]
30 | },
31 | "browserslist": {
32 | "production": [
33 | ">0.2%",
34 | "not dead",
35 | "not op_mini all"
36 | ],
37 | "development": [
38 | "last 1 chrome version",
39 | "last 1 firefox version",
40 | "last 1 safari version"
41 | ]
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/components/movie-card/movie-card.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/" as *;
2 |
3 | .movie-card {
4 | position: relative;
5 | background-position: top;
6 | background-repeat: no-repeat;
7 | background-size: cover;
8 | padding-top: 160%;
9 | border-radius: $border-radius;
10 | margin-bottom: 1rem;
11 |
12 | .btn {
13 | position: absolute;
14 | top: 50%;
15 | left: 50%;
16 | transform: translate(-50%, -50%) scale(0);
17 | transition: transform 0.3s ease, box-shadow 0.3s ease;
18 | }
19 |
20 | &::before {
21 | content: "";
22 | position: absolute;
23 | top: 0;
24 | left: 0;
25 | bottom: 0;
26 | right: 0;
27 | background-color: $black;
28 | opacity: 0;
29 | transition: opacity 0.3s ease;
30 | border-radius: $border-radius;
31 | }
32 |
33 | @media (hover: hover) and (pointer: fine) {
34 | &:hover::before {
35 | opacity: 0.8;
36 | }
37 |
38 | &:hover .btn {
39 | transform: translate(-50%, -50%) scale(1);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/pages/detail/CastList.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 |
3 | import { useParams } from 'react-router';
4 |
5 | import tmdbApi from '../../api/tmdbApi';
6 | import apiConfig from '../../api/apiConfig';
7 |
8 | const CastList = props => {
9 |
10 | const {category} = useParams();
11 |
12 | const [casts, setCasts] = useState([]);
13 |
14 | useEffect(() => {
15 | const getCredits = async () => {
16 | const res = await tmdbApi.credits(category, props.id);
17 | setCasts(res.cast.slice(0, 5));
18 | }
19 | getCredits();
20 | }, [category, props.id]);
21 | return (
22 |
23 | {
24 | casts.map((item, i) => (
25 |
26 |
27 |
{item.name}
28 |
29 | ))
30 | }
31 |
32 | );
33 | }
34 |
35 | export default CastList;
36 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
16 | T Movies
17 |
18 |
19 |
20 |
21 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/components/modal/modal.scss:
--------------------------------------------------------------------------------
1 | @use "../../scss/" as *;
2 |
3 | .modal {
4 | @include flex(center, center);
5 | position: fixed;
6 | z-index: 100;
7 | top: 0;
8 | left: 0;
9 | right: 0;
10 | bottom: 0;
11 | overflow: auto;
12 | background-color: rgba($color: $black, $alpha: 0.4);
13 | opacity: 0;
14 | visibility: hidden;
15 |
16 | &.active {
17 | opacity: 1;
18 | visibility: visible;
19 | }
20 |
21 | &__content {
22 | padding: 2rem;
23 | background-color: $body-bg;
24 | width: 50%;
25 | opacity: 0;
26 | transform: translateY(-250px);
27 | transition: transform 0.6s ease, opacity 0.6s ease;
28 | position: relative;
29 |
30 | @include tablet {
31 | width: 80%;
32 | }
33 |
34 | &__close {
35 | position: absolute;
36 | right: 5px;
37 | top: 5px;
38 | font-size: 1.5rem;
39 | cursor: pointer;
40 |
41 | &:hover {
42 | color: $main-color;
43 | }
44 | }
45 | }
46 |
47 | &.active &__content {
48 | opacity: 1;
49 | transform: translateY(0);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/components/modal/Modal.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect, useRef } from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | import './modal.scss';
5 |
6 | const Modal = props => {
7 |
8 | const [active, setActive] = useState(false);
9 |
10 | useEffect(() => {
11 | setActive(props.active);
12 | }, [props.active]);
13 |
14 | return (
15 |
16 | {props.children}
17 |
18 | );
19 | }
20 |
21 | Modal.propTypes = {
22 | active: PropTypes.bool,
23 | id: PropTypes.string
24 | }
25 |
26 | export const ModalContent = props => {
27 |
28 | const contentRef = useRef(null);
29 |
30 | const closeModal = () => {
31 | contentRef.current.parentNode.classList.remove('active');
32 | if (props.onClose) props.onClose();
33 | }
34 |
35 | return (
36 |
37 | {props.children}
38 |
39 |
40 |
41 |
42 | )
43 | }
44 |
45 | ModalContent.propTypes = {
46 | onClose: PropTypes.func
47 | }
48 |
49 | export default Modal;
50 |
--------------------------------------------------------------------------------
/src/App.scss:
--------------------------------------------------------------------------------
1 | @use "./scss/" as *;
2 |
3 | @import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;900&display=swap");
4 |
5 | * {
6 | padding: 0;
7 | margin: 0;
8 | box-sizing: border-box;
9 | -webkit-tap-highlight-color: transparent;
10 | }
11 |
12 | html {
13 | font-size: 100%;
14 |
15 | @include tablet {
16 | font-size: 80%;
17 | }
18 |
19 | @include mobile {
20 | font-size: 60%;
21 | }
22 | }
23 |
24 | body {
25 | font-family: $font-family;
26 | font-weight: 400;
27 | line-height: 1.5;
28 |
29 | background-color: $body-bg;
30 | color: $txt-color;
31 |
32 | @include mobile {
33 | margin-bottom: 3rem;
34 | }
35 | }
36 |
37 | a {
38 | text-decoration: none;
39 | color: unset;
40 | }
41 |
42 | @media (hover: hover) {
43 | a:hover {
44 | color: $main-color;
45 | }
46 | }
47 |
48 | button,
49 | input {
50 | outline: 0;
51 | }
52 |
53 | ul {
54 | list-style-type: none;
55 | }
56 |
57 | img {
58 | max-width: 100%;
59 | }
60 |
61 | iframe {
62 | border: 0;
63 | }
64 |
65 | .container {
66 | max-width: 1660px;
67 | margin: auto;
68 | }
69 |
70 | .mb-3 {
71 | margin-bottom: 3rem;
72 | }
73 |
74 | .mb-2 {
75 | margin-bottom: 2rem;
76 | }
77 |
78 | .section {
79 | padding: 0 2rem;
80 | }
81 |
82 | .section__header {
83 | @include flex(center, space-between);
84 | }
85 |
--------------------------------------------------------------------------------
/src/api/tmdbApi.js:
--------------------------------------------------------------------------------
1 | import axiosClient from "./axiosClient";
2 |
3 | export const category = {
4 | movie: 'movie',
5 | tv: 'tv'
6 | }
7 |
8 | export const movieType = {
9 | upcoming: 'upcoming',
10 | popular: 'popular',
11 | top_rated: 'top_rated'
12 | }
13 |
14 | export const tvType = {
15 | popular: 'popular',
16 | top_rated: 'top_rated',
17 | on_the_air: 'on_the_air'
18 | }
19 |
20 | const tmdbApi = {
21 | getMoviesList: (type, params) => {
22 | const url = 'movie/' + movieType[type];
23 | return axiosClient.get(url, params);
24 | },
25 | getTvList: (type, params) => {
26 | const url = 'tv/' + tvType[type];
27 | return axiosClient.get(url, params);
28 | },
29 | getVideos: (cate, id) => {
30 | const url = category[cate] + '/' + id + '/videos';
31 | return axiosClient.get(url, {params: {}});
32 | },
33 | search: (cate, params) => {
34 | const url = 'search/' + category[cate];
35 | return axiosClient.get(url, params);
36 | },
37 | detail: (cate, id, params) => {
38 | const url = category[cate] + '/' + id;
39 | return axiosClient.get(url, params);
40 | },
41 | credits: (cate, id) => {
42 | const url = category[cate] + '/' + id + '/credits';
43 | return axiosClient.get(url, {params: {}});
44 | },
45 | similar: (cate, id) => {
46 | const url = category[cate] + '/' + id + '/similar';
47 | return axiosClient.get(url, {params: {}});
48 | },
49 | }
50 |
51 | export default tmdbApi;
--------------------------------------------------------------------------------
/src/pages/detail/VideoList.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect, useRef } from 'react';
2 |
3 | import { useParams } from 'react-router';
4 |
5 | import tmdbApi from '../../api/tmdbApi';
6 |
7 | const VideoList = props => {
8 |
9 | const {category} = useParams();
10 |
11 | const [videos, setVideos] = useState([]);
12 |
13 | useEffect(() => {
14 | const getVideos = async () => {
15 | const res = await tmdbApi.getVideos(category, props.id);
16 | setVideos(res.results.slice(0, 5));
17 | }
18 | getVideos();
19 | }, [category, props.id]);
20 |
21 | return (
22 | <>
23 | {
24 | videos.map((item, i) => (
25 |