├── public
├── robots.txt
├── favicon.ico
├── logo192.png
├── logo512.png
├── manifest.json
└── index.html
├── src
├── pages
│ ├── index.js
│ ├── Search.jsx
│ ├── View.jsx
│ └── Main.jsx
├── setupTests.js
├── App.test.js
├── index.css
├── reportWebVitals.js
├── components
│ ├── common
│ │ ├── styles
│ │ │ ├── navbar.css
│ │ │ ├── footer.css
│ │ │ └── header.css
│ │ ├── Footer.jsx
│ │ ├── Header.jsx
│ │ └── Navbar.jsx
│ ├── content
│ │ ├── PlayerView.jsx
│ │ ├── VideoRow.jsx
│ │ ├── styles
│ │ │ ├── videoRow.css
│ │ │ ├── contentRow.css
│ │ │ ├── recomendation.css
│ │ │ ├── preview.css
│ │ │ ├── playerView.css
│ │ │ └── contentTrending.css
│ │ ├── Preview.jsx
│ │ ├── Details.jsx
│ │ ├── ContentTrending.jsx
│ │ ├── ContentRow.jsx
│ │ ├── Recomendation.jsx
│ │ └── SearchResults.jsx
│ ├── index.js
│ └── minor
│ │ ├── SearchForm.jsx
│ │ └── styles
│ │ └── searchForm.css
├── index.js
├── App.js
├── actions
│ └── movie.js
└── style.css
├── .gitignore
├── package.json
└── README.md
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/James-Zamora/movie_trailer_website/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/James-Zamora/movie_trailer_website/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/James-Zamora/movie_trailer_website/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/src/pages/index.js:
--------------------------------------------------------------------------------
1 | import Main from "./Main";
2 | import View from "./View";
3 | import Search from "./Search";
4 |
5 | export {
6 | Main,
7 | View,
8 | Search,
9 | }
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/.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.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/src/components/common/styles/navbar.css:
--------------------------------------------------------------------------------
1 | nav {
2 | background: linear-gradient(to top, transparent 0%, rgb(0, 0, 0, 0.75) 50%);
3 | height: 100px;
4 | position: relative;
5 | z-index: 10;
6 | }
7 |
8 | nav .logo svg {
9 | width: 10rem;
10 | fill: #e50914;
11 | }
12 |
13 | nav .container {
14 | display: flex;
15 | flex-direction: row;
16 | justify-content: space-between;
17 | align-items: center;
18 | height: 100%;
19 | }
20 |
21 | @media (max-width: 478px) {
22 | nav .logo svg {
23 | width: 5rem;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/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 { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
2 | import { Main, View, Search } from './pages'
3 | import { Footer, Navbar } from './components'
4 | import './style.css'
5 |
6 | function App() {
7 | return (
8 | <>
9 |
10 |
11 |
12 | } />
13 | } />
14 | } />
15 |
16 |
17 |
18 | >
19 | );
20 | }
21 |
22 | export default App;
23 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Netflix Trailers
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/components/content/PlayerView.jsx:
--------------------------------------------------------------------------------
1 | import './styles/playerView.css'
2 |
3 | const PlayerView = ({ trailer, movie }) => {
4 | return (
5 |
6 |
7 | {trailer &&
8 |
16 | }
17 |
18 |
19 | )
20 | }
21 |
22 | export default PlayerView
--------------------------------------------------------------------------------
/src/components/index.js:
--------------------------------------------------------------------------------
1 | import Header from './common/Header'
2 | import Navbar from './common/Navbar'
3 | import Footer from './common/Footer'
4 | import Preview from './content/Preview'
5 | import ContentRow from './content/ContentRow'
6 | import ContentTrending from './content/ContentTrending'
7 | import PlayerView from './content/PlayerView'
8 | import Recomendation from './content/Recomendation'
9 | import VideoRow from './content/VideoRow'
10 | import Details from './content/Details'
11 | import SearchForm from './minor/SearchForm'
12 | import SearchResults from './content/SearchResults'
13 |
14 | export {
15 | Header,
16 | Navbar,
17 | Footer,
18 | Preview,
19 | ContentRow,
20 | ContentTrending,
21 | PlayerView,
22 | Recomendation,
23 | VideoRow,
24 | Details,
25 | SearchForm,
26 | SearchResults,
27 | }
--------------------------------------------------------------------------------
/src/pages/Search.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useRef } from "react"
2 | import { SearchResults, SearchForm, Preview } from "../components"
3 |
4 | const Search = () => {
5 |
6 | const preview = useRef()
7 | const [item, setItem] = useState()
8 | const [items, setItems] = useState(null)
9 | const [isLoading, setIsLoading] = useState(false)
10 | const [type, setType] = useState('movie')
11 |
12 | return (
13 | <>
14 |
19 | >
20 | )
21 | }
22 |
23 | export default Search
--------------------------------------------------------------------------------
/src/components/common/styles/footer.css:
--------------------------------------------------------------------------------
1 | footer {
2 | border-top: 8px solid #222222;
3 | min-height: 400px;
4 | padding-bottom: 50px;
5 | }
6 |
7 | footer .container {
8 | max-width: 700px;
9 | margin: 0 auto;
10 | }
11 |
12 | .footer-top h5 {
13 | font-size: 1.2rem;
14 | opacity: 0.75;
15 | margin-top: 50px;
16 | }
17 |
18 | .footer-links {
19 | margin-top: 50px;
20 | }
21 |
22 | .footer-links ul {
23 | display: grid;
24 | grid-template-columns: repeat(3, 1fr);
25 | gap: 25px;
26 | align-items: center;
27 | }
28 |
29 | .footer-links ul li {
30 | text-decoration: none;
31 | list-style: none;
32 | }
33 |
34 | .footer-links ul li a {
35 | text-decoration: none;
36 | color: #ffffff;
37 | opacity: .75;
38 | }
39 |
40 | @media (max-width: 768px) {
41 | .footer-links ul {
42 | grid-template-columns: repeat(2, 1fr);
43 | }
44 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "movie_trailer_app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.2",
7 | "@testing-library/react": "^12.1.3",
8 | "@testing-library/user-event": "^13.5.0",
9 | "axios": "^0.26.0",
10 | "react": "^17.0.2",
11 | "react-dom": "^17.0.2",
12 | "react-router-dom": "^6.2.2",
13 | "react-scripts": "5.0.0",
14 | "web-vitals": "^2.1.4"
15 | },
16 | "scripts": {
17 | "start": "react-scripts start",
18 | "build": "react-scripts build",
19 | "test": "react-scripts test",
20 | "eject": "react-scripts eject"
21 | },
22 | "eslintConfig": {
23 | "extends": [
24 | "react-app",
25 | "react-app/jest"
26 | ]
27 | },
28 | "browserslist": {
29 | "production": [
30 | ">0.2%",
31 | "not dead",
32 | "not op_mini all"
33 | ],
34 | "development": [
35 | "last 1 chrome version",
36 | "last 1 firefox version",
37 | "last 1 safari version"
38 | ]
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/components/minor/SearchForm.jsx:
--------------------------------------------------------------------------------
1 | import { useState } from "react"
2 | import { getSearch } from "../../actions/movie"
3 | import './styles/searchForm.css'
4 |
5 | const SearchForm = ({ setItems, setIsLoading, setType, type }) => {
6 |
7 | const [searchText, setSearchText] = useState('')
8 |
9 |
10 | const search = () => {
11 | setIsLoading(true)
12 | if(searchText != '') {
13 | getSearch(searchText, type).then((res) => {setItems(res.results); setIsLoading(false);})
14 | }
15 | }
16 |
17 | return (
18 |
26 | )
27 | }
28 |
29 | export default SearchForm
--------------------------------------------------------------------------------
/src/components/common/Footer.jsx:
--------------------------------------------------------------------------------
1 | import './styles/footer.css'
2 |
3 | const Footer = () => {
4 | return (
5 |
28 | )
29 | }
30 |
31 | export default Footer
--------------------------------------------------------------------------------
/src/components/content/VideoRow.jsx:
--------------------------------------------------------------------------------
1 | import { useRef } from 'react'
2 | import './styles/videoRow.css'
3 |
4 | const VideoRow = ({ trailers, setTrailer }) => {
5 | const videoRow = useRef()
6 |
7 | const onWheel = (e) => {
8 | if (e.deltaY > 0) {
9 | videoRow.current.scrollLeft += 100
10 | } else {
11 | videoRow.current.scrollLeft -= 100
12 | }
13 | }
14 |
15 | return (
16 |
17 | MORE TRAILERS
18 |
22 | {trailers.map((item, index) => {
23 | if(item.official) {
24 | return (
25 |
{setTrailer(item); window.scrollTo(0, 0)}}>
26 |

27 |
28 | {item.name}
29 |
30 |
31 | )
32 | }
33 | })}
34 |
35 |
36 | )
37 | }
38 |
39 | export default VideoRow
--------------------------------------------------------------------------------
/src/components/content/styles/videoRow.css:
--------------------------------------------------------------------------------
1 | .video-row {
2 | margin: 100px auto;
3 | }
4 |
5 | .video-row .video-row-container {
6 | display: flex;
7 | flex-wrap: nowrap;
8 | overflow-x: scroll;
9 | overscroll-behavior: contain;
10 | }
11 |
12 | .video-row .video-row-container::-webkit-scrollbar {
13 | width: 1px;
14 | }
15 |
16 | .video-row .video-row-container::-webkit-scrollbar-track {
17 | background: #000000;
18 | width: 1px;
19 | }
20 |
21 | .video-row .video-row-container::-webkit-scrollbar-thumb {
22 | background-color: #000000;
23 | border-radius: 10px;
24 | border: 2px solid #222;
25 | }
26 |
27 | .video-row .card {
28 | margin-right: 15px;
29 | margin-bottom: 15px;
30 | border-radius: 5px;
31 | box-shadow: 0 2px 5px 0 #222222;
32 | width: 500px;
33 | }
34 |
35 | .video-row img {
36 | height: 350px;
37 | width: inherit;
38 | object-fit: cover;
39 | }
40 |
41 | .video-row .video-row-container h3 {
42 | width: 100%;
43 | height: 100px;
44 | padding: 15px;
45 | text-align: center;
46 | display: flex;
47 | justify-content: center;
48 | align-items: center;
49 | }
50 |
51 | @media (max-width: 768px) {
52 | .video-row .card {
53 | width: 300px;
54 | }
55 |
56 | .video-row .video-row-container {
57 | overflow-x: scroll;
58 | overscroll-behavior: unset;
59 | }
60 | }
--------------------------------------------------------------------------------
/src/components/minor/styles/searchForm.css:
--------------------------------------------------------------------------------
1 | .search-form {
2 | display: flex;
3 | justify-content: center;
4 | align-items: center;
5 | margin: 50px 0;
6 | }
7 |
8 | .search-form select {
9 | height: 50px;
10 | width: 120px;
11 | font-size: 1rem;
12 | flex-grow: 0;
13 | border-top-left-radius: 5px;
14 | border-bottom-left-radius: 5px;
15 | padding: 0 15px;
16 | border: none;
17 | }
18 |
19 | .search-form select:focus,
20 | .search-form select::after {
21 | border: none;
22 | outline: none;
23 | }
24 |
25 | .search-form input {
26 | height: 50px;
27 | font-size: 1rem;
28 | border: none;
29 | padding: 15px;
30 | flex-grow: 1;
31 | max-width: 600px;
32 | min-width: 50px;
33 | }
34 |
35 | .search-form button {
36 | flex-grow: 0;
37 | border-top-left-radius: 0px;
38 | border-bottom-left-radius: 0px;
39 | height: 50px;
40 | }
41 |
42 | .search-form input:focus {
43 | outline: none;
44 | }
45 |
46 | @media (max-width: 768px) {
47 | .search-form {
48 | flex-direction: column;
49 | }
50 | .search-form select {
51 | width: 100%;
52 | border-radius: 5px;
53 | }
54 | .search-form input {
55 | border-radius: 5px;
56 | margin: 15px 0;
57 | width: 100%;
58 | }
59 | .search-form button {
60 | border-radius: 5px;
61 | width: 100%;
62 | }
63 | }
--------------------------------------------------------------------------------
/src/pages/View.jsx:
--------------------------------------------------------------------------------
1 | import { useRef, useState, useEffect } from 'react'
2 | import { useParams } from 'react-router-dom'
3 | import { PlayerView, Recomendation, Preview, VideoRow, Details } from '../components'
4 | import { getMovieVideos, getMovieById } from '../actions/movie'
5 |
6 | const View = () => {
7 | const preview = useRef()
8 | const params = useParams()
9 |
10 | const [item, setItem] = useState()
11 | const [movie, setMovie] = useState(null)
12 | const [trailer, setTrailer] = useState(null)
13 | const [trailers, setTrailers] = useState(null)
14 |
15 | useEffect(() => {
16 | window.scrollTo(0, 0)
17 | getMovieVideos(params.id, params.type).then(res => { setTrailers(res); setTrailer(res[0]); })
18 | getMovieById(params.id, params.type).then(res => { setMovie(res) })
19 | }, [params])
20 |
21 | return (
22 |
23 |
24 |
25 |
26 | {trailers && trailers.length > 1 &&
27 |
28 | }
29 |
30 |
31 |
32 |
33 | )
34 |
35 | }
36 |
37 | export default View
--------------------------------------------------------------------------------
/src/components/content/styles/contentRow.css:
--------------------------------------------------------------------------------
1 | .content-row {
2 | margin: 55px 0;
3 | }
4 |
5 | .content-row .cards {
6 | display: flex;
7 | margin-top: 15px;
8 | overflow-x: scroll;
9 | flex-wrap: nowrap;
10 | white-space: nowrap;
11 | overscroll-behavior: contain;
12 | }
13 |
14 | .content-row .cards .card {
15 | margin-right: 15px;
16 | margin-bottom: 10px;
17 | -webkit-user-select: none;
18 | -khtml-user-select: none;
19 | -moz-user-select: none;
20 | -o-user-select: none;
21 | user-select: none;
22 | transition: .3s;
23 | }
24 | .content-row .card:hover {
25 | opacity: 75%;
26 | }
27 |
28 | .content-row .title h3 {
29 | font-size: 1.5rem;
30 | }
31 |
32 | .content-row .cards .card:last-of-type {
33 | margin-right: 0px;
34 | }
35 |
36 | .content-row .card img {
37 | width: 300px;
38 | height: 500px;
39 | border-radius: 5px;
40 | object-fit: cover;
41 | box-shadow: 0 2px 5px 0 #222222;
42 | }
43 |
44 | .content-row .cards::-webkit-scrollbar {
45 | width: 1px;
46 | }
47 |
48 | .content-row .cards::-webkit-scrollbar-track {
49 | background: #000000;
50 | width: 1px;
51 | }
52 |
53 | .content-row .cards::-webkit-scrollbar-thumb {
54 | background-color: #000000;
55 | border-radius: 10px;
56 | border: 2px solid #222;
57 | }
58 |
59 | @media (max-width: 786px) {
60 | .content-row .cards {
61 | overscroll-behavior: unset;
62 | }
63 | }
--------------------------------------------------------------------------------
/src/pages/Main.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useRef, useState } from 'react'
2 | import { Header, ContentRow, Preview, ContentTrending } from '../components'
3 | import { getTrendingTV, getTrendingMovies } from '../actions/movie'
4 |
5 | const Main = () => {
6 |
7 | const preview = useRef()
8 | const [item, setItem] = useState()
9 | const [trendingMovies, setTrendingMovies] = useState([])
10 | const [trendingTV, setTrendingTV] = useState([])
11 |
12 |
13 | useEffect(() => {
14 | getTrendingMovies().then(res => setTrendingMovies(res))
15 | getTrendingTV().then(res => setTrendingTV(res))
16 | }, [])
17 |
18 | return (
19 | <>
20 |
21 |
26 |
27 |
32 |
33 |
34 | >
35 | )
36 |
37 | }
38 |
39 | export default Main
--------------------------------------------------------------------------------
/src/components/content/styles/recomendation.css:
--------------------------------------------------------------------------------
1 | .content-column {
2 | padding-top: 15px;
3 | padding-bottom: 100px;
4 | display: flex;
5 | flex-direction: row;
6 | flex-wrap: wrap;
7 | }
8 |
9 | .content-column .card {
10 | flex-basis: 350px;
11 | flex-grow: 1;
12 | width: 100%;
13 | margin-bottom: 15px;
14 | color: #ffffff;
15 | text-decoration: none;
16 | box-shadow: 0 2px 5px 0 #222222;
17 | border-radius: 5px;
18 | margin: 10px;
19 | transition: .3s;
20 | }
21 |
22 | .content-column .card:hover {
23 | opacity: 75%;
24 | }
25 |
26 | .content-column .card .title {
27 | display: flex;
28 | align-items: center;
29 | justify-content: space-between;
30 | padding: 10px 15px 15px 15px;
31 | }
32 |
33 | .content-column .card .title h3 {
34 | text-align: end;
35 | font-size: 1rem;
36 | font-weight: 400;
37 | }
38 |
39 | .content-column .card img {
40 | border-top-left-radius: 5px;
41 | border-top-right-radius: 5px;
42 | object-fit: cover;
43 | width: 100%;
44 | height: 500px;
45 | }
46 |
47 | .content-column h2 {
48 | font-weight: 400;
49 | font-size: 1rem;
50 | }
51 |
52 | .content-column h3 {
53 | font-size: 0.70rem;
54 | }
55 |
56 | @media (max-width: 786px) {
57 | .content-column .card .title {
58 | flex-direction: column;
59 | align-items: center;
60 | justify-content: center;
61 | }
62 | .content-column .card .title h3 {
63 | text-align: center;
64 | }
65 | }
--------------------------------------------------------------------------------
/src/actions/movie.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 |
3 | const getTrendingTV = async () => {
4 | const responce = await axios.get('https://api.themoviedb.org/3/trending/tv/week?api_key=7c22573a9bc36e843de16a41601db91f')
5 | return responce.data.results
6 | }
7 |
8 | const getTrendingMovies = async () => {
9 | const responce = await axios.get('https://api.themoviedb.org/3/trending/movie/week?api_key=7c22573a9bc36e843de16a41601db91f')
10 | return responce.data.results
11 | }
12 |
13 | const getMovieVideos = async (id, type) => {
14 | const responce = await axios.get(`https://api.themoviedb.org/3/${type}/${id}/videos?api_key=7c22573a9bc36e843de16a41601db91f`)
15 | return responce.data.results
16 | }
17 |
18 | const getMovieById = async (id, type) => {
19 | const responce = await axios.get(`https://api.themoviedb.org/3/${type}/${id}?api_key=7c22573a9bc36e843de16a41601db91f`)
20 | return responce.data
21 | }
22 |
23 | const getRecomendations = async (id, type) => {
24 | const responce = await axios.get(`https://api.themoviedb.org/3/${type}/${id}/recommendations?api_key=7c22573a9bc36e843de16a41601db91f`)
25 | return responce.data
26 | }
27 |
28 | const getSearch = async (query, type) => {
29 | const responce = await axios.get(`https://api.themoviedb.org/3/search/${type}/?query=${query}&include_adult=ture&api_key=7c22573a9bc36e843de16a41601db91f`)
30 | return responce.data
31 | }
32 |
33 | export {
34 | getTrendingMovies,
35 | getTrendingTV,
36 | getMovieVideos,
37 | getMovieById,
38 | getRecomendations,
39 | getSearch
40 | }
--------------------------------------------------------------------------------
/src/components/content/styles/preview.css:
--------------------------------------------------------------------------------
1 | .preview {
2 | height: 600px;
3 | width: 350px;
4 | border-radius: 5px;
5 | background-color: #181818;
6 | position: absolute;
7 | /* pointer-events: none; */
8 | z-index: -1;
9 | opacity: 0;
10 | transform: scale(0.80);
11 | transition-property: opacity, transform;
12 | transition-duration: 400ms;
13 | transition-timing-function: cubic-bezier(0.05,0,0,1);
14 | display: flex;
15 | flex-direction: column;
16 | box-shadow: 0 2px 5px 0 #222222;
17 | }
18 |
19 | .preview[active] {
20 | opacity: 1;
21 | transform: scale(1);
22 | z-index: 2019;
23 | }
24 |
25 | .preview .video {
26 | width: 100%;
27 | height: 500px;
28 | border-top-left-radius: 5px;
29 | border-top-right-radius: 5px;
30 | background-color: #0e0e0e;
31 | background-repeat: no-repeat;
32 | background-size: cover;
33 | background-position: center;
34 | }
35 |
36 | .preview iframe {
37 | width: 100%;
38 | height: 500px;
39 | border-top-left-radius: 5px;
40 | border-top-right-radius: 5px;
41 | border: none;
42 | }
43 |
44 | .preview iframe .video-player-frame {
45 | width: 100%!important;
46 | }
47 |
48 | .preview .btn-close {
49 | background: #222222cb;
50 | padding: 15px 20px;
51 | border-radius: 5px;
52 | position: absolute;
53 | top: 10px;
54 | right: 10px;
55 | border: 2px solid #222222;
56 | transition: .3s;
57 | cursor: pointer;
58 | user-select: none;
59 | }
60 |
61 | .preview .btn-close:hover {
62 | background: #222222;
63 | }
64 |
65 | .preview .details {
66 | width: 100%;
67 | height: 100px;
68 | padding: 15px;
69 | display: flex;
70 | justify-content: center;
71 | flex-direction: column;
72 | color: #ffffff;
73 | text-decoration: none;
74 | }
75 |
76 | .preview .details h3 {
77 | font-size: 1.3rem;
78 | }
79 |
80 | .preview .details p {
81 | margin-top: 5px;
82 | opacity: 75%;
83 | font-size: 1rem;
84 | }
85 |
86 | @media (max-width: 478px) {
87 | .preview {
88 | height: 600px;
89 | width: 90%;
90 | margin: 0 auto;
91 | }
92 | }
--------------------------------------------------------------------------------
/src/components/common/Header.jsx:
--------------------------------------------------------------------------------
1 | import { useRef } from 'react';
2 | import { Link } from 'react-router-dom'
3 | import './styles/header.css'
4 |
5 | const Header = ({ item }) => {
6 |
7 | const bgImage = useRef()
8 |
9 | window.addEventListener('scroll', () => {
10 | let scrolled = window.pageYOffset;
11 | if(bgImage.current) {
12 | bgImage.current.style.transform = `translateY(${(scrolled * 0.4 )}px)`
13 | }
14 | });
15 |
16 |
17 | return (
18 | <>
19 | {item &&
20 |
51 | }
52 | >
53 | )
54 | }
55 |
56 | export default Header
--------------------------------------------------------------------------------
/src/components/content/Preview.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState, useRef } from 'react'
2 | import { Link } from 'react-router-dom'
3 | import { getMovieVideos } from '../../actions/movie'
4 | import './styles/preview.css'
5 |
6 | const Preview = ({ item, preview }) => {
7 |
8 | const [trailer, setTrailer] = useState(null)
9 | const playerRef = useRef()
10 |
11 | useEffect(() => {
12 | if(item) {
13 | console.log(item)
14 | setTrailer(null)
15 | getMovieVideos(item.id, item.media_type).then(res => setTrailer(res[0].key))
16 | }
17 | }, [item])
18 |
19 | return (
20 | {
24 | preview.current.removeAttribute('active');
25 | playerRef.current.contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
26 | }}
27 | >
28 | {trailer ?
29 |
39 | :
40 |
41 | }
42 |
43 |
{
46 | preview.current.removeAttribute('active');
47 | playerRef.current.contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
48 | }}
49 | >Close
50 |
51 | {item &&
{ item.original_title ? item.original_title : item.name}
}
52 | {item &&
{ item.release_date ? item.release_date : 'First Air Date: ' + item.first_air_date }
}
53 |
⭐{item && item.vote_average} | Votes: {item && item.vote_count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
54 |
55 |
56 | )
57 | }
58 |
59 | export default Preview
--------------------------------------------------------------------------------
/src/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | box-sizing: border-box;
5 | }
6 |
7 | html {
8 | scroll-behavior: smooth;
9 | }
10 |
11 | body {
12 | font-family: 'Poppins', sans-serif;
13 | font-size: 16px;
14 | background-color: #000000;
15 | color: #ffffff;
16 | overflow-x: hidden;
17 | }
18 |
19 | img {
20 | user-select: none;
21 | }
22 |
23 |
24 | .container {
25 | max-width: 1450px;
26 | margin: 0 auto;
27 | padding: 0 50px;
28 | }
29 |
30 | .btn {
31 | border: none;
32 | padding: 7px 17px;
33 | line-height: normal;
34 | border-radius: 5px;
35 | font-size: 1rem;
36 | color: #000000;
37 | background-color: #ffffff;
38 | cursor: pointer;
39 | transition: .3s;
40 | user-select: none;
41 | text-decoration: none;
42 | }
43 |
44 | .btn:hover {
45 | opacity: .75;
46 | }
47 |
48 | .btn-danger {
49 | color: #ffffff;
50 | background-color: #e50914;
51 | }
52 |
53 | .btn-dark {
54 | color: #ffffff;
55 | background-color: #3b3b3bd9
56 | }
57 |
58 | .actions {
59 | display: flex;
60 | flex-wrap: wrap;
61 | }
62 |
63 | .actions .btn {
64 | margin: 15px 0;
65 | width: 150px;
66 | height: 50px;
67 | display: flex;
68 | justify-content: center;
69 | text-align: center;
70 | align-items: center;
71 | font-size: 1.25rem;
72 | }
73 |
74 | .actions .btn:nth-of-type(1) {
75 | margin-right: 10px;
76 | }
77 |
78 | .loading {
79 | font-size: 25px;
80 | opacity: 0;
81 | animation-name: opacity;
82 | animation-duration: 2s;
83 | animation-iteration-count: infinite;
84 | margin-top: 100px;
85 | margin-bottom: 200px;
86 | }
87 |
88 | @keyframes opacity {
89 | 0% {
90 | opacity: 25%;
91 | }
92 | 50% {
93 | opacity: 80%;
94 | }
95 | 100% {
96 | opacity: 25%;
97 | }
98 | }
99 |
100 | @media (max-width: 478px) {
101 |
102 | .container {
103 | padding: 0 20px;
104 | }
105 |
106 | .actions {
107 | justify-content: center;
108 | flex-flow: column;
109 | align-items: center;
110 | margin: 10px 0;
111 | }
112 |
113 | .actions .btn {
114 | margin: 5px 0;
115 | }
116 |
117 | .actions .btn {
118 | width: 100%;
119 | height: 40px;
120 | font-size: 1rem;
121 | }
122 |
123 | .actions .btn:nth-of-type(1) {
124 | margin-right: 0;
125 | }
126 |
127 | }
--------------------------------------------------------------------------------
/src/components/common/styles/header.css:
--------------------------------------------------------------------------------
1 | header {
2 | height: 650px;
3 | position: relative;
4 | border-bottom: 8px solid #222222;
5 | }
6 |
7 | header .img-wrapper {
8 | position: absolute;
9 | top: -100px;
10 | z-index: 0;
11 | overflow: hidden;
12 | bottom: 0;
13 | left: 0;
14 | right: 0;
15 | }
16 |
17 | header .img-wrapper img {
18 | height: 100%;
19 | width: 100%;
20 | object-fit: cover;
21 | display: flex;
22 | max-width: 1450px;
23 | object-position: top;
24 | margin: 0 auto;
25 | }
26 |
27 | header .img-wrapper .concord-img-gradient {
28 | top: 0;
29 | bottom: 0;
30 | right: 0;
31 | left: 0;
32 | position: absolute;
33 | margin: 0 auto;
34 | max-width: 1450px;
35 | background: rgba(0,0,0,.4);
36 | background-image: linear-gradient(90deg, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,1) 100%);
37 | }
38 |
39 | header .container {
40 | position: relative;
41 | top: 150px;
42 | width: 100%;
43 | padding: 15px 35px;
44 | margin: 0 auto;
45 | max-width: 1450px;
46 | color: #ffffff;
47 | }
48 |
49 | header .container h1,
50 | header .container .info,
51 | header .container .actions,
52 | header .container p {
53 | /* margin: 0 auto; */
54 | max-width: 500px;
55 | }
56 |
57 | header .container h1 {
58 | font-size: 4rem;
59 | }
60 |
61 | header .container .info {
62 | display: flex;
63 | flex-wrap: wrap;
64 | align-items: center;
65 | }
66 |
67 | header .container .info h3 {
68 | opacity: 75%;
69 | margin: 10px 0;
70 | }
71 |
72 | header .container .info h3.is-edult {
73 | border: 2px solid #ffffffbf;
74 | border-radius: 5px;
75 | padding: 2px 5px;
76 | }
77 |
78 | header .container .info span {
79 | height: 30px;
80 | width: 2px;
81 | margin: 0 10px;
82 | background: #ffffffbf;
83 | }
84 |
85 | header .container p {
86 | font-size: 1rem;
87 | }
88 |
89 | nav svg {
90 | fill: #ffffff;
91 | width: 15px;
92 | margin-right: 10px;
93 | }
94 |
95 | @media (max-width: 478px) {
96 |
97 | header .container {
98 | text-align: center;
99 | }
100 |
101 | header .container h1 {
102 | font-size: 2.5rem;
103 | }
104 |
105 | header .container p {
106 | font-size: 0.95rem;
107 | }
108 |
109 | header .container .info {
110 | justify-content: center;
111 | }
112 |
113 | header .container .info h3 {
114 | font-size: 1rem;
115 | }
116 |
117 | }
--------------------------------------------------------------------------------
/src/components/content/styles/playerView.css:
--------------------------------------------------------------------------------
1 | .player-view {
2 | width: 100%;
3 | height: 500px;
4 | }
5 |
6 | .player-view .video-wrapper {
7 | border-radius: 5px;
8 | background-color: #222222;
9 | width: 100%;
10 | height: 500px;
11 | }
12 |
13 | .player-view .video-wrapper iframe {
14 | width: 100%;
15 | height: inherit;
16 | border-radius: 5px;
17 | height: 500px;
18 | }
19 |
20 | .view-info {
21 | display: flex;
22 | justify-content: space-between;
23 | padding: 45px 25px;
24 | border-bottom-left-radius: 5px;
25 | border-bottom-right-radius: 5px;
26 | box-shadow: 0 2px 5px 0 #222222;
27 | }
28 |
29 | .view-info .title {
30 | flex-basis: 600px;
31 | }
32 |
33 | .view-info .title h1 {
34 | font-size: 3rem;
35 | }
36 |
37 | .view-info .title h3 {
38 | font-size: 1.5rem;
39 | margin: 25px 0;
40 | }
41 |
42 | .view-info .title p {
43 | font-size: 1rem;
44 | margin-top: 15px;
45 | }
46 |
47 | .view-info .details {
48 | flex-basis: 400px;
49 | text-align: end;
50 | font-size: 0.85rem;
51 | }
52 |
53 | .view-info h2 {
54 | font-size: 1rem;
55 | margin-bottom: 15px;
56 | text-align: right;
57 | opacity: 85%;
58 | }
59 |
60 | .view-info .details h3 {
61 | margin-bottom: 15px;
62 | font-size: 1rem;
63 | opacity: 75%;
64 | font-weight: 400;
65 | }
66 |
67 | .view-info .details a {
68 | color: #ffffff;
69 | opacity: 75%;
70 | font-size: 1rem;
71 | margin: 15px 0;
72 | font-weight: 600;
73 | }
74 |
75 | .view-info h3.is-edult {
76 | border: 2px solid #ffffffbf;
77 | border-radius: 5px;
78 | padding: 2px 5px;
79 | }
80 |
81 | .view-info p {
82 | font-size: 0.95rem;
83 | margin-bottom: 15px;
84 | max-height: 175px;
85 | overflow: hidden;
86 | }
87 |
88 | @media (max-width: 990px) {
89 |
90 | .view-info {
91 | flex-direction: column;
92 | justify-content: center;
93 | text-align: center;
94 | align-items: center;
95 | }
96 |
97 | .view-info .title {
98 | flex-basis: auto;
99 | }
100 |
101 | .view-info .title h1 {
102 | font-size: 2rem;
103 | }
104 |
105 | .view-info .details {
106 | flex-basis: auto;
107 | text-align: center;
108 | }
109 |
110 | .view-info .details h2 {
111 | font-size: 0.8rem;
112 | opacity: 75%;
113 | text-align: center;
114 | }
115 |
116 | .view-info .details h3 {
117 | font-size: 0.8rem;
118 | opacity: 75%;
119 | }
120 |
121 | }
--------------------------------------------------------------------------------
/src/components/content/Details.jsx:
--------------------------------------------------------------------------------
1 | import './styles/playerView.css'
2 |
3 | const Details = ({ movie }) => {
4 | return (
5 |
6 | {movie ?
7 | <>
8 |
9 | {movie &&
{ movie.original_title ? movie.original_title : movie.name}
}
10 |
{movie.tagline}
11 |
12 | {movie.overview}
13 |
14 |
15 |
16 |
{ movie.release_date ? movie.release_date : "Last Air Date: " + movie.last_air_date }
17 | { movie.last_air_date &&
Last Eposide: { movie.last_episode_to_air.episode_number }
}
18 | { movie.first_air_date &&
19 |
First Air Date:
20 | { movie.first_air_date }
21 |
22 | }
23 | {movie.adult &&
24 | <>
25 |
18+
26 | >
27 | }
28 |
{movie.genres.map(i=> i.name + " ")}
29 | {movie.runtime &&
Duration: { Math.floor((movie.runtime / 60))+ 'h ' + Math.round(((movie.runtime / 60) - Math.floor(movie.runtime / 60)) * 60) + 'm'}
}
30 | {movie.budget && movie.budget != 0 &&
Budget: { '$' + movie.budget.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") }
}
31 | {movie.revenue && movie.revenue != 0 &&
Revenue: { '$' + movie.revenue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") }
}
32 | {movie.production_companies &&
33 |
34 | Production:
35 | {movie.production_companies.map((item, index) => movie.production_companies.length != index+1 ? ' ' + item.name + "," : ' ' + item.name)}
36 |
37 | }
38 |
⭐{movie.vote_average} | Votes: {movie.vote_count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
39 | {movie.homepage &&
40 |
Official Website
41 | }
42 |
43 | >
44 | :
45 | Loading . . .
46 | }
47 |
48 | )
49 | }
50 |
51 | export default Details
--------------------------------------------------------------------------------
/src/components/content/ContentTrending.jsx:
--------------------------------------------------------------------------------
1 | import { Link } from 'react-router-dom'
2 | import { useRef } from 'react'
3 | import './styles/contentTrending.css'
4 |
5 | const ContentTrending = ({item}) => {
6 |
7 | const bgImage = useRef()
8 |
9 | window.addEventListener('scroll', () => {
10 | if(bgImage.current) {
11 | let scrolled = bgImage.current.offsetParent.parentElement.getBoundingClientRect().bottom - bgImage.current.clientHeight-100;
12 | bgImage.current.style.transform = `translateY(${(scrolled * 0.05 )}px)`
13 | }
14 | });
15 |
16 | return (
17 | <>
18 | {item &&
19 |
20 |
21 |
22 |
23 |

24 |
25 |
26 |
27 |
28 | {item.release_date ?
29 |
{item.release_date}
30 | :
31 |
{item.first_air_date}
32 | }
33 |
34 |
⭐{item.vote_average}
35 | {item.adult &&
36 | <>
37 |
38 | 18+
39 | >
40 | }
41 | {/* */}
42 | {/* {item.media_type.slice(0,1).toUpperCase() + item.media_type.slice(1) }
*/}
43 |
44 | {item &&
{ item.original_title ? item.original_title : item.name}
}
45 |
{item.overview}
46 |
47 |
Watch
48 |
My List
49 |
50 |
51 |
52 |
53 |
54 | }
55 | >
56 | )
57 | }
58 |
59 | export default ContentTrending
--------------------------------------------------------------------------------
/src/components/content/styles/contentTrending.css:
--------------------------------------------------------------------------------
1 | .content-trending {
2 | display: flex;
3 | flex-direction: column;
4 | justify-content: end;
5 | width: 100%;
6 | height: 750px;
7 | position: relative;
8 | padding: 30px 40px;
9 | overflow: hidden;
10 | margin: 55px 0;
11 | }
12 |
13 | .content-trending .img-wrapper {
14 | position: absolute;
15 | top: 0;
16 | z-index: 0;
17 | overflow: hidden;
18 | bottom: 0;
19 | left: 0;
20 | right: 0;
21 | }
22 |
23 | .content-trending .img-wrapper img {
24 | width: 100%;
25 | object-fit: cover;
26 | display: flex;
27 | max-width: 1450px;
28 | object-position: center;
29 | margin: 0 auto;
30 | }
31 |
32 | .content-trending .img-wrapper .concord-img-gradient {
33 | top: 0;
34 | bottom: 0;
35 | right: 0;
36 | left: 0;
37 | position: absolute;
38 | }
39 |
40 | .concord-img-gradient.g-90 {
41 | background: linear-gradient(90deg, rgba(0,0,0, 1) 0%, rgba(0,0,0, 0) 35%,rgba(0,0,0, 0) 65%, rgba(0,0,0, 1) 100%);
42 | }
43 |
44 | .concord-img-gradient.g-180 {
45 | background: linear-gradient(180deg, rgba(0,0,0, 1) 0%, rgba(0,0,0, 1) 5%,rgba(0,0,0, 0) 20%,rgba(0,0,0, 0) 80%,rgba(0,0,0, 1) 90%, rgba(0,0,0, 1) 100%);
46 | }
47 |
48 | .content-trending .info {
49 | max-width: 500px;
50 | z-index: 1;
51 | }
52 |
53 | .content-trending .info h6 {
54 | font-size: 0.85rem;
55 | font-weight: 600;
56 | margin-bottom: 15px;
57 | }
58 |
59 | .content-trending .info .details {
60 | display: flex;
61 | flex-wrap: wrap;
62 | align-items: center;
63 | font-size: 0.85rem;
64 | }
65 |
66 | .content-trending .info .details h2 {
67 | font-size: 1.3rem;
68 | margin-right: 15px;
69 | }
70 |
71 | .content-trending .info .details h3 {
72 | font-size: 1rem;
73 | opacity: 75%;
74 | }
75 |
76 | .content-trending .info .details h3.is-edult {
77 | border: 2px solid #ffffffbf;
78 | padding: 2px 5px;
79 | }
80 |
81 | .content-trending .info .details span {
82 | height: 20px;
83 | width: 2px;
84 | margin: 0 10px;
85 | background: #ffffffbf;
86 | }
87 |
88 | .content-trending .info h1 {
89 | font-size: 3rem;
90 | margin: 25px 0;
91 | }
92 |
93 | .content-trending .info p {
94 | font-size: 0.95rem;
95 | margin-bottom: 15px;
96 | max-height: 175px;
97 | overflow: hidden;
98 | }
99 |
100 | @media (max-width: 508px) {
101 |
102 | .content-trending {
103 | height: 550px;
104 | text-align: center;
105 | padding: 30px 20px;
106 | }
107 |
108 | .content-trending .info .details {
109 | justify-content: center;
110 | }
111 |
112 | .content-trending .info h1 {
113 | font-size: 2rem;
114 | margin: 25px 0;
115 | }
116 |
117 | .content-trending .info p {
118 | font-size: 0.85rem;
119 | }
120 |
121 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/src/components/common/Navbar.jsx:
--------------------------------------------------------------------------------
1 | import { Link } from 'react-router-dom'
2 | import './styles/navbar.css'
3 |
4 | const Navbar = () => {
5 | return (
6 |
29 | )
30 | }
31 |
32 | export default Navbar
--------------------------------------------------------------------------------
/src/components/content/ContentRow.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useRef } from 'react'
2 | import { Link } from 'react-router-dom'
3 | import './styles/contentRow.css'
4 |
5 | const ContentRow = ({ title, items, preview, setItem }) => {
6 |
7 | const contentRow = useRef()
8 | const [delayHandler, setDelayHandler] = useState(null)
9 |
10 | const onWheel = (e) => {
11 | if (e.deltaY > 0) {
12 | contentRow.current.scrollLeft += 100
13 | } else {
14 | contentRow.current.scrollLeft -= 100
15 | }
16 | }
17 |
18 | const onMouseEnterPreview = (e, item) => {
19 |
20 | preview.current.removeAttribute('active')
21 | if(window.innerWidth > 786) {
22 | // Set width to preview element to width of target element + 100px to make it bigger
23 | preview.current.style.width = `${e.currentTarget.offsetWidth + 100}px`;
24 | }
25 | const previewHeight = (preview.current.offsetHeight - e.currentTarget.offsetHeight) / 2
26 | // Align preview element
27 | const offsetTop = e.currentTarget.offsetTop - (preview.current.offsetHeight - e.currentTarget.offsetHeight) / 2
28 | const offsetLeft = e.currentTarget.getBoundingClientRect().left - previewHeight
29 |
30 | setDelayHandler(setTimeout(() => {
31 | setItem(item)
32 | preview.current.style.top = `${offsetTop}px`
33 | window.innerWidth <= 786 ?
34 | preview.current.style.left = `${window.innerWidth - (window.innerWidth / 2 + preview.current.offsetWidth / 2)}px`
35 | :
36 | preview.current.style.left = `${offsetLeft}px`
37 | preview.current.setAttribute('active', '')
38 | }, window.innerWidth <= 786 ? 100 : 1000))
39 |
40 | }
41 |
42 | const onMouseLeavePreview = (e) => {
43 | clearTimeout(delayHandler)
44 | }
45 |
46 | return (
47 |
48 |
49 |
50 |
{title}
51 |
52 |
56 | {items && items.length !== 0 ?
57 | <>
58 | {items.map((item, index) => {
59 | return (
60 |
onMouseEnterPreview(e, item)}
62 | onMouseLeave={onMouseLeavePreview}
63 | key={`cards-${title}-${index}`}
64 | className="card"
65 | >
66 | {window.innerWidth <= 786 ?
67 |
68 |

69 |
70 | :
71 |
72 |

73 |
74 | }
75 |
76 | )
77 | })}
78 | >
79 | :
80 |
Loading. . .
81 | }
82 |
83 |
84 |
85 | )
86 | }
87 |
88 | export default ContentRow
--------------------------------------------------------------------------------
/src/components/content/Recomendation.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react'
2 | import { Link, useParams } from 'react-router-dom'
3 | import { getRecomendations } from '../../actions/movie'
4 | import './styles/recomendation.css'
5 |
6 | const ContentColumn = ({ preview, setItem, }) => {
7 |
8 | const [delayHandler, setDelayHandler] = useState(null)
9 | const [items, setItems] = useState(null)
10 | const params = useParams()
11 |
12 |
13 | useEffect(() => {
14 | if(!items) {
15 | getRecomendations(params.id, params.type).then((res) => setItems(res.results))
16 | }
17 | }, [])
18 |
19 |
20 | const onMouseEnter = (e, item) => {
21 |
22 | preview.current.removeAttribute('active')
23 | if(window.innerWidth > 786) {
24 | // Set width to preview element to width of target element + 100px to make it bigger
25 | preview.current.style.width = `${e.currentTarget.offsetWidth + 100}px`;
26 | }
27 | // Align preview element
28 | const offsetTop = e.currentTarget.offsetTop - (preview.current.offsetHeight - e.currentTarget.offsetHeight) / 2
29 | const offsetLeft = e.currentTarget.offsetLeft - (preview.current.offsetWidth - e.currentTarget.offsetWidth) / 2
30 |
31 | setDelayHandler(setTimeout(() => {
32 | setItem(item)
33 | preview.current.style.top = `${offsetTop}px`
34 | window.innerWidth <= 786 ?
35 | preview.current.style.left = `${window.innerWidth - (window.innerWidth / 2 + preview.current.offsetWidth / 2)}px`
36 | :
37 | preview.current.style.left = `${offsetLeft}px`
38 | preview.current.setAttribute('active', '')
39 | }, window.innerWidth <= 786 ? 100 : 1000))
40 |
41 | }
42 |
43 | const onMouseLeave = (e) => {
44 | clearTimeout(delayHandler)
45 | }
46 |
47 | return (
48 | <>
49 | {items && items.length > 0 && MORE LIKE IT
}
50 |
51 | {items ?
52 | <>
53 | {items.map((item, index) => {
54 | return (
55 | window.innerWidth <= 786 ?
56 | onMouseEnter(e, item)}
60 | onMouseLeave={onMouseLeave}
61 | >
62 |

63 |
64 |
{ item.original_title ? item.original_title : item.name}
65 |
66 |
⭐{item.vote_average}
67 | { item.release_date ? item.release_date : "Last Air Date: " + item.last_air_date }
68 |
69 |
70 |
71 | :
72 | onMouseEnter(e, item)}
77 | onMouseLeave={onMouseLeave}
78 | >
79 |
80 |
81 |
{ item.original_title ? item.original_title : item.name}
82 |
83 |
⭐{item.vote_average}
84 | { item.release_date ? item.release_date : "Last Air Date: " + item.last_air_date }
85 |
86 |
87 |
88 | )
89 | })}
90 | >
91 | :
92 | Loading ...
93 | }
94 |
95 | >
96 | )
97 | }
98 |
99 | export default ContentColumn
--------------------------------------------------------------------------------
/src/components/content/SearchResults.jsx:
--------------------------------------------------------------------------------
1 | import { useState } from 'react'
2 | import { Link } from 'react-router-dom'
3 | import './styles/recomendation.css'
4 |
5 | const SearchResults = ({ items, isLoading, preview, setItem, type }) => {
6 |
7 | const [delayHandler, setDelayHandler] = useState(null)
8 |
9 | const onMouseEnter = (e, item) => {
10 |
11 | preview.current.removeAttribute('active')
12 | if(window.innerWidth > 786) {
13 | // Set width to preview element to width of target element + 100px to make it bigger
14 | preview.current.style.width = `${e.currentTarget.offsetWidth + 100}px`;
15 | }
16 | // Align preview element
17 | const offsetTop = e.currentTarget.offsetTop - (preview.current.offsetHeight - e.currentTarget.offsetHeight) / 2
18 | const offsetLeft = e.currentTarget.offsetLeft - (preview.current.offsetWidth - e.currentTarget.offsetWidth) / 2
19 |
20 | setDelayHandler(setTimeout(() => {
21 | item['media_type'] = type
22 | setItem(item)
23 | preview.current.style.top = `${offsetTop}px`
24 | window.innerWidth <= 786 ?
25 | preview.current.style.left = `${window.innerWidth - (window.innerWidth / 2 + preview.current.offsetWidth / 2)}px`
26 | :
27 | preview.current.style.left = `${offsetLeft}px`
28 | preview.current.setAttribute('active', '')
29 | }, window.innerWidth <= 786 ? 100 : 1000))
30 |
31 | }
32 |
33 | const onMouseLeave = (e) => {
34 | clearTimeout(delayHandler)
35 | }
36 |
37 | return (
38 | <>
39 |
40 | {items ?
41 | <>
42 | {items
43 | .sort(
44 | (a,b) => ( b.release_date ? +b.release_date.slice(0,4) : b.first_air_date ? +b.first_air_date.slice(0,4) : 0) - ( a.release_date ? +a.release_date.slice(0,4) : a.first_air_date ? +a.first_air_date.slice(0,4) : 0)
45 | )
46 | .map((item, index) => {
47 | return (
48 | window.innerWidth <= 786 && item.poster_path ?
49 | onMouseEnter(e, item)}
53 | onMouseLeave={onMouseLeave}
54 | >
55 |

56 |
57 |
{ item.original_title ? item.original_title : item.name}
58 |
59 |
⭐{item.vote_average}
60 | { item.release_date ? item.release_date : item.first_air_date ? "First Air Date: " + item.first_air_date : '' }
61 |
62 |
63 |
64 | : item.poster_path &&
65 | onMouseEnter(e, item)}
70 | onMouseLeave={onMouseLeave}
71 | >
72 |
73 |
74 |
{ item.original_title ? item.original_title : item.name}
75 |
76 | {item.vote_average != 0 &&
⭐{item.vote_average}
}
77 | { item.release_date ? item.release_date : item.first_air_date ? "First Air Date: " + item.first_air_date : '' }
78 |
79 |
80 |
81 | )
82 | })}
83 | >
84 | :
85 | isLoading ?
86 | Loading ...
87 | :
88 |
89 | }
90 |
91 | >
92 | )
93 | }
94 |
95 | export default SearchResults
--------------------------------------------------------------------------------