Connect, collaborate, and grow with a community of TypeScript developers
AoT Events Page lights decoration (#1720)
PickleNik2282d0c80e86
diff --git a/apps/aot/src/app/events/[year]/24BgDecorations.tsx b/apps/aot/src/app/events/[year]/24BgDecorations.tsxindex 711b8c6e..4a529a8f 100644--- a/apps/aot/src/app/events/[year]/24BgDecorations.tsx+++ b/apps/aot/src/app/events/[year]/24BgDecorations.tsx@@ -8,7 +8,7 @@ export default function BgDecorations() {initial={{ opacity: 0, transform: 'rotateX(69deg) translate(-50%, 115%)' }}animate={{ opacity: 1, transform: 'rotateX(69deg) translate(-50%, 135%)' }}transition={{ delay: 22 * 0.025, type: 'spring' }}- className="absolute bottom-0 left-1/2 h-[30rem] w-[30rem] overflow-hidden rounded-full bg-black/5 dark:bg-white/5"+ className="pointer-events-none absolute bottom-0 left-1/2 h-[30rem] w-[30rem] overflow-hidden rounded-full bg-black/5 dark:bg-white/5"style={{perspective: '1000px',}}@@ -17,7 +17,7 @@ export default function BgDecorations() {initial={{ opacity: 0, transform: 'rotateX(69deg) translate(-50%, 125%)' }}animate={{ opacity: 1, transform: 'rotateX(69deg) translate(-50%, 145%)' }}transition={{ delay: 26 * 0.025, type: 'spring' }}- className="absolute bottom-0 left-1/2 h-[35rem] w-[35rem] overflow-hidden rounded-full bg-black/5 dark:bg-white/5"+ className="pointer-events-none absolute bottom-0 left-1/2 h-[35rem] w-[35rem] overflow-hidden rounded-full bg-black/5 dark:bg-white/5"style={{perspective: '1000px',}}@@ -26,7 +26,7 @@ export default function BgDecorations() {initial={{ opacity: 0, transform: 'rotateX(69deg) translate(-50%, 135%)' }}animate={{ opacity: 1, transform: 'rotateX(69deg) translate(-50%, 155%)' }}transition={{ delay: 30 * 0.025, type: 'spring' }}- className="absolute bottom-0 left-1/2 h-[40rem] w-[40rem] overflow-hidden rounded-full bg-black/5 dark:bg-white/5"+ className="pointer-events-none absolute bottom-0 left-1/2 h-[40rem] w-[40rem] overflow-hidden rounded-full bg-black/5 dark:bg-white/5"style={{transform: 'rotateX(69deg) translate(-50%, 155%)',perspective: '1000px',@@ -36,7 +36,7 @@ export default function BgDecorations() {initial={{ opacity: 0, transform: 'rotateX(69deg) translate(-50%, 115%)' }}animate={{ opacity: 1, transform: 'rotateX(69deg) translate(-50%, 135%)' }}transition={{ delay: 22 * 0.025, type: 'spring' }}- className="absolute bottom-0 left-1/2 h-96 w-96 overflow-hidden rounded-full bg-gradient-to-b from-pink-400/10 to-emerald-400/10 blur-xl"+ className="pointer-events-none absolute bottom-0 left-1/2 h-96 w-96 overflow-hidden rounded-full bg-gradient-to-b from-pink-400/10 to-emerald-400/10 blur-xl"style={{perspective: '1000px',}}diff --git a/apps/aot/src/app/events/[year]/Lights/Bulb.tsx b/apps/aot/src/app/events/[year]/Lights/Bulb.tsxnew file mode 100644index 00000000..69c444ee--- /dev/null+++ b/apps/aot/src/app/events/[year]/Lights/Bulb.tsx@@ -0,0 +1,51 @@+'use client';+import { useEffect, useRef } from 'react';++const colors = [+ 'bg-red-500',+ 'bg-yellow-500',+ 'bg-green-500',+ 'bg-blue-500',+ 'bg-indigo-500',+ 'bg-purple-500',+ 'bg-pink-500',+];++export default function Bulb() {+ const bulb = useRef<HTMLDivElement>(null);+ const randomSpacing = Math.random() * 2;++ useEffect(() => {+ const interval = setInterval(() => {+ bulb.current?.classList.toggle('animate-bulb');+ bulb.current?.classList.toggle('odd:[animation-delay:0.25s]');+ bulb.current?.classList.toggle('odd:[animation-delay:1s]');+ bulb.current?.classList.toggle('animate-bulb-slow');+ }, 4000);++ return () => {+ clearInterval(interval);+ };+ }, []);+ return (+ <div+ ref={bulb}+ className="animate-bulb relative p-8 will-change-auto odd:ml-8 odd:[animation-delay:0.25s] even:mr-8"+ style={{+ transform: `translateX(${randomSpacing}rem) translateY(${-randomSpacing}rem)`,+ }}+ >+ <div+ className={`${+ colors[Math.round(Math.random() * 6)]+ } h-2 w-2 rounded-full blur-sm duration-75 group-hover:scale-150`}+ />+ <div+ className="absolute inset-0 m-auto h-1 w-0.5 rounded-full bg-white/40"+ style={{+ rotate: `${Math.random() * 90 - 45}deg`,+ }}+ />+ </div>+ );+}diff --git a/apps/aot/src/app/events/[year]/Lights/Strip.tsx b/apps/aot/src/app/events/[year]/Lights/Strip.tsxnew file mode 100644index 00000000..91b61f5b--- /dev/null+++ b/apps/aot/src/app/events/[year]/Lights/Strip.tsx@@ -0,0 +1,19 @@+import React from 'react';+import Bulb from './Bulb';++export default function Strip({ delay }: { delay: number }) {+ return (+ <div+ className="animate-slidedown group flex h-full w-full flex-col items-center justify-center px-2 will-change-auto odd:-translate-y-0 even:translate-y-16 even:-scale-x-100"+ style={+ {+ '--delay': `${delay}s`,+ } as React.CSSProperties+ }+ >+ {[...Array(14)].map((_, i) => (+ <Bulb key={i} />+ ))}+ </div>+ );+}diff --git a/apps/aot/src/app/events/[year]/Lights/index.tsx b/apps/aot/src/app/events/[year]/Lights/index.tsxnew file mode 100644index 00000000..283ffe7b--- /dev/null+++ b/apps/aot/src/app/events/[year]/Lights/index.tsx@@ -0,0 +1,11 @@+import Strip from './Strip';++export default function ChristmasLights() {+ return (+ <div className="absolute inset-0 hidden h-full justify-center dark:flex">+ {[...Array(12)].map((_, i) => (+ <Strip key={i} delay={i * 0.125} />+ ))}+ </div>+ );+}diff --git a/apps/aot/src/app/events/[year]/page.tsx b/apps/aot/src/app/events/[year]/page.tsxindex d032dbbf..10346ec9 100644--- a/apps/aot/src/app/events/[year]/page.tsx+++ b/apps/aot/src/app/events/[year]/page.tsx@@ -9,6 +9,7 @@ import { DailyCountdownTimer } from '~/components/DailyCountdownTimer';import BgDecorations from './24BgDecorations';import Partners from '~/components/landing/Partners';import { Footsies } from '~/components/footsies';+import ChristmasLights from './Lights';type Challenge = RouterOutputs['event']['getEventChallengesByYear'][0];interface EventByYearLandingPageProps {@@ -40,15 +41,15 @@ export default async function EventByYearLandingPage({ params }: EventByYearLandreturn (<>- <div className="z-10 -mt-14 flex min-h-screen flex-col items-center justify-between overflow-hidden border-b border-neutral-300 bg-gradient-to-t from-neutral-200 to-neutral-50 py-14 dark:border-neutral-700 dark:from-neutral-800 dark:to-neutral-950">+ <div className="z-10 -mt-14 flex min-h-screen flex-col items-center justify-between overflow-clip border-b border-neutral-300 bg-gradient-to-t from-neutral-200 to-neutral-50 py-14 dark:border-neutral-700 dark:from-neutral-800 dark:to-neutral-950">+ <ChristmasLights />+ {/* bg image */}<divclassName={`pointer-events-none fixed left-0 top-0 h-full w-full bg-[url('https://images.pexels.com/photos/724906/pexels-photo-724906.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2')] bg-cover opacity-10 blur-3xl`}/>- <div className="container relative mx-auto pt-12">+ <div className="container pointer-events-none relative mx-auto pt-12"><BgDecorations />- {/* <h1 className="mb-16 mt-8 text-center text-3xl font-bold lg:text-6xl">- Challenges for {year}- </h1> */}+<ul className="z-10 flex flex-col items-center gap-2 sm:gap-3 md:gap-4">{year === 2024 ? (<div className="flex flex-col items-center pb-10">@@ -63,7 +64,7 @@ export default async function EventByYearLandingPage({ params }: EventByYearLand<Linkkey={`day-active-${day.day}`}href={`/events/${year}/${day.day}`}- className={`${!day.active && 'pointer-events-none'}`}+ className={!day.active ? 'pointer-events-none' : 'pointer-events-auto'}aria-disabled={!day.active}><DaySolved day={day.day} active={day.active} hasSolved={day.hasSolved} />diff --git a/apps/aot/src/app/globals.css b/apps/aot/src/app/globals.cssindex 88ae9fea..afcf2544 100644--- a/apps/aot/src/app/globals.css+++ b/apps/aot/src/app/globals.css@@ -564,3 +564,35 @@ body.mobile-nav-active {.candy-cane-neutral {background: repeating-linear-gradient(45deg, #8884, #8884 10px, #fff0 10px, #fff0 20px);}++.animate-bulb {+ opacity: 0.05;+ /* scale: 0.5; */+ animation: bulb 0.25s ease-in-out infinite alternate;+}++.animate-bulb-slow {+ opacity: 0.1;+ /* scale: 0.5; */+ animation: bulb 1s ease-in-out infinite alternate;+}++@keyframes bulb {+ to {+ /* scale: 1; */+ opacity: 1;+ }+}++.animate-slidedown {+ opacity: 0;+ translate: 0 -1rem;+ animation: slidedown 0.66s var(--delay) cubic-bezier(0.175, 0.885, 0.32, 2.275) forwards;+}++@keyframes slidedown {+ to {+ opacity: 1;+ translate: 0 0;+ }+}