Skip to content

Commit

Permalink
Merge pull request #602 from City-of-Helsinki/hotfix/fullwidthhearing…
Browse files Browse the repository at this point in the history
…-image

Add default image on imageless fullwidth hearing.
  • Loading branch information
Rikuoja authored Feb 23, 2018
2 parents d2ed3a5 + 22f81cb commit 03adba3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`HearingCard component should render as expected 1`] = `
className="hearing-card-image"
style={
Object {
"backgroundImage": "url(\\"https://api.hel.fi/kerrokantasi-test/media/images/2017/10/LzqVMrMI.jpeg\\")",
"backgroundImage": "url(https://api.hel.fi/kerrokantasi-test/media/images/2017/10/LzqVMrMI.jpeg)",
}
}
to={
Expand Down
2 changes: 1 addition & 1 deletion src/components/FullWidthHearing.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import getAttr from '../utils/getAttr';
const FullWidthHearing = ({hearing, className = '', ...rest}, {language}) => {
const backgroundImage = getHearingMainImageURL(hearing);
const styles = {
backgroundImage: backgroundImage ? `url(${backgroundImage})` : '',
backgroundImage: backgroundImage ? `url(${backgroundImage})` : 'url(/assets/images/default-image.svg)',
};
return (
<div className={`fullwidth-hearing ${className}`} {...rest}>
Expand Down
10 changes: 3 additions & 7 deletions src/components/HearingCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ import config from '../config';

const HearingCard = ({hearing, language, className = ''}) => {
const backgroundImage = getHearingMainImageURL(hearing);
let cardImageStyle = {
backgroundImage: 'url(/assets/images/default-image.svg)',
const cardImageStyle = {
backgroundImage: backgroundImage ? `url(${backgroundImage})` : 'url(/assets/images/default-image.svg)',
};
if (backgroundImage) {
cardImageStyle = {
backgroundImage: 'url("' + backgroundImage + '")',
};
}

// FIXME: Should there be direct linking to hearing using certain language?
const translationAvailable = !!getAttr(hearing.title, language, {exact: true});
const expiresSoon = moment(hearing.close_at).diff(moment(), 'weeks') < 1;
Expand Down

0 comments on commit 03adba3

Please sign in to comment.