Connect, collaborate, and grow with a community of TypeScript developers
wip feat(aot): AOT leaderboard christmas decors (#1665)
Devinda Senanayakaf52af2e4fb25
diff --git a/apps/aot/public/leaderboard-stage/Chrismas_Tree_Stylized.glb b/apps/aot/public/leaderboard-stage/Chrismas_Tree_Stylized.glbnew file mode 100644index 00000000..a09954ecBinary files /dev/null and b/apps/aot/public/leaderboard-stage/Chrismas_Tree_Stylized.glb differdiff --git a/apps/aot/public/leaderboard-stage/cane.glb b/apps/aot/public/leaderboard-stage/cane.glbnew file mode 100644index 00000000..f955b849Binary files /dev/null and b/apps/aot/public/leaderboard-stage/cane.glb differdiff --git a/apps/aot/public/leaderboard-stage/gift.glb b/apps/aot/public/leaderboard-stage/gift.glbnew file mode 100644index 00000000..200bf891Binary files /dev/null and b/apps/aot/public/leaderboard-stage/gift.glb differdiff --git a/apps/aot/public/leaderboard-stage/snowman.glb b/apps/aot/public/leaderboard-stage/snowman.glbnew file mode 100644index 00000000..093d79dfBinary files /dev/null and b/apps/aot/public/leaderboard-stage/snowman.glb differdiff --git a/apps/aot/src/app/events/(leaderboard)/_components/leaderboard-page.tsx b/apps/aot/src/app/events/(leaderboard)/_components/leaderboard-page.tsxindex cd12f901..63875a64 100644--- a/apps/aot/src/app/events/(leaderboard)/_components/leaderboard-page.tsx+++ b/apps/aot/src/app/events/(leaderboard)/_components/leaderboard-page.tsx@@ -1,6 +1,7 @@import type { Role } from '@repo/db/types';import { Stage } from './stage';import { LeaderboardTable } from './table';+import styles from './leaderboard-styles.module.css';export function LeaderboardPage(props: {isDayPage: boolean;@@ -19,8 +20,11 @@ export function LeaderboardPage(props: {<Stage data={props.data.slice(0, 3)} isDayStage={props.isDayPage} /></div></div>- <div className="border-[hsla(0, 0%, 100%, 0.12)] mx-auto mt-[255px] max-w-screen-lg rounded-2xl rounded-b-none border border-b-0 bg-[hsla(0,0%,0%,0.07)] px-2 pt-2 shadow-[0px_-18px_131px_-78px_hsla(132,100%,53%,0.3)] backdrop-blur-sm md:mt-[350px] lg:mt-[500px] dark:bg-[hsla(0,0%,100%,0.07)]">- <div className="bg-background relative rounded-lg rounded-b-none">+ <div className="border-[hsla(0, 0%, 100%, 0.12)] relative mx-auto mt-[255px] max-w-screen-lg rounded-2xl rounded-b-none border border-b-0 bg-[hsla(0,0%,0%,0.07)] px-1 pt-1 shadow-[0px_-18px_131px_-78px_hsla(132,100%,53%,0.3)] backdrop-blur-sm md:mt-[350px] lg:mt-[500px] dark:bg-[hsla(0,0%,100%,0.07)]">+ <div className={`${styles['ring-container']} -inset-0`}>+ <div className={`${styles['ring-animation']} inset-1 bg-slate-50/10`} />+ </div>+ <div className="bg-background rounded-lg rounded-b-none"><LeaderboardTable data={props.data} isDayTable={props.isDayPage} /></div></div>diff --git a/apps/aot/src/app/events/(leaderboard)/_components/leaderboard-styles.module.css b/apps/aot/src/app/events/(leaderboard)/_components/leaderboard-styles.module.cssnew file mode 100644index 00000000..39573966--- /dev/null+++ b/apps/aot/src/app/events/(leaderboard)/_components/leaderboard-styles.module.css@@ -0,0 +1,62 @@+.ring-container {+ padding: 1px 1px 0;+ mask:+ linear-gradient(#fff 0 0) content-box,+ linear-gradient(#fff 0 0);+ mask-composite: exclude;+ position: absolute;+ z-index: 4;+ border-radius: inherit;+ height: 100%;+ width: 100%;+ container-type: size;+ overflow: hidden;+}++.ring-animation {+ width: 200px;+ height: 200px;+ position: absolute;+ top: 100cqh;+ background-image: linear-gradient(0deg, rgba(255, 46, 46, 0), #ff4c4c, #ff2323);+ animation: ring-animate 10s linear infinite;+}++@keyframes ring-animate {+ 0% {+ transform: translateZ(0) translate(calc(1cqw - 52%), calc(-90cqh));+ }+ 5% {+ transform: translateZ(0) translate(calc(1cqw - 52%), calc(-99cqh));+ }+ 7% {+ transform: translateZ(0) translate(calc(1cqw - 52%), calc(-100cqh)) rotate(45deg);+ }+ 12% {+ transform: translateZ(0) translate(calc(15cqw), calc(-100cqh - 50%)) rotate(90deg);+ }+ 24% {+ transform: translateZ(0) translate(calc(94cqw - 100%), calc(-100cqh - 50%)) rotate(90deg);+ }+ 25% {+ transform: translateZ(0) translate(calc(98cqw - 100%), calc(-100cqh - 50%)) rotate(135deg);+ }+ 27% {+ transform: translateZ(0) translate(calc(96cqw), calc(-95cqh - 50%)) rotate(180deg);+ }+ 69% {+ transform: translateZ(0) translate(calc(96cqw), calc(1cqh)) rotate(180deg);+ }+ 70% {+ transform: translateZ(0) translate(calc(25cqw - 52%), calc(1cqh)) rotate(180deg);+ }+ 71% {+ transform: translateZ(0) translate(calc(25cqw - 52%), calc(1cqh));+ }+ 72% {+ transform: translateZ(0) translate(calc(1cqw - 52%), calc(1cqh));+ }+ 100% {+ transform: translateZ(0) translate(calc(1cqw - 52%), calc(-90cqh));+ }+}diff --git a/apps/aot/src/app/events/(leaderboard)/_components/stage.tsx b/apps/aot/src/app/events/(leaderboard)/_components/stage.tsxindex 7023fc54..d7a68c75 100644--- a/apps/aot/src/app/events/(leaderboard)/_components/stage.tsx+++ b/apps/aot/src/app/events/(leaderboard)/_components/stage.tsx@@ -1,8 +1,21 @@'use client';-import { Billboard, Edges, Image, PerspectiveCamera, Text } from '@react-three/drei';-import { Canvas, extend, useFrame, type Object3DNode } from '@react-three/fiber';+import { Billboard, Edges, Image, PerspectiveCamera, Text, useGLTF } from '@react-three/drei';+import {+ Canvas,+ extend,+ useFrame,+ type Object3DNode,+ type GroupProps,+ type MeshProps,+} from '@react-three/fiber';import { useRef } from 'react';-import { Color, LinearToneMapping, type PerspectiveCamera as PerspectiveCameraType } from 'three';+import {+ type Mesh,+ Color,+ LinearToneMapping,+ type PerspectiveCamera as PerspectiveCameraType,+ DoubleSide,+} from 'three';import { geometry } from 'maath';import { useScroll, useSpring } from 'framer-motion';import { motion } from 'framer-motion-3d';@@ -31,7 +44,12 @@ export function Stage(props: DataProps) {</Canvas>);}-+const colors = {+ red: new Color(0xff3d3d),+ green: new Color(0x2d9d2d),+ gold: new Color(0xffd700),+ offWhite: new Color(0xeaeaea),+};function Experience(props: DataProps) {const cameraRef = useRef<PerspectiveCameraType>(null);const { scrollY } = useScroll({ smooth: 0.4 });@@ -60,7 +78,7 @@ function Experience(props: DataProps) {}}><Platform- color="red"+ color={colors.red}x={0}height={1.8 + 2.5}heightOffset={2.5}@@ -71,9 +89,31 @@ function Experience(props: DataProps) {}}z={0.001}isDayStage={props.isDayStage}+ decorations={+ <group position-y={1.8 + 2.5 - 0.5}>+ <Gift+ position-z={0.4}+ position-x={-0.42}+ rotation-y={Math.PI * 0.24}+ rotation-z={-Math.PI * 0.05}+ />+ <Gift position-z={0.4} position-x={-0.3} rotation-y={Math.PI * 0.1} />+ <Gift position-z={0.3} position-x={-0.39} rotation-y={Math.PI * 0.1} />+ <CandyCane+ position-z={-0.2}+ position-x={-0.45}+ position-y={-0.1}+ rotation-z={-Math.PI * 0.1}+ rotation-y={-Math.PI * 0.65}+ scale={4}+ />+ <Tree position-z={-0.4} position-x={-0.47} />+ <Tree position-z={0.4} position-x={0.4} />+ </group>+ }/><Platform- color="green"+ color={colors.green}x={-1.001}height={1.5 + 2.5}heightOffset={2.5}@@ -83,9 +123,22 @@ function Experience(props: DataProps) {image: props.data[1]?.image ?? null,}}isDayStage={props.isDayStage}+ decorations={+ <group position-y={1.5 + 2.5 - 0.5}>+ <Gift+ position-z={0.4}+ position-x={0.42}+ rotation-y={Math.PI * 0.24}+ rotation-z={Math.PI * 0.1}+ />+ <Gift position-z={0.4} position-x={0.3} rotation-y={Math.PI * 0.1} />+ <Tree position-z={-0.2} position-x={0.3} />+ <Snowman position-z={0.49} position-x={-0.4} rotation-y={-Math.PI * 0.3} />+ </group>+ }/><Platform- color="green"+ color={colors.green}x={1.001}height={1.35 + 2.5}heightOffset={2.5}@@ -95,6 +148,26 @@ function Experience(props: DataProps) {image: props.data[2]?.image ?? null,}}isDayStage={props.isDayStage}+ decorations={+ <group position-y={1.35 + 2.5 - 0.5}>+ <Gift+ position-z={0.4}+ position-x={0.25}+ rotation-y={Math.PI * 0.15}+ rotation-z={-Math.PI * 0.04}+ />+ <CandyCane+ scale={6}+ position-z={0.46}+ position-x={-0.4}+ position-y={-0.1}+ rotation-z={-Math.PI * 0.1}+ rotation-y={-Math.PI * 0.35}+ />+ <Tree position-z={-0.4} position-x={-0.2} />+ <Tree position-z={0.4} position-x={0.4} />+ </group>+ }/></motion.group></>@@ -108,7 +181,8 @@ function Platform(props: {heightOffset: number;userInfo: { username: string; points: number | string; image: string | null };isDayStage: boolean;- color: string;+ color: Color | string;+ decorations: JSX.Element;}) {const { resolvedTheme } = useTheme();return (@@ -170,13 +244,30 @@ function Platform(props: {scale={1.001}/></mesh>+ <group>+ {props.decorations}++ <SnowCurves position-y={props.height - 0.5} />+ {/* front snow plane */}+ <mesh position-y={props.height - 0.49} position-z={0.51}>+ <planeGeometry args={[1, 0.02]} />+ <meshBasicMaterial+ color={resolvedTheme === 'dark' ? colors.offWhite : new Color(0xeeeded)}+ />+ </mesh>+ {/* top plane snow */}+ <mesh position-y={props.height - 0.49} rotation-x={-Math.PI / 2}>+ <planeGeometry args={[1.01, 1.01]} />+ <meshBasicMaterial color={resolvedTheme === 'dark' ? 'white' : new Color(0xe3e3e3)} />+ </mesh>+ </group><group position-z={0.51}><Text- fontSize={0.1}+ fontSize={0.14}font="/roboto-mono-v23-latin-regular.woff"textAlign="center"anchorY="top"- position-y={props.height - 0.6}+ position-y={props.height - 0.61}maxWidth={0.9}overflowWrap="break-word"color={resolvedTheme === 'dark' ? 'white' : 'black'}@@ -186,7 +277,7 @@ function Platform(props: {{props.isDayStage ? null : (<TextanchorY="top"- position-y={props.height - 0.74}+ position-y={props.height - 0.76}fontSize={0.1}font="/roboto-mono-v23-latin-regular.woff"color={resolvedTheme === 'dark' ? 'white' : 'black'}@@ -224,3 +315,188 @@ function ImageWithFallback(props: { image: string | null; name: string }) {</Image>);}++type TreeGLTFResult = ReturnType<typeof useGLTF> & {+ nodes: {+ Tree: Mesh;+ Balls: Mesh;+ Star: Mesh;+ };+};++function Tree(props: GroupProps) {+ const { nodes } = useGLTF('/leaderboard-stage/Chrismas_Tree_Stylized.glb') as TreeGLTFResult;+ return (+ <group dispose={null} scale={0.2} {...props}>+ <mesh geometry={nodes.Tree.geometry}>+ <meshBasicMaterial color={colors.green} />+ <Edges color="#000000" scale={1.001} linewidth={0.5} />+ </mesh>+ <mesh geometry={nodes.Balls.geometry}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>+ <mesh geometry={nodes.Star.geometry}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>+ </group>+ );+}+function SnowCurves(props: GroupProps) {+ const radiuses = fiveRandomNumbers();+ return (+ <group {...props} position-z={0.51}>+ <HalfCircle position-x={-0.4} radius={radiuses[0] ?? 0.1} />+ <HalfCircle position-x={-0.2} radius={radiuses[1] ?? 0.1} />+ <HalfCircle position-x={0} radius={radiuses[2] ?? 0.1} />+ <HalfCircle position-x={0.2} radius={radiuses[3] ?? 0.1} />+ <HalfCircle position-x={0.4} radius={radiuses[4] ?? 0.1} />+ </group>+ );+}++function HalfCircle(props: MeshProps & { radius: number }) {+ return (+ <mesh {...props}>+ <circleGeometry args={[props.radius, 16, Math.PI, Math.PI]} />+ <meshBasicMaterial color={colors.offWhite} />+ </mesh>+ );+}++function fiveRandomNumbers() {+ const result = [0.1];+ let remainingSum = 0.3;++ for (let i = 0; i < 2; i++) {+ const maxPossible = Math.min(0.13, remainingSum - 0.05 * (2 - i));+ const minPossible = Math.max(0.08, remainingSum - 0.13 * (2 - i));++ const num = Math.random() * (maxPossible - minPossible) + minPossible;+ const rounded = Number(num.toFixed(3));+ result.push(rounded);+ remainingSum -= rounded;+ }++ result.push(Number(remainingSum.toFixed(3)));+ result.push(0.1);+ return result;+}++useGLTF.preload('/leaderboard-stage/Chrismas_Tree_Stylized.glb');++type CandyCaneGLTFResult = ReturnType<typeof useGLTF> & {+ nodes: {+ Vert001: Mesh;+ };+};++function CandyCane({ scale, ...props }: GroupProps & { scale?: number }) {+ const { nodes } = useGLTF('/leaderboard-stage/cane.glb') as CandyCaneGLTFResult;+ return (+ <group {...props} dispose={null}>+ <mesh geometry={nodes.Vert001.geometry} scale={scale ?? 5}>+ <meshBasicMaterial color={colors.red} />+ </mesh>+ </group>+ );+}++useGLTF.preload('/leaderboard-stage/cane.glb');++type GiftGLTFResult = ReturnType<typeof useGLTF> & {+ nodes: {+ Gift: Mesh;+ GiftRibbon: Mesh;+ Sphere001: Mesh;+ BézierCircle: Mesh;+ BézierCircle001: Mesh;+ BézierCircle002: Mesh;+ BézierCircle003: Mesh;+ };+};++export function Gift(props: JSX.IntrinsicElements['group']) {+ const { nodes } = useGLTF('/leaderboard-stage/gift.glb') as GiftGLTFResult;+ return (+ <group {...props} dispose={null} scale={2}>+ <mesh geometry={nodes.Gift.geometry}>+ <meshBasicMaterial color={colors.red} />+ <Edges color="#000000" scale={1.001} linewidth={0.5} />+ </mesh>+ <mesh geometry={nodes.GiftRibbon.geometry}>+ <meshBasicMaterial color={colors.green} />+ </mesh>+ <mesh geometry={nodes.Sphere001.geometry}>+ <meshBasicMaterial color={colors.gold} />+ <mesh geometry={nodes.BézierCircle.geometry} rotation={[Math.PI / 2, 0, 0]}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>+ <mesh geometry={nodes.BézierCircle001.geometry} rotation={[Math.PI / 2, 0, -Math.PI / 2]}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>+ <mesh geometry={nodes.BézierCircle002.geometry} rotation={[Math.PI / 2, 0, Math.PI]}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>+ <mesh geometry={nodes.BézierCircle003.geometry} rotation={[Math.PI / 2, 0, Math.PI / 2]}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>+ </mesh>+ </group>+ );+}++useGLTF.preload('/leaderboard-stage/gift.glb');++type SnowmanGLTFResult = ReturnType<typeof useGLTF> & {+ nodes: {+ scarf: Mesh;+ hat: Mesh;+ eyes: Mesh;+ teeth: Mesh;+ belly: Mesh;+ hand: Mesh;+ face: Mesh;+ nose: Mesh;+ };+};++function Snowman(props: JSX.IntrinsicElements['group']) {+ const { nodes } = useGLTF('/leaderboard-stage/snowman.glb') as SnowmanGLTFResult;+ return (+ <group {...props} dispose={null} scale={0.1}>+ <mesh geometry={nodes.scarf.geometry} rotation={[-0.017, 0, 0.009]}>+ <meshBasicMaterial color={colors.red} />+ </mesh>++ <mesh geometry={nodes.hat.geometry} rotation={[0, 0.681, 0]}>+ <meshBasicMaterial color={colors.green} side={DoubleSide} />+ </mesh>++ <mesh geometry={nodes.eyes.geometry} rotation={[0, 0.681, 0]}>+ <meshBasicMaterial color="black" />+ </mesh>++ <mesh geometry={nodes.teeth.geometry} rotation={[0, 0.681, 0]}>+ <meshBasicMaterial color="black" />+ </mesh>++ <mesh geometry={nodes.belly.geometry} rotation={[0, 0.681, 0]}>+ <meshBasicMaterial color={new Color(0xfbfbfb)} />+ </mesh>++ <mesh geometry={nodes.hand.geometry} rotation={[0, 0.681, 0]}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>++ <mesh geometry={nodes.face.geometry} rotation={[0, 0.681, 0]}>+ <meshBasicMaterial color={new Color(0xfbfbfb)} />+ </mesh>++ <mesh geometry={nodes.nose.geometry} rotation={[0, 0.681, 0]}>+ <meshBasicMaterial color={colors.gold} />+ </mesh>+ </group>+ );+}++useGLTF.preload('/leaderboard-stage/snowman.glb');diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex c42bef3b..38b70739 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1023,7 +1023,7 @@ importers:dependencies:'@next/eslint-plugin-next':specifier: canary- version: 15.0.4-canary.24+ version: 15.0.4-canary.27'@repo/tsconfig':specifier: workspace:*version: link:../config-typescript@@ -1035,7 +1035,7 @@ importers:version: 5.62.0([email protected])([email protected])'@vercel/style-guide':specifier: ^4.0.2eslint:specifier: ^8.45.0version: 8.45.0@@ -2150,8 +2150,8 @@ packages:'@next/[email protected]':resolution: {integrity: sha512-YJqyq6vk39JQfvaNtN83t/p5Jy45+bazRL+V4QI8FPd3FBqFYMEsULiwRLgSJMgFqkk4t4JbeZurz+gILEAFpA==}- '@next/[email protected]':- resolution: {integrity: sha512-qCUveh97G9qUiNAcm27dkWuodY6jcbazeBi0P3mcyFjlwpbdCGdHnLvG/5RDIYRExGhFt0C+OpaDf3mE4AL4fQ==}+ '@next/[email protected]':+ resolution: {integrity: sha512-DO7KOSFVqhE6WlIu6ArKJ6MHlt0OZMW9XPXReULcMO+WSyec54PO5XwwCElYOcLEhyjV+IFJ1X6FvSrRvYw+lA==}'@next/[email protected]':resolution: {integrity: sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==}@@ -8313,7 +8313,7 @@ packages:resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==}engines: {node: '>= 4.0'}- deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at <https://github.com/visionmedia/superagent/releases>.+ deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.netresolution: {integrity: sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA==}@@ -10077,7 +10077,7 @@ snapshots:dependencies:glob: 7.1.7- '@next/[email protected]':+ '@next/[email protected]':dependencies:fast-glob: 3.3.1@@ -12374,7 +12374,7 @@ snapshots:next: 14.2.5(@playwright/[email protected])([email protected]([email protected]))([email protected])react: 18.2.0- '@vercel/[email protected](@next/[email protected])([email protected])([email protected])([email protected])':+ '@vercel/[email protected](@next/[email protected])([email protected])([email protected])([email protected])':dependencies:'@babel/core': 7.22.10'@babel/eslint-parser': 7.22.10(@babel/[email protected])([email protected])@@ -12396,7 +12396,7 @@ snapshots:eslint-plugin-unicorn: 43.0.2([email protected])prettier-plugin-packagejson: 2.4.3([email protected])optionalDependencies:- '@next/eslint-plugin-next': 15.0.4-canary.24+ '@next/eslint-plugin-next': 15.0.4-canary.27eslint: 8.45.0prettier: 3.1.1typescript: 5.3.3