-
Notifications
You must be signed in to change notification settings - Fork 8
/
Detail.js
137 lines (122 loc) · 3.11 KB
/
Detail.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import { css } from 'glamor'
import { parseDate, swissTime } from '../../lib/utils/format'
import { intersperse } from '../../lib/utils/helpers'
import withT from '../../lib/withT'
import {
Interaction,
A,
RawHtml,
fontFamilies,
mediaQueries,
useColorContext,
} from '@project-r/styleguide'
import ActionBar from '../ActionBar'
import { PUBLIC_BASE_URL } from '../../lib/constants'
export const EVENT_PADDING = 60
const BLOCK_PADDING_TOP = 10
const styles = {
container: css({
marginBottom: 60,
}),
block: css({
padding: `${BLOCK_PADDING_TOP}px 0`,
borderTopWidth: 1,
borderTopStyle: 'solid',
position: 'relative',
wordWrap: 'break-word',
[mediaQueries.mUp]: {
paddingLeft: EVENT_PADDING,
},
}),
hr: css({
height: 0,
border: 0,
borderTopWidth: 1,
borderTopStyle: 'solid',
}),
title: css({
marginBottom: 15,
}),
label: css({
fontSize: 17,
fontFamily: fontFamilies.sansSerifMedium,
[mediaQueries.mUp]: {
lineHeight: '25px',
position: 'absolute',
left: 0,
top: BLOCK_PADDING_TOP + 3,
},
}),
}
const Label = ({ children }) => <div {...styles.label}>{children}</div>
const { H1, P } = Interaction
const weekday = swissTime.format('%A')
const Event = withT(
({
t,
data: {
title,
description,
link,
date: rawDate,
time,
where,
locationLink,
slug,
},
}) => {
const [colorScheme] = useColorContext()
const date = parseDate(rawDate)
let location =
!!where && intersperse(where.split('\n'), (d, i) => <br key={i} />)
if (locationLink && location) {
location = (
<A href={locationLink} target='_blank' rel='noreferrer'>
{location}
</A>
)
}
const shareObject = {
title: title,
url: `${PUBLIC_BASE_URL}/veranstaltung/${slug}`,
emailSubject: title,
tweet: title,
shareOverlayTitle: t('events/share/title'),
label: t('events/share/title'),
}
const borderRule = colorScheme.set('borderTopColor', 'divider')
return (
<div {...styles.container}>
<div {...styles.block} {...borderRule}>
<Label>{t('events/labels/description')}</Label>
<H1 {...styles.title}>{title}</H1>
<RawHtml
type={P}
key={slug}
dangerouslySetInnerHTML={{
__html: description.split('\n').join('<br />'),
}}
/>
{!!link && (
<P>
<A href={link} target='_blank' rel='noreferrer'>
{link}
</A>
</P>
)}
</div>
<div {...styles.block} {...borderRule}>
<Label>{t('events/labels/date')}</Label>
<P>{[weekday(date), rawDate, time].join(', ')}</P>
</div>
<div {...styles.block} {...borderRule}>
{!!where && <Label>{t('events/labels/location')}</Label>}
{!!where && <P>{location}</P>}
{!!where && <hr {...styles.hr} {...borderRule} />}
<ActionBar share={shareObject} />
</div>
</div>
)
},
)
export default Event