Skip to content

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

lw7: autoplay tickets slider

Francesco Sansalvadorec45379b9f338
diff --git a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
index 74d1293d9b5..7404c69608a 100644
--- a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
+++ b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
@@ -4,6 +4,7 @@ import { Button } from 'ui'
import { useMobileViewport } from '../../../hooks/useMobileViewport'
import { UserData } from '../Ticket/hooks/use-conf-data'
import { TicketBrickWallRow } from './TicketBrickWallRow'
+import { TicketBrickWallSlider } from './TicketBrickWallSlider'
type user = UserData
@@ -27,12 +28,15 @@ 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
+ <TicketBrickWallSlider
users={users.slice(0, isMobile ? 5 : 7)}
xOffset={isMobile ? 50 : 250}
/>
- <TicketBrickWallRow users={users.slice(isMobile ? 5 : 7, isMobile ? 11 : 14)} reverse />
- {isMobile && <TicketBrickWallRow users={users.slice(11, 17)} />}
+ <TicketBrickWallSlider
+ users={users.slice(isMobile ? 5 : 7, isMobile ? 11 : 14)}
+ reverse
+ />
+ {isMobile && <TicketBrickWallSlider users={users.slice(11, 17)} speed={16000} />}
</div>
<div className="w-full mt-2 lg:mt-4 mx-auto flex justify-center">
<Link href="/launch-week/tickets">
diff --git a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallSlider.tsx b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallSlider.tsx
new file mode 100644
index 00000000000..37b4056c296
--- /dev/null
+++ b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWallSlider.tsx
@@ -0,0 +1,86 @@
+import { useEffect, useRef, useState } from 'react'
+import Image from 'next/image'
+import Link from 'next/link'
+import { UserData } from '../Ticket/hooks/use-conf-data'
+import { useWindowSize } from 'react-use'
+
+import { Swiper, SwiperSlide } from 'swiper/react'
+import SwiperCore, { Autoplay } from 'swiper'
+import 'swiper/swiper.min.css'
+
+SwiperCore.use([Autoplay])
+
+interface Props {
+ users: UserData[]
+ reverse?: boolean
+ xOffset?: number
+ speed?: number
+}
+
+export function TicketBrickWallSlider({ users, reverse, xOffset = 250, speed = 10000 }: Props) {
+ const ref = useRef(null)
+ const [swiperInstace, setSwiperInstance] = useState<SwiperCore | null>(null)
+ const { width } = useWindowSize()
+ const STORAGE_URL = 'https://obuldanrptloktxcffvn.supabase.co/storage/v1/object/public/images/lw7'
+ const getOgUrl = (username: string) => `${STORAGE_URL}/tickets/gallery/${username}.png`
+
+ useEffect(() => {
+ if (swiperInstace) swiperInstace?.autoplay.run()
+ }, [width])
+
+ return (
+ <div ref={ref} className="relative h-auto w-full m-0 overflow-hidden mb-2.5">
+ <div className="flex ticket-brick-swiper">
+ <Swiper
+ onSwiper={(swiper) => setSwiperInstance(swiper)}
+ centeredSlides={true}
+ spaceBetween={10}
+ slidesPerView={5}
+ speed={speed}
+ loop={true}
+ watchOverflow
+ threshold={2}
+ updateOnWindowResize
+ allowTouchMove={false}
+ autoplay={{
+ delay: 0,
+ disableOnInteraction: true,
+ reverseDirection: reverse,
+ }}
+ breakpoints={{
+ 320: {
+ slidesPerView: 2.5,
+ },
+ 720: {
+ slidesPerView: 3.5,
+ },
+ 1440: {
+ slidesPerView: 5,
+ },
+ }}
+ >
+ {users.map((user, i) => (
+ <SwiperSlide key={user.username}>
+ <Link href={`/launch-week/tickets/${user.username}`} key={user.username}>
+ <a className="relative !w-[230px] md:w-[450px] !h-[200px] transform scale-100 md:hover:scale-[101%] transition-transform">
+ <div className="relative inset-0 w-full pt-[50%] transform rounded-md md:rounded-lg overflow-hidden">
+ <Image
+ src={getOgUrl(user.username!)}
+ alt={user.username}
+ layout="fill"
+ objectFit="cover"
+ quality={50}
+ objectPosition="center"
+ placeholder="blur"
+ blurDataURL="/images/blur.png"
+ />
+ </div>
+ </a>
+ </Link>
+ </SwiperSlide>
+ ))}
+ </Swiper>
+ </div>
+ </div>
+ )
+}
diff --git a/apps/www/components/LaunchWeek/LaunchSection/ticket-brick-wall-slider.module.css b/apps/www/components/LaunchWeek/LaunchSection/ticket-brick-wall-slider.module.css
new file mode 100644
index 00000000000..164e683b3a2
--- /dev/null
+++ b/apps/www/components/LaunchWeek/LaunchSection/ticket-brick-wall-slider.module.css
@@ -0,0 +1,3 @@
+.swiper-wrapper .swiper-slide {
+ width: 300px !important;
+}
diff --git a/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx b/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx
index 66f504702a5..b3490b5f443 100644
--- a/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx
+++ b/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx
@@ -29,7 +29,7 @@ export default function TicketsGrid({ loadedUsers, isLoading, pageCount }: Props
return (
<Link href={`/launch-week/tickets/${user.username}`} key={`${user.username}-000${i}`}>
<motion.a
- className="relative w-full rounded-lg overflow-hidden transform scale-100 md:hover:scale-[101%]"
+ className="relative w-full rounded-lg overflow-hidden hover:cursor-pointer"
initial={{ opacity: 0, y: 20, x: isOddRow ? 30 : -30 }}
animate={{
opacity: !isTablet && (i === 0 || i === 4) ? 0 : 1,
@@ -42,7 +42,7 @@ export default function TicketsGrid({ loadedUsers, isLoading, pageCount }: Props
},
}}
>
- <div className="relative inset-0 w-full pt-[50%] transform">
+ <div className="relative inset-0 w-full pt-[50%]">
<Image
src={getOgUrl(user.username!)}
alt={user.username}
diff --git a/apps/www/styles/index.css b/apps/www/styles/index.css
index 65011a93394..708ecef423d 100644
--- a/apps/www/styles/index.css
+++ b/apps/www/styles/index.css
@@ -717,3 +717,18 @@ launch week
background: radial-gradient(45% 100% at 50% 50%, #fff 30%, hsla(0, 0%, 100%, 0.6) 100%);
}
}
+
+/* LW7 Tickets Slider */
+.ticket-brick-swiper .swiper-slide {
+ width: 230px;
+}
+
+@media (min-width: 768px) {
+ .ticket-brick-swiper .swiper-slide {
+ width: 450px;
+ }
+}
+
+.ticket-brick-swiper .swiper-wrapper {
+ transition-timing-function: linear;
+}