-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChallengeItem.js
More file actions
131 lines (127 loc) · 4.76 KB
/
ChallengeItem.js
File metadata and controls
131 lines (127 loc) · 4.76 KB
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
import React, { useState } from 'react'
import './style.scss'
import Markdown from '../Markdown'
import { requirePropFactory } from '@material-ui/core'
const ChallengeItem = ({ item }) => {
//Animation duration
const aDur = 0.6
const {
name,
company,
shorttext,
long_text,
thechallenge,
insights,
price,
judging,
aboutcompany,
insightimage,
tags,
key,
} = item
var { cardbackground, icon } = item
if (!cardbackground) {
cardbackground = { url: '' }
}
if (!icon) {
icon = { url: '' }
}
const [open, toggleOpen] = useState(false)
const [clicable, toggleClicable] = useState(true)
var blurStyle = ""
var isFirefox = typeof InstallTrigger !== 'undefined'
const flipStyle = (e, state) => {
e.currentTarget.classList.toggle('flip', state)
e.currentTarget.doneAnimating = !state
}
const flipCard = (e) => {
console.log('===', clicable)
if (!clicable) {
return
}
let duration = aDur * 1000
flipStyle(e, true)
setTimeout(() => toggleOpen(!open), duration / 2)
}
if (isFirefox) {
blurStyle = "FirefoxBlur"
} else {
blurStyle = "Blur"
}
console.log(blurStyle)
if (open) {
return (
<div className={blurStyle} onClick={(e) => flipCard(e)}>
<div
className="ChallengeItem open flip"
style={{ animationDuration: aDur + 's' }}
onAnimationEnd={(e) => flipStyle(e, false)}
onMouseEnter={(e) => {
toggleClicable(false)
}}
onMouseLeave={(e) => {
toggleClicable(true)
}}
>
<div className="ChallengeItem--text">
<img class="ChallengeIco open" src={icon.url} />
<span
href="#"
class="close"
onMouseEnter={(e) => {
toggleClicable(true)
}}
onMouseLeave={(e) => {
toggleClicable(false)
}}
></span>
<span className="ChallengeItem--title">{name}</span>
<p className="ChallengeItem--description">{shorttext}</p>
<p className="ChallengeItem--description">{long_text}</p>
<div className="ChallengeItem--subsection">
<p className="ChallengeItem--left">The Challenge</p>
<p className="ChallengeItem--right">{thechallenge}</p>
</div>
<div className="ChallengeItem--subsection">
<p className="ChallengeItem--left">Insights</p>
<p className="ChallengeItem--right">{insights}</p>
</div>
{insightimage && <img class="InsightImg" src={insightimage.url} />}
<div className="ChallengeItem--subsection">
<p className="ChallengeItem--left">The Prize</p>
<p className="ChallengeItem--right">{price}</p>
</div>
<div className="ChallengeItem--subsection">
<p className="ChallengeItem--left">Judging Criteria</p>
<p className="ChallengeItem--right">{judging}</p>
</div>
<div className="ChallengeItem--subsection">
<p className="ChallengeItem--left">About the company</p>
<p className="ChallengeItem--right">{aboutcompany}</p>
</div>
</div>
</div>
</div>
)
}
return (
<div
className="ChallengeItem closed flip"
style={{
backgroundImage: 'url(' + cardbackground.url + ')',
animationDuration: aDur + 's',
}}
onAnimationEnd={(e) => flipStyle(e, false)}
onClick={(e) => flipCard(e)}
>
<div className="ChallengeItem--logowpr">
<img class="ChallengeIco" src={icon.url} />
</div>
<div className="ChallengeItem--text">
<span className="ChallengeItem--title">{name}</span>
<p className="ChallengeItem--description">{shorttext}</p>
</div>
</div>
)
}
export default ChallengeItem