From bc646bb3f68520078fd4456881c3fc6dfa268102 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Wed, 8 Mar 2023 19:04:22 +0100 Subject: [PATCH] LW7: tickets brick wall on scroll --- .../LaunchSection/TicketBrickWall.tsx | 40 ++++--------- .../LaunchSection/TicketBrickWallRow.tsx | 57 +++++++++++++++++++ apps/www/pages/launch-week/index.tsx | 2 +- .../pages/launch-week/tickets/[username].tsx | 2 +- 4 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx diff --git a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx index 841653778f0..226cdc977ba 100644 --- a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx +++ b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx @@ -1,8 +1,6 @@ import React from 'react' import { UserData } from '../Ticket/hooks/use-conf-data' - -import { TicketBrick } from './TicketBrick' -import styles from './brick-wall.module.css' +import { TicketBrickWallRow } from './TicketBrickWallRow' type user = UserData @@ -13,36 +11,20 @@ interface Props { export default function TicketBrickWall({ users }: Props) { return (
-
-
- -
-
+
+

Explore the unique tickets generated by our community

-
-
- {users.slice(0, 4).map((user) => ( - - ))} -
-
- {users.slice(4, 8).map((user) => ( - - ))} -
+
+ +
diff --git a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx new file mode 100644 index 00000000000..f7a11087cfe --- /dev/null +++ b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx @@ -0,0 +1,57 @@ +import { useRef, useState } from 'react' +import Image from 'next/image' +import Link from 'next/link' +import { motion, useScroll, useTransform } from 'framer-motion' +import { UserData } from '../Ticket/hooks/use-conf-data' + +interface Props { + users: UserData[] + reverse?: boolean + speed?: number +} + +export function TicketBrickWallRow({ users, reverse, speed = 50000 }: Props) { + const ref = useRef(null) + const { scrollYProgress } = useScroll({ + target: ref, + offset: ['start end', 'end start'], + }) + const STORAGE_URL = 'https://obuldanrptloktxcffvn.supabase.co/storage/v1/object/public/images/lw7' + const getOgUrl = (username: string, isGold: boolean) => + isGold + ? `${STORAGE_URL}/tickets/golden/${username}.png` + : `${STORAGE_URL}/tickets/${username}.png` + + const x = useTransform(scrollYProgress, [0, 1], reverse ? [-300, 0] : [0, -300]) + + console.log(users) + + return ( +
+
+ + {users.map((user, i) => ( + + +
+ + {user.username} + + {user.username} +
+
+ + ))} +
+
+
+ ) +} diff --git a/apps/www/pages/launch-week/index.tsx b/apps/www/pages/launch-week/index.tsx index f11c629da5e..a48614ffb3f 100644 --- a/apps/www/pages/launch-week/index.tsx +++ b/apps/www/pages/launch-week/index.tsx @@ -135,7 +135,7 @@ export default function TicketHome({ users }: Props) { export const getStaticProps: GetStaticProps = async () => { // fetch users for the TicketBrickWall - const { data: users } = await supabaseAdmin!.from('lw7_tickets').select().limit(8) + const { data: users } = await supabaseAdmin!.from('lw7_tickets_golden').select('*').limit(12) return { props: { diff --git a/apps/www/pages/launch-week/tickets/[username].tsx b/apps/www/pages/launch-week/tickets/[username].tsx index d7e23fe02d7..363e79befdf 100644 --- a/apps/www/pages/launch-week/tickets/[username].tsx +++ b/apps/www/pages/launch-week/tickets/[username].tsx @@ -113,7 +113,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { let bg_image_id // fetch users for the TicketBrickWall - const { data: users } = await supabaseAdmin!.from('lw7_tickets').select().limit(8) + const { data: users } = await supabaseAdmin!.from('lw7_tickets_golden').select().limit(12) // fetch a specific user if (username) {