Created
November 14, 2017 10:28
-
-
Save mauricedb/f942fdd94526caa7340b9054c48cf4af to your computer and use it in GitHub Desktop.
Create a movie card component
This file contains hidden or 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 { h, Component } from "preact"; | |
import style from "./style"; | |
export default ({ movie }) => { | |
return ( | |
<div class={["card", style.movieCard].join(" ")}> | |
<img | |
class="card-img-top" | |
src={movie.image} | |
alt="Card image cap" | |
/> | |
<div class="card-body"> | |
<h4 class="card-title">{movie.title}</h4> | |
<p class="card-text">{movie.overview}</p> | |
</div> | |
<div class="card-footer text-cente"> | |
{movie.genres.map(genre => ( | |
<span | |
class={["badge", "badge-pill", "badge-info", style.genreBadge].join( | |
" " | |
)} | |
> | |
{genre} | |
</span> | |
))} | |
</div> | |
</div> | |
); | |
}; |
This file contains hidden or 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
.movieCard { | |
min-width: 250px; | |
max-width: 250px; | |
margin-top: 15px; | |
margin-bottom: 15px; | |
} | |
.genreBadge { | |
margin-right: 3px; | |
} |
This file contains hidden or 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 { h, Component } from "preact"; | |
import style from "./style"; | |
import Movie from "../../components/movie"; | |
export default ({ movies }) => ( | |
<div class={style.movies}> | |
<h2>Movies</h2> | |
<div class="card-deck"> | |
{movies.map(movie => <Movie movie={movie} />)} | |
</div> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment