This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
meta.js
115 lines (109 loc) · 3.11 KB
/
meta.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React, { Component } from 'react'
import { shuffle } from 'd3-array'
import { postMessage } from '../lib/withInNativeApp'
import Front from '../components/Front'
import {
TitleBlock,
Editorial,
Interaction,
Center,
Figure,
FigureImage,
FigureCaption,
FigureByline
} from '@project-r/styleguide'
import QuestionnaireMetaWidget from '../components/Questionnaire/QuestionnaireMetaWidget'
import { data as gallery } from '../lib/meta/gallery.json'
import withT from '../lib/withT'
import Gallery from '../components/Gallery/Gallery'
const GallerHeading = withT(({ t }) => (
<Interaction.H3
style={{
marginTop: 30,
marginBottom: 20,
textAlign: 'center'
}}
>
{t('pages/meta/behind/gallery')}
</Interaction.H3>
))
class MetaPage extends Component {
static async getInitialProps() {
return {
galleryItems: shuffle(gallery)
}
}
constructor(props) {
super(props)
this.state = {
gallery: false
}
this.toggleGallery = () => {
this.setState({ gallery: !this.state.gallery }, () =>
postMessage({
type: !this.state.gallery ? 'fullscreen-enter' : 'fullscreen-exit'
})
)
}
}
render() {
const { galleryItems = [] } = this.props
const galleryImage = galleryItems[0]
const containerStyle = {
maxWidth: 1200,
margin: '0 auto'
}
return (
<Front
containerStyle={containerStyle}
renderBefore={meta =>
meta && (
<TitleBlock center>
<Interaction.Headline>{meta.title}</Interaction.Headline>
<Editorial.Lead>{meta.description}</Editorial.Lead>
</TitleBlock>
)
}
renderAfter={
galleryImage
? meta =>
meta && (
<div style={{ ...containerStyle, marginBottom: 100 }}>
<QuestionnaireMetaWidget />
<Center>
<GallerHeading />
{this.state.gallery && (
<Gallery
onClose={this.toggleGallery}
items={galleryItems}
/>
)}
<Figure>
<div
style={{ cursor: 'pointer' }}
onClick={this.toggleGallery}
>
<FigureImage
{...FigureImage.utils.getResizedSrcs(
galleryImage.src,
700
)}
alt={galleryImage.alt}
/>
</div>
<FigureCaption>
{galleryImage.caption}{' '}
<FigureByline>{galleryImage.credit}</FigureByline>
</FigureCaption>
</Figure>
</Center>
</div>
)
: undefined
}
path='/verlag'
/>
)
}
}
export default MetaPage