1
|
|
|
import { CardImage, CardTeaser, CardTeaserVertical } from "./Card" |
2
|
|
|
import "./news-item.scss" |
3
|
|
|
import React, { Component } from "react" |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Render a single news item in default card layout. |
7
|
|
|
*/ |
8
|
|
|
export class NewsItemCard extends Component { |
9
|
|
|
render() { |
10
|
|
|
const { node, teaser = false } = this.props |
11
|
|
|
const localFile = node.relationships.field_media_article_image.relationships.field_media_image.localFile |
12
|
|
|
const summary = teaser && node.body.summary |
13
|
|
|
|
14
|
|
|
const relatedTags = node.relationships.field_tags || [] |
15
|
|
|
|
16
|
|
|
return ( |
17
|
|
|
<CardTeaser |
18
|
|
|
title={node.title} |
19
|
|
|
body={summary} |
20
|
|
|
picture={localFile} |
21
|
|
|
link={node.path.alias} |
22
|
|
|
metadata={true} |
23
|
|
|
tags={relatedTags} |
24
|
|
|
createTime={node.created} |
25
|
|
|
key={node.nid} |
26
|
|
|
className={`test`} |
27
|
|
|
/> |
28
|
|
|
) |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Render a single news item in image focus card layout. |
34
|
|
|
*/ |
35
|
|
|
export class NewsItemFeatured extends Component { |
36
|
|
|
render() { |
37
|
|
|
const { node } = this.props |
38
|
|
|
const localFile = node.relationships.field_media_article_image.relationships.field_media_image.localFile |
39
|
|
|
|
40
|
|
|
return <CardImage title={node.title} picture={localFile} link={node.path.alias} /> |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Render a single news item in vertical image card layout. |
46
|
|
|
*/ |
47
|
|
|
export class NewsItemSquare extends Component { |
48
|
|
|
render() { |
49
|
|
|
const { node } = this.props |
50
|
|
|
const localFile = node.relationships.field_media_article_image.relationships.field_media_image.localFile |
51
|
|
|
|
52
|
|
|
return <CardTeaserVertical title={node.title} picture={localFile} link={node.path.alias} /> |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Render news item in appropriate layout depending on the aspect ratio. |
58
|
|
|
*/ |
59
|
|
|
export class NewsItemCardRatio extends Component { |
60
|
|
|
render() { |
61
|
|
|
const { node, teaser = false } = this.props |
62
|
|
|
|
63
|
|
|
const { gatsbyImageData: heroImage } = |
64
|
|
|
node.relationships.field_media_article_image.relationships.field_media_image.localFile.childImageSharp |
65
|
|
|
|
66
|
|
|
const aspectRatio = heroImage.width / heroImage.height |
67
|
|
|
|
68
|
|
|
if (aspectRatio >= 1) { |
69
|
|
|
return <NewsItemCard node={node} teaser={teaser} /> |
70
|
|
|
} else { |
71
|
|
|
return <NewsItemSquare node={node} /> |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Render a single KCVV TV item in default card layout. |
78
|
|
|
*/ |
79
|
|
|
export class KcvvTvCard extends Component { |
80
|
|
|
render() { |
81
|
|
|
const { node } = this.props |
82
|
|
|
const localFile = node.relationships.field_media_article_image.relationships.field_media_image.localFile |
83
|
|
|
const summary = `${node.title}<br/><br/>Bekijk hier het wedstrijdverslag, interviews, nabespreking... en stem voor je man van de match!` |
84
|
|
|
return ( |
85
|
|
|
<CardImage |
86
|
|
|
title={`KCVV TV`} |
87
|
|
|
icon={`fa-facebook-square`} |
88
|
|
|
body={summary} |
89
|
|
|
picture={localFile} |
90
|
|
|
link={node.field_website.uri} |
91
|
|
|
metadata={true} |
92
|
|
|
key={node.nid} |
93
|
|
|
createTime={node.created} |
94
|
|
|
/> |
95
|
|
|
) |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|