Skip to content

Commit 0940b48

Browse files
Merge pull request #124 from akshat-chd/Random_Identity
Random identity Added
2 parents 321320e + 903a0ce commit 0940b48

File tree

3 files changed

+411
-0
lines changed

3 files changed

+411
-0
lines changed

src/data/content.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import GKQuiz from "../pages/games/Gk_quiz"
2525
import { DogHttpCode } from "../pages/activities/DogHttpCode";
2626
import { CatHttpCode } from "../pages/activities/CatHttpCode";
2727
import FlappyBird from "../pages/games/FlappyBird";
28+
import RandomIdentity from "../pages/activities/RandomIdentity";
2829

2930
export const activities = [
3031
{
@@ -90,6 +91,13 @@ export const activities = [
9091
urlTerm: "cat-http-status",
9192
element: <CatHttpCode />,
9293
},
94+
{
95+
title: "Zodiac Sign",
96+
description:"Get to know your zodiac sign",
97+
icon:"https://is1-ssl.mzstatic.com/image/thumb/Purple211/v4/2a/51/52/2a5152df-66f0-fc94-6e5e-251d3b2d6ef8/AppIcon-0-0-1x_U007emarketing-0-6-0-85-220.png/1200x630wa.png",
98+
urlTerm:"zodiac-sign",
99+
element:<RandomIdentity/>
100+
}
93101
];
94102

95103
export const games = [
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import { useState } from "react";
2+
import "../../styles/pages/activities/RandomIdentity.css";
3+
4+
const zodiacData = {
5+
aries: { name: "Aries ♈", traits: ["Bold", "Energetic", "Starter"], message: "Start the thing. Your fire is useful today." },
6+
taurus: { name: "Taurus ♉", traits: ["Grounded", "Patient", "Steady"], message: "Go slow and solid. Comfort-first is okay." },
7+
gemini: { name: "Gemini ♊", traits: ["Curious", "Expressive", "Adaptable"], message: "Talk it out. A convo will unlock clarity." },
8+
cancer: { name: "Cancer ♋", traits: ["Caring", "Intuitive", "Protective"], message: "Nurture your circle. Your care will be noticed." },
9+
leo: { name: "Leo ♌", traits: ["Confident", "Creative", "Warm"], message: "Show your light. You’re the main character today." },
10+
virgo: { name: "Virgo ♍", traits: ["Detail-loving", "Helpful", "Practical"], message: "Fix one tiny thing. You’ll feel aligned right away." },
11+
libra: { name: "Libra ♎", traits: ["Balanced", "Charming", "Fair"], message: "Choose harmony, not speed. People will support you." },
12+
scorpio: { name: "Scorpio ♏", traits: ["Intense", "Loyal", "Deep"], message: "Go deeper, not wider. Depth will give you power." },
13+
sagittarius: { name: "Sagittarius ♐", traits: ["Adventurous", "Optimistic", "Honest"], message: "Say yes to something new — expansion wants you." },
14+
capricorn: { name: "Capricorn ♑", traits: ["Ambitious", "Disciplined", "Patient"], message: "Keep building. Quiet consistency will pay off." },
15+
aquarius: { name: "Aquarius ♒", traits: ["Original", "Big-picture", "Humanitarian"], message: "Share the weird idea. That’s the one people need." },
16+
pisces: { name: "Pisces ♓", traits: ["Empathic", "Dreamy", "Creative"], message: "Create from what you feel. Soft does not mean weak." },
17+
};
18+
19+
function getZodiac(month, day) {
20+
if ((month === 3 && day >= 21) || (month === 4 && day <= 19)) return "aries";
21+
if ((month === 4 && day >= 20) || (month === 5 && day <= 20)) return "taurus";
22+
if ((month === 5 && day >= 21) || (month === 6 && day <= 20)) return "gemini";
23+
if ((month === 6 && day >= 21) || (month === 7 && day <= 22)) return "cancer";
24+
if ((month === 7 && day >= 23) || (month === 8 && day <= 22)) return "leo";
25+
if ((month === 8 && day >= 23) || (month === 9 && day <= 22)) return "virgo";
26+
if ((month === 9 && day >= 23) || (month === 10 && day <= 22)) return "libra";
27+
if ((month === 10 && day >= 23) || (month === 11 && day <= 21)) return "scorpio";
28+
if ((month === 11 && day >= 22) || (month === 12 && day <= 21)) return "sagittarius";
29+
if ((month === 12 && day >= 22) || (month === 1 && day <= 19)) return "capricorn";
30+
if ((month === 1 && day >= 20) || (month === 2 && day <= 18)) return "aquarius";
31+
return "pisces";
32+
}
33+
34+
export default function RandomIdentity() {
35+
const [date, setDate] = useState("");
36+
const [zodiac, setZodiac] = useState(null);
37+
const [showResult, setShowResult] = useState(false);
38+
const [confettiKey, setConfettiKey] = useState(0);
39+
40+
function handleSubmit(e) {
41+
e.preventDefault();
42+
if (!date) return;
43+
const d = new Date(date);
44+
const month = d.getMonth() + 1;
45+
const day = d.getDate();
46+
const zKey = getZodiac(month, day);
47+
setZodiac(zodiacData[zKey]);
48+
setShowResult(false);
49+
setConfettiKey((k) => k + 1);
50+
setTimeout(() => setShowResult(true), 15);
51+
}
52+
53+
return (
54+
<div className="identity-light-container with-anim">
55+
<div className="id-bubble id-b1"></div>
56+
<div className="id-bubble id-b2"></div>
57+
<div className="id-bubble id-b3"></div>
58+
59+
{showResult && (
60+
<div key={confettiKey} className="party-layer">
61+
<div className="party-bomber left-bomber"></div>
62+
<div className="party-bomber right-bomber"></div>
63+
<div className="party-confetti c1"></div>
64+
<div className="party-confetti c2"></div>
65+
<div className="party-confetti c3"></div>
66+
<div className="party-confetti c4"></div>
67+
</div>
68+
)}
69+
70+
<div className="identity-card-light">
71+
<h2 className="identity-title-light">Your Zodiac Vibe ✨</h2>
72+
<p className="identity-sub-light">Enter your birth date to see your sign, traits, and today’s message.</p>
73+
74+
<form className="identity-form" onSubmit={handleSubmit}>
75+
<input
76+
type="date"
77+
className="identity-date-input"
78+
value={date}
79+
onChange={(e) => setDate(e.target.value)}
80+
max={new Date().toISOString().split("T")[0]}
81+
required
82+
/>
83+
<button type="submit" className="identity-btn-rect">
84+
Reveal
85+
</button>
86+
</form>
87+
88+
{showResult && zodiac && (
89+
<div className="identity-result pop-in glow">
90+
<p className="identity-label">Your zodiac sign</p>
91+
<h3 className="identity-zodiac-name">{zodiac.name}</h3>
92+
<div className="identity-traits">
93+
{zodiac.traits.map((t) => (
94+
<span key={t} className="identity-pill">
95+
{t}
96+
</span>
97+
))}
98+
</div>
99+
<p className="identity-message">{zodiac.message}</p>
100+
</div>
101+
)}
102+
</div>
103+
</div>
104+
);
105+
}

0 commit comments

Comments
 (0)