Skip to content

Commit

Permalink
react practice
Browse files Browse the repository at this point in the history
  • Loading branch information
JunHyeong Kim committed Sep 21, 2024
1 parent 85fac06 commit 20de8e2
Show file tree
Hide file tree
Showing 16 changed files with 18,931 additions and 12,442 deletions.
30,943 changes: 18,639 additions & 12,304 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"gh-pages": "^6.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"react-router-dom": "^6.26.2",
"react-scripts": "^3.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand All @@ -34,5 +36,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"homepage": "https://junbro1908.github.io/react-practice"
}
24 changes: 0 additions & 24 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,10 @@
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>
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

28 changes: 10 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import logo from './logo.svg';
import './App.css';
import Home from "./router/Home";
import Detail from "./router/Detail";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import React from "react";

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<Router>
<Routes>
<Route path="/detail/:id" element={<Detail />} />
<Route path="/" element={<Home />} />
</Routes>
</Router>
);
}

Expand Down
8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

35 changes: 35 additions & 0 deletions src/components/Movie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import PropTypes from "prop-types";
import { Link } from "react-router-dom";
import React from "react";
import styles from "../css/Home.module.css";

function Movie({ id, img, genres = [], title, score, content }) {
console.log("movie rendered");
return (
<div className={styles.item} key={id}>
<img className={styles.image} src={img} alt={title} />
<div className={styles.info}>
<Link to={`/detail/${id}`} className={styles.title}>
{title}
</Link>
<p className={styles.genres}>{genres.join(", ")}</p>
<p className={styles.rating}>Rating: {score}</p>
<p className={styles.content}>
content:{" "}
{content.length > 200 ? `${content.slice(0, 200)}...` : content}
</p>
</div>
</div>
);
}

Movie.propTypes = {
genres: PropTypes.array,
img: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
score: PropTypes.number.isRequired,
content: PropTypes.string.isRequired,
id: PropTypes.number.isRequired,
};

export default Movie;
40 changes: 40 additions & 0 deletions src/css/Detail.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.movie_detail {
max-width: 800px;
margin: auto;
padding: 20px;
color: white;
}

.movie_background {
height: 300px;
background-size: cover;
background-position: center;
border-radius: 10px;
margin-bottom: 20px;
}

.movie_info {
background-color: rgba(0, 0, 0, 0.7);
padding: 20px;
border-radius: 10px;
}

.movie_cover {
width: 100%;
max-width: 300px;
border-radius: 10px;
}

.more_info {
display: inline-block;
margin-top: 10px;
padding: 10px 15px;
background-color: #e50914;
color: white;
border-radius: 5px;
text-decoration: none;
}

.more-info:hover {
background-color: #f62134;
}
63 changes: 63 additions & 0 deletions src/css/Home.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.list {
max-width: 1200px;
margin: auto;
padding: 20px;
display: flex;
flex-wrap: wrap;
gap: 20px;
}

.item {
background-color: rgba(0, 0, 0, 0.7);
border-radius: 10px;
overflow: hidden;
width: calc(33.333% - 20px);
transition: transform 0.2s;
}

.item:hover {
transform: scale(1.05);
}

.image {
width: 100%;
height: auto;
}

.info {
padding: 15px;
color: white;
}

.title {
font-size: 1.5em;
margin: 0;
}

.genres {
font-size: 0.9em;
color: #ccc;
}

.rating {
font-weight: bold;
}

.loader {
border: 8px solid rgba(243, 243, 243, 0.7);
border-top: 8px solid #3498db;
border-radius: 50%;
width: 60px;
height: 60px;
animation: spin 1s linear infinite;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
13 changes: 0 additions & 13 deletions src/index.css

This file was deleted.

21 changes: 5 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

13 changes: 0 additions & 13 deletions src/reportWebVitals.js

This file was deleted.

Loading

0 comments on commit 20de8e2

Please sign in to comment.