1
1
import React from 'react' ;
2
2
import styled from 'react-emotion' ;
3
- import { space } from 'styled-system' ;
3
+ import { space , fontSize } from 'styled-system' ;
4
4
import { Flex , Box } from 'grid-emotion' ;
5
5
import TimeIcon from 'react-icons/lib/md/access-time' ;
6
6
import format from 'date-fns/format' ;
@@ -10,28 +10,30 @@ import TicketIcon from 'react-icons/lib/md/exit-to-app';
10
10
import StreamIcon from 'react-icons/lib/md/desktop-mac' ;
11
11
12
12
import { breakpoints , Button , graySecondary } from '../../utils/base.styles' ;
13
+ import truncateString from '../../utils' ;
13
14
14
- const Card = styled . div `
15
+ const Card = styled ( Flex ) `
15
16
${ space } ;
16
17
background: #fff;
17
18
border: 1px solid ${ graySecondary } ;
19
+ min-height: 120px;
18
20
& .eventPhoto {
21
+ height: 120px;
19
22
width: 100%;
20
- height: 150px;
21
- vertical-align: middle;
22
- object-fit: cover;
23
- }
24
- & .title {
25
- font-size: 1rem;
26
- font-weight: 350;
27
- color: #000;
28
- border-bottom: 1px solid ${ graySecondary } ;
23
+ ${ breakpoints . sm } {
24
+ object-fit: cover;
25
+ height: 200px;
26
+ }
29
27
${ breakpoints . xs } {
30
- font-size: 0.9rem;
28
+ height: 200px;
29
+ object-fit: cover;
31
30
}
32
31
}
32
+ & .eventDetails {
33
+ min-height: 120px;
34
+ }
33
35
& .secondaryText {
34
- font-size: 0.8rem ;
36
+ ${ fontSize } ;
35
37
color: #36434d;
36
38
}
37
39
& .icons {
@@ -41,53 +43,79 @@ const Card = styled.div`
41
43
}
42
44
& .rsvp {
43
45
text-align: right;
46
+ ${ breakpoints . sm } {
47
+ text-align: left;
48
+ & > * {
49
+ width: 100%;
50
+ display: block;
51
+ text-align: center;
52
+ margin: 0;
53
+ }
54
+ }
55
+ ${ breakpoints . xs } {
56
+ text-align: left;
57
+ & > * {
58
+ width: 100%;
59
+ display: block;
60
+ text-align: center;
61
+ margin: 0;
62
+ }
63
+ }
44
64
}
45
65
` ;
46
66
67
+ const CardTitle = styled . h3 `
68
+ ${ space } ;
69
+ font-weight: 650;
70
+ border-bottom: 1px solid ${ graySecondary } ;
71
+ ` ;
72
+
47
73
export default props => (
48
- < Card m = { 2 } >
49
- < Flex wrap >
50
- < Box width = { [ 1 , 1 / 3 , 1 / 4 , 1 / 4 ] } >
51
- < img className = "eventPhoto" src = { props . image } />
52
- </ Box >
53
- < Box width = { [ 1 , 2 / 3 , 3 / 4 , 3 / 4 ] } pb = { 1 } pt = { 1 } >
54
- < Flex column justify = { 'space-between' } align = { 'stretch' } >
55
- < Box className = "title" pr = { 1 } pl = { 1 } >
56
- { props . name }
57
- </ Box >
58
- < Box className = "secondaryText" pr = { 1 } pl = { 1 } >
59
- < LocationIcon className = "icons" />
60
- < span > { props . location } </ span >
61
- </ Box >
62
- < Box pr = { 1 } pl = { 1 } >
63
- < Flex wrap >
64
- < Box className = "secondaryText" pr = { 1 } >
65
- < TimeIcon className = "icons" />
74
+ < Card my = { [ 3 ] } wrap >
75
+ < Flex align = "streach" width = { [ 1 , 1 , 1 / 4 ] } >
76
+ < img
77
+ className = "eventPhoto"
78
+ src = { `https://res.cloudinary.com/coderplex/image/fetch/w_200,h_150/${ props . image } ` }
79
+ srcSet = { `https://res.cloudinary.com/coderplex/image/fetch/w_300,h_200/${
80
+ props . image
81
+ } 720w, https://res.cloudinary.com/coderplex/image/fetch/w_200,h_150/${ props . image } 1024w`}
82
+ />
83
+ </ Flex >
84
+ < Box className = "eventDetails" width = { [ 1 , 1 , 3 / 4 ] } >
85
+ < Flex className = "eventDetails" column justify = "space-between" >
86
+ < CardTitle inverted color = "#222" px = { [ 2 ] } py = { [ 1 ] } m = { 0 } >
87
+ { truncateString ( props . name , 64 ) }
88
+ </ CardTitle >
89
+ < Box fontSize = { [ 12 , 14 , 16 ] } className = "secondaryText" px = { [ 2 ] } my = { [ 1 , 1 , 0 ] } >
90
+ < LocationIcon className = "icons" />
91
+ < span > { props . location } </ span >
92
+ </ Box >
93
+ < Box px = { 2 } pb = { [ 2 , 1 ] } >
94
+ < Flex wrap >
95
+ < Box fontSize = { [ 12 , 14 , 16 ] } width = { [ 1 , 1 , 0.33 ] } className = "secondaryText" pr = { 1 } mr = { [ 0 ] } my = { [ 1 , 1 , 0 ] } >
96
+ < TimeIcon className = "icons" />
97
+ < span >
66
98
{ props . tense === 'past'
67
99
? format ( props . time , "ddd MMM Do 'YY" )
68
100
: format ( props . time , "h:mm A, ddd MMM Do 'YY" ) }
69
- </ Box >
70
- < Box className = "secondaryText" pr = { 1 } >
71
- < AttendeesIcon className = "icons" />
72
- { props . tense === 'past' ? `${ props . attendees } attended` : `${ props . attendees } attending` }
73
- </ Box >
74
- < Box className = "secondaryText" pr = { 1 } >
75
- { props . tense === 'past' ? null : (
76
- < div >
77
- { props . online ? < StreamIcon className = "icons" /> : < TicketIcon className = "icons" /> }
78
- { props . online ? 'Free session' : 'Free entry' }
79
- </ div >
80
- ) }
81
- </ Box >
82
- < Box flex = "1 1 auto" className = "rsvp" >
83
- < Button href = { props . link } ghost >
84
- { props . tense === 'past' ? 'View' : 'RSVP' }
85
- </ Button >
86
- </ Box >
87
- </ Flex >
88
- </ Box >
89
- </ Flex >
90
- </ Box >
91
- </ Flex >
101
+ </ span >
102
+ </ Box >
103
+ < Box fontSize = { [ 12 , 14 , 16 ] } width = { [ 1 , 1 , 0.25 ] } className = "secondaryText" pr = { 1 } mx = { [ 0 ] } my = { [ 1 , 1 , 0 ] } >
104
+ < AttendeesIcon className = "icons" />
105
+ < span > { props . tense === 'past' ? `${ props . attendees } attended` : `${ props . attendees } attending` } </ span >
106
+ </ Box >
107
+ < Box fontSize = { [ 12 , 14 , 16 ] } width = { [ 1 , 1 , 0.25 ] } className = "secondaryText" pr = { 1 } mx = { [ 0 ] } my = { [ 1 , 1 , 0 ] } >
108
+ { props . online ? < StreamIcon className = "icons" /> : < TicketIcon className = "icons" /> }
109
+ < span > { props . online ? 'Free session' : 'Free entry' } </ span >
110
+ </ Box >
111
+ < Box fontSize = { [ 12 , 14 , 16 ] } width = { [ 1 , 1 , 0.17 ] } mt = { [ 1 , 1 , 0 ] } className = "rsvp" >
112
+ < Button href = { props . link } ghost small >
113
+ { props . tense === 'past' ? 'View' : 'RSVP' }
114
+ </ Button >
115
+ </ Box >
116
+ </ Flex >
117
+ </ Box >
118
+ </ Flex >
119
+ </ Box >
92
120
</ Card >
93
121
) ;
0 commit comments