Skip to content
Open
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
Binary file removed .DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions week10/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.env
54 changes: 54 additions & 0 deletions week10/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default tseslint.config({
extends: [
// Remove ...tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default tseslint.config({
plugins: {
// Add the react-x and react-dom plugins
'react-x': reactX,
'react-dom': reactDom,
},
rules: {
// other rules...
// Enable its recommended typescript rules
...reactX.configs['recommended-typescript'].rules,
...reactDom.configs.recommended.rules,
},
})
```
28 changes: 28 additions & 0 deletions week10/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
13 changes: 13 additions & 0 deletions week10/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions week10/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "week10",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@tailwindcss/vite": "^4.1.10",
"axios": "^1.10.0",
"i": "^0.3.7",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"tailwindcss": "^4.1.10"
},
"devDependencies": {
"@eslint/js": "^9.25.0",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react-swc": "^3.9.0",
"eslint": "^9.25.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"typescript": "~5.8.3",
"typescript-eslint": "^8.30.1",
"vite": "^6.3.5"
}
}
1 change: 1 addition & 0 deletions week10/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added week10/src/App.css
Empty file.
11 changes: 11 additions & 0 deletions week10/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import './App.css'
import HomePage from './pages/HomePage'

function App() {
return<HomePage />


}

export default App
8 changes: 8 additions & 0 deletions week10/src/apis/axiosClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import axios from 'axios'

export const axiosClient = axios.create({
baseURL: 'https://api.themoviedb.org/3',
headers: {
Authorization: 'Brearer ${import.meta.env.VITE_TMDB_TOKEN}',
},
})
1 change: 1 addition & 0 deletions week10/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions week10/src/components/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
interface InputProps {
value: string
onChange: (value: string) => void
placeholder?: string
className?: string
}

export const Input = ({ value, onChange, placeholder = '검색어를 입력하세요', className, }: InputProps) => {
return (
<input className={`w-full rounded-md border-gray-300 shadow-sm border p-2 focus:border-blue-500 focus:ring-blue-500 ${className}`}
placeholder={placeholder}
value={value}
onChange={(e) => onChange(e.target.value)}
/>
)
}

export default Input
31 changes: 31 additions & 0 deletions week10/src/components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
interface LanguageOptions {
value: string;
label: string;
}

interface LanguageSelectorProps {
value: string;
onChange: (value: string) => void;
options: LanguageOptions[];
className?: string;
}

export const LanguageSelector = ({
value,
onChange,
options,
className = '',
}: LanguageSelectorProps ) => {
return (
<select className='w-full rounded-lg border-gray-300 px-4 py-2 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500'>
{options.map((option) => (
<option
key={option.value}
value={option.value}
>
{option.label}
</option>
))}
</select>
)
}
36 changes: 36 additions & 0 deletions week10/src/components/MovieCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Movie } from '../types/movie'

interface MovieCardProps {
movie: Movie
}

const MovieCard = ({movie}:MovieCardProps) => {
const imageBaseUrl = 'https://image.tmdb.org/t/p/w500'
const fallbackImage = 'https://via.placeholder.com/640x480'
return (
<div className='cursor-pointer overflow-hidden rounded-lg bg-white shadow-md transition-all hover:shadow-lg'>
<div className='relative h-80 overflow-hidden'>
<img src={movie.poster_path
? `${imageBaseUrl}${movie.poster_path}`
: fallbackImage}
alt={`${movie.title} 포스터`}
className='h-full w-full object-cover transition-transform duration-300 ease-in-out hover:scale-105'
/>
<div className='absolute right-2 top-2 rounded-md bg-black-500 px-2 py-1 text-sm font-bold text-white'>
{movie.vote_average.toFixed(1)}
</div>
</div>
<div className='p-4'>
<h3 className='mb-2 text-lg font-semibold text-gray-800 line-clamp-2'>{movie.title}</h3>
<p className='text-sm text-gray-600 line-clamp-3'>{movie.overview}</p>
<p className='mt-2 text-xs text-gray-500'>개봉일: {new Date(movie.release_date).toLocaleDateString()}</p>
</div>
<div className='flex items-center justify-between border-t p-4'>
<span className='text-sm text-gray-500'>평점: {movie.vote_average.toFixed(1)}</span>
<span className='text-sm text-gray-500'>조회수: {movie.vote_count}</span>
</div>
</div>
)
}

export default MovieCard
66 changes: 66 additions & 0 deletions week10/src/components/MovieFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { useState } from 'react'
import type { Movie, MovieFilters, MovieLanguage } from '../types/movie'
import Input from './Input'
import { SelectBox } from './SelectBox'
import { LANGUAGE_OPTIONS } from '../constants/movie'
import { LanguageSelector } from './LanguageSelector'

interface MovieFilterProps {
onChange : (filter: MovieFilters) => void
}
export const MovieFilter = ({onChange}: MovieFilterProps) => {
const[query, setQuery] = useState<string>('')
const[includeAdult, setIncludeAdult] = useState<boolean>(false)
const[language, setLanguage] = useState<MovieLanguage>('ko-KR')

const handleSubmit = () => {
const filters: MovieFilters = {
query,
include_adult: includeAdult,
language,
}
onChange(filters)
}

return (
<div className='transform space-y-6 rounded-2xl bg-white p-6 shadow-xl transition-all duration-300 hover:shadow-2xl'>
<div className='flex flex-wrap gap-6'>
<div className='mix-w-[450px] flex-1'>
<label className="mb-2 block text-sm font-medium text-gray-700">영화 제목</label>
<Input value={query} onChange={setQuery}/>
</div>

<div className='min-w-[250px] flex-1'>
<label className="mb-2 block text-sm font-medium text-gray-700">
옵션
</label>
<SelectBox
checked={includeAdult}
onChange={setIncludeAdult}
label='성인 콘텐츠 포함'
id='include_adult'
className='w-full rounded-lg border-gray-300 px-4 py-2 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500'
/>
</div>


<div className='min-w-[250px] flex-1'>
<label className="mb-2 block text-sm font-medium text-gray-700">
언어
</label>
<LanguageSelector
value={language}
onChange={setLanguage}
options={LANGUAGE_OPTIONS}
className='w-full rounded-lg border-gray-300 px-4 py-2 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500'
/>
</div>


<div className='pt-4'>
<button onClick={handleSubmit}>영화 검색</button>
</div>
</div>
</div>
)
}
23 changes: 23 additions & 0 deletions week10/src/components/MovieList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Movie } from '../types/movie'
import MovieCard from './MovieCard'

interface MovieListProps {
movies: Movie[]
}

export const MovieList = ({movies}:MovieListProps) => {
if (movies.length === 0) {
return(
<div className='flex h-60 items-center justify-center'>
<p className='font-bold text-gray-500'>검색 결과가 없습니다.</p>
</div>
)
}
return (
<div className='grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5'>
{movies.map((movie) => (
<MovieCard key={movie.id} movie={movie}/>
))}
</div>
)
}
22 changes: 22 additions & 0 deletions week10/src/components/SelectBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
interface SelectBoxProps {
checked?: boolean
onChange?: (checked: boolean) => void
label: string
id?: string
className?: string
}

export const SelectBox = ({ checked = false, onChange, label, id = 'checkbox', className }: SelectBoxProps) => {
return (
<div className= {`flex items-center ${className}`}>
<input
type="checkbox"
id={id}
checked={checked}
onChange={(e) => onChange?.(e.target.checked)}
className="size-4 rounded border-gray-300 text-blue-600 bg-gray-200 focus:ring-blue-500"
/>
<label htmlFor={id} className="ml-2 text-sm text-gray-700"> {label} </label>
</div>
)
}
5 changes: 5 additions & 0 deletions week10/src/constants/movie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const LANGUAGE_OPTIONS = [
{ label: '한국어', value: 'ko' },
{ label: '영어', value: 'en' },
{ label: '일본어', value: 'ja' },
]
Loading