Skip to content

Commit 6c813bb

Browse files
Dhruv DangeDhruv Dange
authored andcommitted
Added easter egg quiz
1 parent 344f6a9 commit 6c813bb

File tree

5 files changed

+182
-2
lines changed

5 files changed

+182
-2
lines changed

components/HeroBanner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const HeroBanner = () => {
1515
<div className="row pt-5">
1616
<div className="col-lg-6 pb-5">
1717
<div className="d-md-block pycon-logo text-center text-lg-start">
18-
<a href="#">
18+
<a href="/2023/suprise">
1919
<Image src={logo} width="100%" height="100%" alt="" />
2020
</a>
2121
</div>

components/quiz.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import React, { useState, useEffect } from "react";
2+
import Button from 'react-bootstrap/Button';
3+
import Modal from 'react-bootstrap/Modal';
4+
5+
const Quiz = () => {
6+
const [answer, setAnswer] = useState("");
7+
const [questions, setQuestions] = useState([]);
8+
const [answersQ, setAnswersQ] = useState([]);
9+
const [currentQuestion, setCurrentQuestion] = useState(0);
10+
const [openModal, setOpenModal] = useState(false);
11+
const discountCode = "PYCON2023";
12+
13+
useEffect(() => {
14+
setQuestions([
15+
"Password",
16+
"What is the name of the conference? \nA. pycon2023 \n B. pycon2022 \n C. pycon2021 \n D. pycon2020",
17+
]);
18+
19+
setAnswersQ([
20+
"PYCON2023",
21+
'A',
22+
]);
23+
}, []);
24+
25+
useEffect(() => {
26+
if (answer.toUpperCase() === answersQ[currentQuestion]) {
27+
setAnswer("");
28+
setCurrentQuestion(currentQuestion + 1);
29+
if (currentQuestion === questions.length - 1) {
30+
setOpenModal(true);
31+
}
32+
}
33+
}, [answer]);
34+
35+
const handleAnswerChange = (event) => {
36+
setAnswer(event.target.value);
37+
};
38+
39+
const handleClose = () => {setOpenModal(false); window.location.href = "/2023";}
40+
const copyToClipboard = async () => {
41+
if ('clipboard' in navigator) {
42+
return await navigator.clipboard.writeText(discountCode);
43+
} else {
44+
return document.execCommand('copy', true, discountCode);
45+
}
46+
}
47+
48+
return (
49+
<>
50+
<div className="cyber-container">
51+
<div className="cyber-card">
52+
{currentQuestion !== 0 && (
53+
<h2 className="cyber-heading">
54+
Answer These Questions for a Special Prize!
55+
</h2>
56+
)}
57+
<div className="cyber-form-group">
58+
<label className="cyber-label" htmlFor="passwordInput">
59+
<text style={{whiteSpace: "pre-line"}}>{questions[currentQuestion]}</text>
60+
</label>
61+
<input
62+
type="password"
63+
className="cyber-form-control"
64+
id="passwordInput"
65+
value={answer}
66+
onChange={handleAnswerChange}
67+
/>
68+
</div>
69+
70+
<Modal show={openModal} onHide={handleClose}>
71+
<Modal.Header closeButton>
72+
<Modal.Title>Congratulations!</Modal.Title>
73+
</Modal.Header>
74+
<Modal.Body>Woohoo, you completed the quiz! Here is a pycon ticket discount code just for you! <br/> {discountCode}</Modal.Body>
75+
<Modal.Footer>
76+
<Button variant="secondary" onClick={handleClose}>
77+
Close
78+
</Button>
79+
<Button variant="primary" onClick={copyToClipboard}>
80+
Copy Code
81+
</Button>
82+
</Modal.Footer>
83+
</Modal>
84+
</div>
85+
</div>
86+
</>
87+
);
88+
};
89+
90+
export default Quiz;

pages/suprise.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Quiz from "../components/quiz";
2+
3+
type componentProps = {
4+
isMobile: boolean;
5+
};
6+
7+
export default function CyberQuiz() {
8+
return <Quiz />;
9+
}

public/images/logos/python-256.png

6.13 KB
Loading

styles/css/style.css

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,89 @@ button a {
239239
cursor: pointer;
240240
position: relative;
241241
}
242+
243+
/* Cyper Page CSS */
244+
.cyber-container {
245+
background-color: black;
246+
height: 100vh;
247+
display: flex;
248+
justify-content: center;
249+
align-items: center;
250+
}
251+
252+
.cyber-card {
253+
display: flex;
254+
flex-direction: column;
255+
align-items: center;
256+
padding: 20px;
257+
border-radius: 10px;
258+
}
259+
260+
.cyber-form-group {
261+
width: 100%;
262+
margin-bottom: 10px;
263+
display: flex;
264+
align-items: center; /* Align items on the same line */
265+
flex-direction: column;
266+
}
267+
268+
.cyber-label {
269+
color: #20C20E;
270+
font-size: 24px;
271+
margin: 2rem;
272+
}
273+
274+
.cyber-heading {
275+
position: fixed;
276+
top: 0;
277+
left: 0;
278+
right: 0;
279+
text-align: center;
280+
color: #20C20E;
281+
font-size: 2rem;
282+
margin: 0;
283+
padding: 1rem;
284+
background-color: black;
285+
}
286+
287+
288+
.cyber-label2 {
289+
color: #20C20E;
290+
font-size: 24px;
291+
margin-right: 10px;
292+
}
293+
294+
.cyber-form-control {
295+
flex: 1; /* Expand input to take remaining space */
296+
border: 2px solid #20C20E;
297+
background-color: black;
298+
color: white;
299+
padding: 10px;
300+
border-radius: 5px;
301+
outline: none;
302+
}
303+
304+
.cyber-btn-primary {
305+
background-color: #20C20E;
306+
border: none;
307+
padding: 10px 20px;
308+
border-radius: 5px;
309+
color: white;
310+
cursor: pointer;
311+
outline: none;
312+
}
313+
314+
@media (max-width: 768px) {
315+
.cyber-form-group {
316+
flex-direction: column; /* Change to column layout for mobile */
317+
}
318+
.cyber-label {
319+
margin: 0.2rem;
320+
margin-bottom: 1rem;
321+
}
322+
}
242323

243-
.green-btn {
324+
.green-btn {
244325
color: white;
245326
background-color: #1f928d;
246327
}

0 commit comments

Comments
 (0)