Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

LW7: responsive tickets wall

Francesco Sansalvadore4f7c4fac9bb5
diff --git a/apps/www/components/LaunchWeek/LW7BgGraphic.tsx b/apps/www/components/LaunchWeek/LW7BgGraphic.tsx
index 09ee4d10d22..432c002299d 100644
--- a/apps/www/components/LaunchWeek/LW7BgGraphic.tsx
+++ b/apps/www/components/LaunchWeek/LW7BgGraphic.tsx
@@ -1,20 +1,10 @@
import { motion, useScroll, useTransform } from 'framer-motion'
import Image from 'next/image'
-import { useEffect, useState } from 'react'
-import { useWindowSize } from 'react-use'
+import { useMobileViewport } from '../../hooks/useMobileViewport'
export default function LW7BgGraphic() {
const { scrollYProgress } = useScroll()
- const [isMobile, setIsMobile] = useState(false)
- const { width } = useWindowSize()
-
- useEffect(() => {
- if (width <= 768) {
- setIsMobile(true)
- } else {
- setIsMobile(false)
- }
- }, [width])
+ const isMobile = useMobileViewport(768)
const graphicsScale = useTransform(
scrollYProgress,
diff --git a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
index 226cdc977ba..35925f5938f 100644
--- a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
+++ b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
@@ -1,4 +1,5 @@
import React from 'react'
+import { useMobileViewport } from '../../../hooks/useMobileViewport'
import { UserData } from '../Ticket/hooks/use-conf-data'
import { TicketBrickWallRow } from './TicketBrickWallRow'
@@ -9,6 +10,7 @@ interface Props {
}
export default function TicketBrickWall({ users }: Props) {
+ const isMobile = useMobileViewport(768)
return (
<div className="relative py-36">
<div className="mx-auto bg-[#1C1C1C]">
@@ -23,8 +25,13 @@ export default function TicketBrickWall({ users }: Props) {
after:content-[' '] after:absolute after:inset-0 after:left-auto after:w-1/4 after:bg-gradient-to-l after:from-[#1C1C1C] after:to-[#1C1C1C00] after:z-10 after:pointer-events-none
"
>
- <TicketBrickWallRow users={users.slice(0, 5)} />
- <TicketBrickWallRow users={users.slice(5, 12)} reverse />
+ <TicketBrickWallRow
+ users={users.slice(0, isMobile ? 5 : 7)}
+ xOffset={isMobile ? 50 : 250}
+ />
+ {/* TODO: set the correct amount of users when enough data */}
+ <TicketBrickWallRow users={users.slice(isMobile ? 5 : 3, isMobile ? 11 : 14)} reverse />
+ {isMobile && <TicketBrickWallRow users={users.slice(3, 15)} />}
</div>
</div>
</div>
diff --git a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx
index 5119e14fbf3..7267c85eeb3 100644
--- a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx
+++ b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallRow.tsx
@@ -1,17 +1,19 @@
-import { useRef, useState } from 'react'
+import { useRef } 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'
+import { useMobileViewport } from '../../../hooks/useMobileViewport'
interface Props {
users: UserData[]
reverse?: boolean
- speed?: number
+ xOffset?: number
}
-export function TicketBrickWallRow({ users, reverse, speed = 50000 }: Props) {
+export function TicketBrickWallRow({ users, reverse, xOffset = 250 }: Props) {
const ref = useRef(null)
+ const isMobile = useMobileViewport(768)
const { scrollYProgress } = useScroll({
target: ref,
offset: ['start end', 'end start'],
@@ -22,20 +24,15 @@ export function TicketBrickWallRow({ users, reverse, speed = 50000 }: Props) {
? `${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)
+ const x = useTransform(scrollYProgress, [0, 1], reverse ? [-xOffset, 0] : [0, -xOffset])
return (
- <div ref={ref} className="relative h-[250px] w-full m-0 overflow-hidden py-2.5">
+ <div ref={ref} className="relative h-[125px] md:h-[250px] w-full m-0 overflow-hidden py-2.5">
<div className="absolute flex h-fit w-fit">
- <motion.div className="flex gap-5 will-change-transform" style={{ x }}>
+ <motion.div className="flex gap-2.5 md:gap-5 will-change-transform" style={{ x }}>
{users.map((user, i) => (
- <div
- key={user.username}
- className="relative w-[450px] rounded-2xl overflow-hidden transform scale-100 hover:scale-[102%] transition-transform"
- >
- <Link href={`/launch-week/tickets/${user.username}`}>
+ <Link href={`/launch-week/tickets/${user.username}`} key={user.username}>
+ <a className="relative w-[230px] md:w-[450px] rounded-lg md:rounded-2xl overflow-hidden transform scale-100 md:hover:scale-[101%] transition-transform">
<div className="relative inset-0 w-full pt-[50%] transform scale-[120%]">
<span className="absolute inset-0 flex items-center justify-center text-white">
{user.username}
@@ -45,13 +42,13 @@ export function TicketBrickWallRow({ users, reverse, speed = 50000 }: Props) {
alt={user.username}
layout="fill"
objectFit="cover"
- objectPosition="top 50% right 5px"
+ objectPosition={isMobile ? 'top 50% right 2px' : 'top 50% right 5px'}
placeholder="blur"
blurDataURL="/images/blur.png"
/>
</div>
- </Link>
- </div>
+ </a>
+ </Link>
))}
</motion.div>
</div>
diff --git a/apps/www/hooks/useMobileViewport.tsx b/apps/www/hooks/useMobileViewport.tsx
new file mode 100644
index 00000000000..8252052cc11
--- /dev/null
+++ b/apps/www/hooks/useMobileViewport.tsx
@@ -0,0 +1,17 @@
+import { useEffect, useState } from 'react'
+import { useWindowSize } from 'react-use'
+
+export function useMobileViewport(breakpoint = 768) {
+ const [isMobile, setIsMobile] = useState(false)
+ const { width } = useWindowSize()
+
+ useEffect(() => {
+ if (width <= breakpoint) {
+ setIsMobile(true)
+ } else {
+ setIsMobile(false)
+ }
+ }, [width])
+
+ return isMobile
+}