Allow GridBlock images to be clickable links

This commit is contained in:
Frank Li 2017-07-21 13:57:37 -07:00
parent b359a2500d
commit f72144e988
2 changed files with 22 additions and 10 deletions

View file

@ -29,11 +29,11 @@ class GridBlock extends React.Component {
const topLeftImage =
(block.imageAlign === "top" || block.imageAlign === "left") &&
this.renderBlockImage(block.image);
this.renderBlockImage(block.image, block.imageLink);
const bottomRightImage =
(block.imageAlign === "bottom" || block.imageAlign === "right") &&
this.renderBlockImage(block.image);
this.renderBlockImage(block.image, block.imageLink);
return (
<div className={blockClasses} key={block.title}>
@ -49,13 +49,23 @@ class GridBlock extends React.Component {
);
}
renderBlockImage(image) {
renderBlockImage(image, imageLink) {
if (image) {
return (
<div className="blockImage">
<img src={image} />
</div>
);
if (imageLink) {
return (
<div className="blockImage">
<a href={imageLink}>
<img src={image} />
</a>
</div>
);
} else {
return (
<div className="blockImage">
<img src={image} />
</div>
);
}
} else {
return null;
}
@ -65,7 +75,9 @@ class GridBlock extends React.Component {
if (title) {
return (
<h2>
<Marked>{title}</Marked>
<Marked>
{title}
</Marked>
</h2>
);
} else {