Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Fronted Projects/Movie-DB/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
36 changes: 36 additions & 0 deletions Fronted Projects/Movie-DB/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Movie DB

**To View the Original Github:** https://github.com/chanakyha/movie-detail-search-bar
**To View the Website:** https://discover-movies-kappa.vercel.app/

## Technologies

The Website is Build with [`React.Js`](https://reactjs.org/) [`Tailwind CSS`](https://tailwindcss.com/) [`TMDB`](https://www.themoviedb.org/)

Deployed using [`Vercel`](https://www.vercel.com/)

> Used TMBD Api to get the Latest Movie Details

## Development

```
yarn install
yarn start
```

## Contributors

[![All Contributors](https://img.shields.io/badge/All_Contributors-1-green.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

<table>
<tbody>
<tr>
<td align="center"><a href="https://chanakyha-coder.xyz"><img src="https://avatars.githubusercontent.com/u/66877639?v=4" width="100px;" alt="Chanakyha"/><br /><sub><b>Chanakyha.V</b></sub></a><br /></td>
</tbody>
</table>

## License

This project uses [Standard]() license.
44 changes: 44 additions & 0 deletions Fronted Projects/Movie-DB/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "movie-search",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"autoprefixer": "^10.4.8",
"postcss": "^8.4.16",
"tailwindcss": "^3.1.8"
}
}
6 changes: 6 additions & 0 deletions Fronted Projects/Movie-DB/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file added Fronted Projects/Movie-DB/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions Fronted Projects/Movie-DB/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added Fronted Projects/Movie-DB/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Fronted Projects/Movie-DB/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Fronted Projects/Movie-DB/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions Fronted Projects/Movie-DB/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
123 changes: 123 additions & 0 deletions Fronted Projects/Movie-DB/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React, { useState, useEffect } from "react";
import axios, { request } from "./axios";
import Footer from "./components/Footer";
import MovieDetails from "./components/MovieDetails";

import MovieList from "./components/MovieList";

const App = () => {
const [input, setInput] = useState("");
const [movies, setMovies] = useState([]);
const [suggestion, setSuggestion] = useState([]);

const [searchMovieDetail, setSearchMovieDetail] = useState(false);

useEffect(() => {
(async () => {
const response1 = await axios.get(request + "&page=1");
setMovies(response1.data.results);
})();
}, []);

useEffect(() => {
if (!movies) return;
if (!input) return;

let currentSuggestion = [];

for (let i = 0; i < movies.length; i++) {
if (movies[i].title.toUpperCase().indexOf(input.toUpperCase()) > -1) {
currentSuggestion.push(movies[i].title);
}

if (currentSuggestion.includes(input)) {
currentSuggestion = [];
break;
}
}

setSuggestion(currentSuggestion);
}, [input]);

return (
<div>
<div className="flex justify-center md:justify-between items-center p-7 bg-slate-800">
<img
src="https://bit.ly/3wXPyzv"
alt="logo"
className="w-10 h-10 hidden md:inline-block"
/>
<div className="bg-white rounded-md px-3 space-x-3 py-2 flex ietms-center justify-evenly">
<svg
fill="#000000"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24px"
height="24px"
>
<path d="M 9 2 C 5.1458514 2 2 5.1458514 2 9 C 2 12.854149 5.1458514 16 9 16 C 10.747998 16 12.345009 15.348024 13.574219 14.28125 L 14 14.707031 L 14 16 L 20 22 L 22 20 L 16 14 L 14.707031 14 L 14.28125 13.574219 C 15.348024 12.345009 16 10.747998 16 9 C 16 5.1458514 12.854149 2 9 2 z M 9 4 C 11.773268 4 14 6.2267316 14 9 C 14 11.773268 11.773268 14 9 14 C 6.2267316 14 4 11.773268 4 9 C 4 6.2267316 6.2267316 4 9 4 z" />
</svg>
<div>
<input
className="flex-grow font-bold bg-transparent outline-none md:w-64 border-r-2"
type="text"
placeholder={
searchMovieDetail ? "Input Disabled" : "Enter Movie Name"
}
value={input}
disabled={searchMovieDetail}
onChange={(e) => setInput(e.target.value)}
/>
{suggestion.length > 0 && input.length > 0 ? (
<div
className={`absolute bg-white rounded-md text-gray-500 p-4 shadow-lg w-64 space-y-1`}
>
{suggestion?.map((sug, ind) => (
<p
key={ind}
onClick={() => {
setInput(sug);
}}
className="search-item"
>
👉 {sug}
</p>
))}
</div>
) : null}
</div>
{searchMovieDetail ? (
<button
onClick={() => {
setSearchMovieDetail(!searchMovieDetail);
}}
className="text-red-500 font-semibold"
>
Go Back
</button>
) : (
<button
onClick={() => {
setSearchMovieDetail(!searchMovieDetail);
}}
className="text-blue-500 font-semibold"
>
Search
</button>
)}
</div>
<h1 className="hidden md:inline-block font-bold text-xl text-white">
Search and Discover Movies
</h1>
</div>
{searchMovieDetail ? (
<MovieDetails movies={movies} searchInput={input} />
) : (
<MovieList setInput={setInput} movies={movies} />
)}
<Footer />
</div>
);
};

export default App;
8 changes: 8 additions & 0 deletions Fronted Projects/Movie-DB/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
11 changes: 11 additions & 0 deletions Fronted Projects/Movie-DB/src/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import axios from "axios";

const API_KEY = process.env.REACT_APP_TMDB_API;
export const request = `/discover/movie?api_key=${API_KEY}`;
export const imageBaseUrl = "https://image.tmdb.org/t/p/original/";

const instance = axios.create({
baseURL: "https://api.themoviedb.org/3",
});

export default instance;
11 changes: 11 additions & 0 deletions Fronted Projects/Movie-DB/src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

const Footer = () => {
return (
<div className="relative bottom-0 p-5 bg-slate-800 text-white text-center font-bold">
Made with 🤍 by Chanakyha
</div>
);
};

export default Footer;
27 changes: 27 additions & 0 deletions Fronted Projects/Movie-DB/src/components/MovieCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { useState } from "react";
import { imageBaseUrl } from "../axios";

const MovieCard = ({ movie, setInput }) => {
const [detailsVisible, setDetailsVisible] = useState(false);
return (
<div>
<div>
<div className={`${detailsVisible ? "absolute" : "hidden"} w-64 p-2`}>
<h1 className="text-lg z-10 font-bold">{movie?.title}</h1>
<p>{movie?.overview}</p>
</div>
<img
src={imageBaseUrl + movie?.poster_path}
alt="poster"
loading="lazy"
onClick={() => setInput(movie?.title)}
onMouseEnter={() => setDetailsVisible(true)}
onMouseLeave={() => setDetailsVisible(false)}
className="hover:opacity-30 w-64 rounded-lg shadow-md hover:shadow-lg cursor-pointer hover:scale-105 duration-150 ease-out"
/>
</div>
</div>
);
};

export default MovieCard;
Loading