Skip to content

Commit 8009816

Browse files
authored
Merge pull request #29 from cherryontech/feat/challenges
feat(challenges): created challenges pages
2 parents 6cf6c15 + 057b5c4 commit 8009816

File tree

2 files changed

+91
-60
lines changed

2 files changed

+91
-60
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { tv } from "tailwind-variants/lite";
2+
import Button from "../Button";
3+
import { FaArrowRight } from "react-icons/fa6";
4+
5+
const tileVariants = tv({
6+
base: 'font-poppins flex flex-col justify-start py-6 px-4 rounded-lg shadow-[0_4px_15px_rgba(0,0,0,0.25)]',
7+
8+
variants: {
9+
size: {
10+
sm: 'h-[222px]',
11+
lg: 'h-[222px] md:h-[340px]'
12+
},
13+
span: {
14+
2: 'col-span-1 md:col-span-2',
15+
3: 'col-span-1 md:col-span-3'
16+
}
17+
},
18+
});
19+
20+
export default function ChallengeTile({ size, span, title, subtitle, tags, to }){
21+
return (
22+
<div className={tileVariants({ size, span })}>
23+
<div className="h-full flex flex-col justify-between">
24+
<div className="flex flex-col gap-2">
25+
<h2 className="text-lg md:text-[20px] font-medium">{title}</h2>
26+
<p className="text-base">{subtitle}</p>
27+
</div>
28+
{/* tag and button */}
29+
<div className="flex flex-row justify-between items-center">
30+
<p className="flex-1">{tags}</p>
31+
<Button
32+
size='circ'
33+
color='primary'
34+
label={<FaArrowRight/>}
35+
to={to}
36+
/>
37+
</div>
38+
</div>
39+
</div>
40+
);
41+
};

src/pages/Challenges.jsx

Lines changed: 50 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,56 @@
1-
import { db } from "../firebase";
2-
import { doc, setDoc, updateDoc, getDoc } from "firebase/firestore";
31
import Button from "../components/Button";
4-
import { useState } from "react";
2+
import ChallengeTile from "../components/Challenges/ChallengeTile";
53

64
export default function Challenges() {
7-
// use state to use data
8-
const [teamData, setTeamData] = useState(null);
9-
10-
// add a new document in the collection test function
11-
async function writeTestDoc() {
12-
// create a collection with a document called team
13-
try {
14-
await setDoc(doc(db, "test", "team"), {
15-
name: "Mint Chip Mavericks",
16-
sprintsCompleted: 3
17-
});
18-
console.log("New Team data added")
19-
} catch (error) {
20-
console.error("The error found", error);
21-
};
22-
};
23-
24-
// update data in an existing doc
25-
async function addDataToDoc() {
26-
const teamDocRef = doc(db, "test", "team")
27-
await updateDoc(teamDocRef, {
28-
members: 3
29-
});
30-
31-
console.log("New field added");
32-
};
33-
34-
// read data in the doc to display
35-
async function readTestDoc() {
36-
const teamDocRef = doc(db, "test", "team");
37-
const teamDocSnap = await getDoc(teamDocRef);
38-
39-
if (teamDocSnap.exists()) {
40-
console.log("document data", teamDocSnap.data());
41-
setTeamData(teamDocSnap.data());
42-
} else {
43-
console.log("there is no data")
44-
};
45-
};
46-
475
return (
48-
<div className="min-h-screen bg-emerald-100 flex flex-col gap-10 items-center justify-center">
49-
<h1 className="text-4xl font-bold text-lime-500">Challenges Page! 🎉</h1>
50-
51-
{/* test write document button */}
52-
<Button onClick={writeTestDoc} label="create a collection/document" size="lg"/>
53-
54-
{/* update test document button */}
55-
<Button onClick={addDataToDoc} label="add data field to a document" size="lg"/>
56-
57-
{/* test read document button */}
58-
<Button onClick={readTestDoc} label="read a document and display data" size="lg"/>
59-
60-
{/* tester sentence with the added firestore data */}
61-
{teamData && (
62-
<p>{teamData.name} has {teamData.members} members and completed {teamData.sprintsCompleted} sprints!</p>
63-
)}
64-
</div>
6+
<div className="bg-white">
7+
{/* title section */}
8+
<div className="flex flex-col mx-8 sm:mx-15 md:mx-10 lg:mx-20 xl:mx-40 2xl:mx-80">
9+
<h1 className="text-3xl font-playfair font-semibold text-eerie place-self-center lg:place-self-start mt-4">Which task would you like to work on today?</h1>
10+
</div>
11+
12+
{/* challenge tile grid */}
13+
<div className="grid grid-cols-1 md:grid-cols-6 gap-8 auto-rows-min my-10 mx-8 sm:mx-15 md:mx-10 lg:mx-20 xl:mx-40 2xl:mx-80">
14+
{/* row 1 */}
15+
<ChallengeTile
16+
size="sm"
17+
span="2"
18+
title="Sleep 7-9 hours"
19+
subtitle="Better sleep means a better you."
20+
tags='#Sleep #Stress'
21+
/>
22+
<ChallengeTile
23+
size="sm"
24+
span="2"
25+
title="Read a Book"
26+
subtitle="Destress by reading for at least 20 minutes a day."
27+
tags='#Sleep #Stress'
28+
/>
29+
<ChallengeTile
30+
size="sm"
31+
span="2"
32+
title="Practice Saying No"
33+
subtitle="Learn the different ways you can say no in & outside in the office."
34+
tags='#Stress #SelfDoubt'
35+
/>
36+
37+
{/* row 2 */}
38+
<ChallengeTile
39+
size="lg"
40+
span="3"
41+
title="Read Positive Affirmations"
42+
subtitle="Recite empowering messages meant to help you fight self-doubt and anxiety."
43+
tags='#Sleep #SelfDoubt #GenderBias #Postpartum'
44+
/>
45+
<ChallengeTile
46+
size="lg"
47+
span="3"
48+
title="Daily Journal Entry"
49+
subtitle="Answer a different prompt each day or share what’s on your mind."
50+
tags='#Stress #SelfDoubt #GenderBias #Postpartum'
51+
to='/journal'
52+
/>
53+
</div>
54+
</div>
6555
);
6656
};

0 commit comments

Comments
 (0)