-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventCard.js
117 lines (112 loc) · 2.36 KB
/
EventCard.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
import React from 'react';
import {
Text,
View,
StyleSheet,
} from 'react-native';
import PropTypes from 'prop-types';
import {
formatDate,
getCountdownParts,
} from './api';
const styles = StyleSheet.create({
card: {
backgroundColor: '#fff',
flex: 1,
padding: 10,
paddingTop: 10,
paddingBottom: 20,
margin: 10,
marginTop: 5,
marginBottom: 5,
},
cardHeader: {
flex: 1,
flexDirection: 'row',
},
date: {
fontWeight: '200',
fontSize: 15,
color: '#bdbdbd',
width: '30%',
textAlign: 'right',
},
title: {
fontSize: 15,
fontWeight: '300',
marginLeft: 7,
textAlign: 'left',
},
counterContainer: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
paddingLeft: '5%',
paddingRight: '5%',
},
counter: {
width: '25%',
flex: 1,
},
counterText: {
fontSize: 40,
textAlign: 'center',
},
counterLabel: {
fontSize: 13,
fontWeight: '100',
color: '#a3a3a3',
textAlign: 'center',
paddingTop: 0,
},
});
export default function EventCard({ event }) {
const {
days,
hours,
minutes,
seconds,
} = getCountdownParts(event.date);
return (
<View style={styles.card}>
<View style={styles.cardHeader}>
<Text style={styles.date}>{formatDate(event.date)}</Text>
<Text style={styles.title}>{event.title}</Text>
</View>
<View
style={styles.counterContainer}
>
<View
style={styles.counter}
>
<Text style={styles.counterText}>{days}</Text>
<Text style={styles.counterLabel}>DAYS</Text>
</View>
<View
style={styles.counter}
>
<Text style={styles.counterText}>{hours}</Text>
<Text style={styles.counterLabel}>HOURS</Text>
</View>
<View
style={styles.counter}
>
<Text style={styles.counterText}>{minutes}</Text>
<Text style={styles.counterLabel}>MINUTES</Text>
</View>
<View
style={styles.counter}
>
<Text style={styles.counterText}>{seconds}</Text>
<Text style={styles.counterLabel}>SECONDS</Text>
</View>
</View>
</View>
);
}
EventCard.propTypes = {
event: PropTypes.shape({
title: PropTypes.string.isRequired,
date: PropTypes.instanceOf(Date)
}),
};