Last active
August 17, 2018 14:25
-
-
Save luandevpro/3d4b67224c5c1ea5192426ed7f4de9e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import styled from "styled-components" | |
import Overdrive from 'react-overdrive' | |
import Link from 'next/link' | |
import { POSTER_PATH } from '../constants/ActionTypes' | |
import { MovieInfo } from "../layouts/Layout" | |
class Movies extends Component { | |
render() { | |
var { movie } = this.props | |
var { poster_path , title ,id } = movie | |
return ( | |
<MovieInfo> | |
<Link href={`/post?id=${id}`}> | |
<a> | |
<Overdrive id={poster_path}> | |
<Poster src={`${POSTER_PATH}/${poster_path}`} alt={title} /> | |
</Overdrive> | |
</a> | |
</Link> | |
</MovieInfo> | |
); | |
} | |
} | |
export default Movies; | |
export const Poster = styled.img` | |
width: 100%; | |
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React , { Component } from 'react' | |
import styled from 'styled-components' | |
import Overdrive from 'react-overdrive' | |
import { BACKDROP_PATH , POSTER_PATH } from '../constants/ActionTypes' | |
import { Layout } from '../layouts/Layout' | |
import { CallAPIInfo } from '../utils/api' | |
import { Poster } from '../components/Movies' | |
class Post extends Component{ | |
static async getInitialProps({query}){ | |
const { id } = query | |
const res = await CallAPIInfo(id ,'get',null) | |
return { movie: res.data } | |
} | |
render(){ | |
var { movie } = this.props | |
var { tagline , id , backdrop_path , original_title , poster_path , overview , vote_average , vote_count} = movie | |
return ( | |
<Layout> | |
<MovieBackground backdrop_path={`${BACKDROP_PATH}${backdrop_path}`} alt={original_title}> | |
<MovieInfo> | |
<Overdrive id={poster_path} > | |
<Poster src={`${POSTER_PATH}${poster_path}`} alt={original_title}/> | |
</Overdrive> | |
<div> | |
<h1>{original_title}</h1> | |
<p>{overview}</p> | |
<h5>{vote_average} - {vote_count} - {tagline}</h5> | |
</div> | |
</MovieInfo> | |
</MovieBackground> | |
</Layout> | |
) | |
} | |
} | |
export default Post | |
const MovieBackground = styled.div` | |
background: url(${props => props.backdrop_path}) no-repeat; | |
position: relative; | |
padding-top: 50vh; | |
background-size: cover; | |
` | |
const MovieInfo = styled.div` | |
background: white; | |
padding: 2rem 10%; | |
text-align: left; | |
display: flex; | |
> div { | |
margin-left: 20px; | |
> p { | |
text-align: justify; | |
} | |
} | |
img { | |
position: relative; | |
top: -5rem; | |
width: 180px; | |
height: 250px; | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment