Skip to content

Commit

Permalink
Add fallback when no image movie is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Macxim committed Aug 11, 2017
1 parent 3da29a3 commit 578e5e2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/components/List/index.css
Expand Up @@ -19,6 +19,37 @@
box-shadow: 0px 1px 8px 1px rgba(0, 0, 0, 0.4);
}


.list__movie-no_image_holder{
display: inline-block;
background-color: #dbdbdb;
height: 100%;
width: 100%;
position: relative;
}

.list__movie-no_image_holder span{
color: #000;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.list__movie-no_image_holder:before{
content: "No image available";
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
line-height: 24px;
border: 1px dotted #b5b5b5;
padding: 10px;
color: #b5b5b5;
text-align: center;
}

.list__movie-title{
display: block;
font-size: 16px;
Expand Down
6 changes: 5 additions & 1 deletion src/components/List/index.js
Expand Up @@ -10,7 +10,11 @@ const List = ({ list }) => {
<div key={item.id} className="list-container__item">
<div className="list__movie-image">
<span className="list__movie-vote-average">{item.vote_average}</span>
<img src={`https://image.tmdb.org/t/p/w185_and_h278_bestv2${item.poster_path}`} alt={item.title}/>
{item.poster_path ? (
<img src={`https://image.tmdb.org/t/p/w185_and_h278_bestv2${item.poster_path}`} alt={item.title}/>
)
: (<div className="list__movie-no_image_holder"></div>)
}
</div>
<div className="list__movie-title">
{item.title}
Expand Down

0 comments on commit 578e5e2

Please sign in to comment.