Skip to content

Commit

Permalink
mission : submit week3 mission(완성본)HomePage
Browse files Browse the repository at this point in the history
  • Loading branch information
KOOMINSEOK committed Oct 12, 2024
1 parent 36305f4 commit f17e164
Show file tree
Hide file tree
Showing 20 changed files with 206 additions and 65 deletions.
1 change: 1 addition & 0 deletions mission/chapter03/mission01/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.env
8 changes: 7 additions & 1 deletion mission/chapter03/mission01/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import CategoryPage from "./pages/categoryPage";
import SearchPage from "./pages/searchPage";
import LoginPage from "./pages/loginPage";
import SignupPage from "./pages/signupPage";
import HomePage from "./pages/homePage";

const router = createBrowserRouter([
{
path: '/',
element: <RootLayout/>,
children: [
{ index:true,
element : <MoviesPage/>
element : <HomePage/>
},
{
path: 'search',
Expand All @@ -30,6 +31,11 @@ const router = createBrowserRouter([
path: 'signup',
element: <SignupPage/>
}
,
{
path: 'movies/:category',
element: <MoviesPage/>
}
]
}
])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import styled from "styled-components";


const CategoryCard = ({title})=>{
return(
<CardDiv>
<CardSpan>{title}</CardSpan>
</CardDiv>
)

}

export default CategoryCard;

const CardDiv = styled.div`
width : 200px;
height : 100px;
background-color : white;
border-radius: 10px;
display : flex;
align-items : flex-end;
&:hover{
transform: scale(1.05);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}
`
const CardSpan = styled.span`
background-color: grey;
color: white;
opacity: 0.5;
border-radius: 5px;
margin :10px 10px 10px 10px;
padding : 0px 3px 3px 3px;
vertical-align : bottom;
`
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
.movie_item{
display: flex;
height: 240px;
flex-direction: column;
height: 300px;
width: 160px;
position: relative;
overflow: hidden;
}
.movie_item span{
font-size: 15px;
}
.movie_item p{
font-size: 10px;
margin-top: 2px;
}
.poster_img{
width: 100%;
height: 100%;
height: 80%;
object-fit: cover;
border-radius: 10px;

}
.poster_hover{
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import "./moviePoster.css"

const MoviePoster = (props)=>{
const {poster_path} = props
const {poster_path, title, release_date} = props
return (
<div className='movie_item'>
<img className='poster_img' src={`https://image.tmdb.org/t/p/w500${poster_path}`}/>
<span>{title}</span>
<p>{release_date}</p>
<div className='poster_hover'/>
</div>
)
Expand Down
23 changes: 0 additions & 23 deletions mission/chapter03/mission01/src/components/navbar.jsx

This file was deleted.

41 changes: 41 additions & 0 deletions mission/chapter03/mission01/src/components/navbar/navbar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {Link} from "react-router-dom";
import styled from "styled-components";

const Navbar = () => {
return (
<NavContainer>
<Link to={'/'}><Logo>YONGCHA</Logo></Link>
<div>
<Link to={'/login'}><StyledButton color={'#111'}>로그인</StyledButton></Link>
<Link to={'/signup'}><StyledButton color={'#111'}>회원가입</StyledButton></Link>
</div>
</NavContainer>
);
};

export default Navbar;

const NavContainer = styled.div`
display: flex;
justify-content: space-between;
width: 100%;
background-color: #1b1b1b;
align-items: center;
`
const StyledButton = styled.button`
background-color: ${props => props.color};
border: none;
color: white;
padding: 10px 20px;
border-radius: 5px;
margin-left: 10px;
cursor: pointer;
font-size: 16px;
&:hover {
background-color: #ff007c;
}
`
const Logo = styled.h2`
color: #ff007c;
padding-left : 20px;
`
20 changes: 0 additions & 20 deletions mission/chapter03/mission01/src/components/sidebar.jsx

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions mission/chapter03/mission01/src/components/sidebar/sidebar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ul li {
color: white;
text-decoration: none;
font-size: 18px;
display: block;
padding-top: 10px;
padding-bottom: 10px;
transition: background-color 0.3s;
}
ul{
padding-left: 20px;
padding-right: 0px;
}
ul li:hover{
background-color: #333;
border-radius: 5px;
}
25 changes: 25 additions & 0 deletions mission/chapter03/mission01/src/components/sidebar/sidebar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import styled from "styled-components";
import { Link } from "react-router-dom";
import searchIcon from "./icon/search.png"
import movieIcon from "./icon/movie.png"
import "./sidebar.css"
const SideBar = () => {
return (
<SideBarContainer>
<ul className = "sidebar" >
<Link to={'/search'}><li><img src={searchIcon} width={20} height={20}/>찾기</li></Link>
<Link to={'/movies'}><li><img src={movieIcon} width={20} height={20}/>영화</li></Link>
</ul>
</SideBarContainer>
);
};

export default SideBar;

const SideBarContainer = styled.div`
dispaly: flex;
height: 100vh;
background-color: #1b1b1b;
width: 15%;
`
6 changes: 4 additions & 2 deletions mission/chapter03/mission01/src/layout/root-layout.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Outlet} from "react-router-dom";
import Navbar from "../components/navbar";
import SideBar from "../components/sidebar";
import Navbar from "../components/navbar/navbar";
import SideBar from "../components/sidebar/sidebar";
import styled from "styled-components";

const RootLayout = () => {
Expand All @@ -22,4 +22,6 @@ const BoxLayout = styled.div`
display: flex;
flex-direction: row;
width: 100vw;
background-color: #111;
color: white;
`
34 changes: 32 additions & 2 deletions mission/chapter03/mission01/src/pages/categoryPage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
import { Link } from "react-router-dom";
import CategoryCard from "../components/categoryCard/categoryCard";
import styled from "styled-components";

const categoryList = [
{ title : "현재 상영 중인", value : "now-playing"},
{ title : "인기 있는", value : "popular"},
{ title : "높은 평가를 받은", value : "top-rated"},
{ title : "개봉 예정중인", value : "up-coming"}

]

const CategoryPage = ()=>{
return(
<h3>카테고리</h3>
<CategoryContainer>
<h2>카테고리</h2>
<CateListBox>
{categoryList.map((category)=>(
<Link to={`/movies/${category.value}`} key={category.value}><CategoryCard title = {category.title}/></Link>
))}
</CateListBox>
</CategoryContainer>
)
}

export default CategoryPage;
export default CategoryPage;

const CategoryContainer = styled.div`
display: flex;
flex-direction: column;
padding-left: 15px;
`
const CateListBox = styled.div`
display: flex;
flex-direction: row;
gap: 10px;
`
7 changes: 7 additions & 0 deletions mission/chapter03/mission01/src/pages/homePage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const HomePage = ()=>{
return(
<h2>홈 페이지</h2>
)
}

export default HomePage;
2 changes: 1 addition & 1 deletion mission/chapter03/mission01/src/pages/loginPage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const LoginPage = ()=>{
return(
<h3>로그인 페이지</h3>
<h2>로그인 페이지</h2>
)
}

Expand Down
23 changes: 16 additions & 7 deletions mission/chapter03/mission01/src/pages/moviesPage.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
import { useState, useEffect } from 'react'
import MoviePoster from '../components/moviePoster.jsx';
import MoviePoster from '../components/moviePoster/moviePoster.jsx';
import './moviesPages.css'
import axios from "axios";
import { useParams } from 'react-router-dom';

const APIurl={
"now-playing" : 'https://api.themoviedb.org/3/movie/now_playing?language=kr-KR&page=1',
"popular" : 'https://api.themoviedb.org/3/movie/popular?language=kr-KR&page=1',
"top-rated" : 'https://api.themoviedb.org/3/movie/top_rated?language=kr-KR&page=1',
"up-coming" :'https://api.themoviedb.org/3/movie/upcoming?language=kr-KR&page=1'
}

const MoviesPage = () => {
const [movies, setMovies] = useState([]);

const {category} = useParams();
useEffect(() => {
const getMovies = async () => {
const movies = await axios.get(`https://api.themoviedb.org/3/movie/popular?language=en-US&page=1`, {
const movies = await axios.get(APIurl[category], {
headers: {
Authorization: `Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI3Yzk1MjQ3ZGU3NDUxMzY0MjM0MmE2MTc4ODQzOWYzNiIsIm5iZiI6MTcyODQ3OTkwOS44MDczNjEsInN1YiI6IjY3MDY3YmFkNTk3YzEyNmYwN2RkYzRhYSIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.56L6fv17OgkRqftv2BLlKCJiw3-4w9Ym_g_sFhPyP-E`
Authorization: `Bearer ${import.meta.env.VITE_TMDB_ACCESS_TOKEN}`
}
})
setMovies(movies);
}
getMovies()
}, []);
}, [category]);


return (
<>
<div className="movie_poster_list">
{movies.data?.results.map((movie) => (
<MoviePoster poster_path={movie.poster_path}/>
<MoviePoster poster_path={movie.poster_path}
title = {movie.title}
release_date = {movie.release_date}/>
))}
{console.log(movies)}
</div>
</>
)
Expand Down
7 changes: 4 additions & 3 deletions mission/chapter03/mission01/src/pages/moviesPages.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
display: flex;
flex-wrap: wrap;
width: 100%;
gap: 10px;
margin-left: 10px;
justify-content: center;
gap: 15px;
margin-left: 15px;
margin-top: 15px;

}
2 changes: 1 addition & 1 deletion mission/chapter03/mission01/src/pages/searchPage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const SearchPage = ()=>{
return(
<h3>검색 페이지 야호~!</h3>
<h2>검색 페이지 야호~!</h2>
)
}

Expand Down
2 changes: 1 addition & 1 deletion mission/chapter03/mission01/src/pages/signupPage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const SignupPage = ()=>{
return(
<h3>회원가입 페이지</h3>
<h2>회원가입 페이지</h2>
)
}

Expand Down

0 comments on commit f17e164

Please sign in to comment.