Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

feat: add solved indicator on tree view

bautistaaa984aae32367f
diff --git a/apps/aot/src/app/events/[year]/GiftBox.tsx b/apps/aot/src/app/events/[year]/GiftBox.tsx
index 7cda43f5..9d165c27 100644
--- a/apps/aot/src/app/events/[year]/GiftBox.tsx
+++ b/apps/aot/src/app/events/[year]/GiftBox.tsx
@@ -1,4 +1,5 @@
'use client';
+import { Star } from '@repo/ui/icons';
import { motion } from 'framer-motion';
import Image from 'next/image';
import gift1 from '~/../public/giftbox.png';
@@ -11,9 +12,11 @@ export default function GiftBox({
day,
active,
index,
+ hasSolved,
}: {
day: number;
active: boolean;
+ hasSolved: boolean;
index: number;
}) {
return (
@@ -25,6 +28,9 @@ export default function GiftBox({
index == 2 && 'ml-20 mr-12'
}`}
>
+ {hasSolved ? (
+ <Star className="absolute right-1 top-1 z-50 h-3 w-3 select-none fill-yellow-600 text-yellow-600 dark:fill-yellow-300 dark:text-yellow-300" />
+ ) : null}
<Image
className={`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 select-none brightness-100 ${
!active && 'opacity-50 grayscale'
diff --git a/apps/aot/src/app/events/[year]/day-active.tsx b/apps/aot/src/app/events/[year]/day-active.tsx
index 764b2bf1..699d3e7f 100644
--- a/apps/aot/src/app/events/[year]/day-active.tsx
+++ b/apps/aot/src/app/events/[year]/day-active.tsx
@@ -3,6 +3,7 @@ import star from '~/../public/star.png';
import Image from 'next/image';
import { motion } from 'framer-motion';
+import { Star } from '@repo/ui/icons';
const colorsArray = [
'from-blue-200 dark:from-blue-800 via-blue-600 dark:via-blue-400 to-blue-100 dark:to-blue-900',
@@ -29,6 +30,9 @@ export default function DayActive({ day, hasSolved }: { day: number; hasSolved:
day === 22 && 'h-14'
}`}
>
+ {hasSolved ? (
+ <Star className="absolute right-1 top-1 z-50 h-3 w-3 select-none fill-yellow-600 text-yellow-600 dark:fill-yellow-300 dark:text-yellow-300" />
+ ) : null}
{day === 1 && (
<Image
className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 select-none brightness-100 grayscale-0 group-hover:brightness-90 dark:brightness-50"
@@ -38,10 +42,7 @@ export default function DayActive({ day, hasSolved }: { day: number; hasSolved:
height={64}
/>
)}
- <h1 className="z-10 font-bold">
- {day}
- {hasSolved ? '' : undefined}
- </h1>
+ <h1 className="z-10 font-bold">{day}</h1>
</div>
</motion.div>
);
diff --git a/apps/aot/src/app/events/[year]/page.tsx b/apps/aot/src/app/events/[year]/page.tsx
index 63ae8b21..dd314d26 100644
--- a/apps/aot/src/app/events/[year]/page.tsx
+++ b/apps/aot/src/app/events/[year]/page.tsx
@@ -84,7 +84,12 @@ export default async function EventByYearLandingPage({ params }: Props) {
<>
{day.active ? (
<Link key={day.day} href={`/events/${year}/${day.day}`}>
- <GiftBox day={day.day} active={day.active} index={index} />
+ <GiftBox
+ day={day.day}
+ active={day.active}
+ index={index}
+ hasSolved={day.hasSolved}
+ />
</Link>
) : (
<GiftBox key={day.day} day={day.day} active={day.active} index={index} />
diff --git a/packages/ui/src/icons.ts b/packages/ui/src/icons.ts
index 32d6a7aa..19378233 100644
--- a/packages/ui/src/icons.ts
+++ b/packages/ui/src/icons.ts
@@ -65,6 +65,7 @@ export {
Settings,
Settings2,
Shapes,
+ Star,
Palette,
Share,
Shield,