Skip to content

Instantly share code, notes, and snippets.

@mauricedb
Created November 14, 2017 10:28
Show Gist options
  • Save mauricedb/f942fdd94526caa7340b9054c48cf4af to your computer and use it in GitHub Desktop.
Save mauricedb/f942fdd94526caa7340b9054c48cf4af to your computer and use it in GitHub Desktop.
Create a movie card component
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>
);
};
.movieCard {
min-width: 250px;
max-width: 250px;
margin-top: 15px;
margin-bottom: 15px;
}
.genreBadge {
margin-right: 3px;
}
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