forked from skillrecordings/egghead-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestionReveal.js
More file actions
61 lines (58 loc) · 2.07 KB
/
QuestionReveal.js
File metadata and controls
61 lines (58 loc) · 2.07 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
import React from 'react'
import {motion, AnimatePresence} from 'framer-motion'
const QuestionReveal = ({children, question, action = 'Reveal Answer'}) => {
const [isShown, setShown] = React.useState(false)
return (
<div className="shadow border-gray-100 border-2 p-8 bg-gray-50 rounded-lg mt-12">
<div className="text-gray-600 text-base mx-auto text-center mt-3">
Test Your Knowledge
</div>
<div className="relative flex items-center justify-center font-sans text-center text-xl font-semibold leading-normal mt-2">
{question}
</div>
<div className="relative flex items-center justify-center p-8 bg-gray-50 rounded-lg mt-2">
<AnimatePresence>
{!isShown && (
<motion.div
className="absolute z-10 flex flex-col items-center"
initial={{opacity: 0}}
animate={{opacity: 1}}
exit={{opacity: 0}}
transition={{duration: 1, type: 'spring'}}
>
<div className="font-sans text-lg font-normal text-gray-700">
What's the answer?
</div>
<button
className="leading-8 mt-4 px-5 py-3 rounded-md bg-indigo-500 hover:bg-indigo-600 transition-colors duration-200 ease-in-out text-white"
onClick={() => setShown(!isShown)}
>
{action}
</button>
</motion.div>
)}
</AnimatePresence>
<motion.div
initial={{
filter: 'blur(8px)',
}}
animate={{
filter: isShown ? 'blur(0px)' : 'blur(8px)',
}}
transition={{duration: 2, type: 'spring'}}
css={{
'img, pre, .gif_player': {
display: isShown ? 'inherit' : 'none',
},
}}
className={!isShown && `max-h-48 overflow-hidden`}
>
<div className="font-sans text-lg font-normal text-gray-700">
{children}
</div>
</motion.div>
</div>
</div>
)
}
export default QuestionReveal