Files
supabase/apps/www/components/LaunchWeek/15/LW15Meetups.tsx
Brian-AnandDanny White f1082e28c7 chore: migrate Framer Motion imports to Motion (#51520)
## Problem

Closes #31221.
The applications and shared UI packages still import the former
`framer-motion` package instead of Motion's React entry point.

## Solution

Replace runtime imports, type imports, and three test mocks with
`motion/react` across the consuming workspaces.
Replace the seven direct dependency declarations with `motion:
^11.18.2`.
Preserve the existing animation engine version and all other dependency
resolutions, including the asynchronous `domMax` feature loader.
Historical blog examples remain as published; `framer-motion` remains a
transitive implementation dependency of Motion.

## Review instructions

1. Run `pnpm install --frozen-lockfile` and check the seven dependency
replacements in the lockfile.
2. Open the WWW Auth page and Docs homepage at desktop and mobile
widths, with normal and reduced motion preferences.
3. Open the mobile navigation, expand Product on WWW, and close the menu
using Escape and the close button.
4. Check the existing animation components, shared form validation, and
Studio tests for unchanged behavior.

Validation:

- Studio: 731 test files, 8,334 passing tests and one expected failure,
with `--maxWorkers=4`.
- Shared UI, UI patterns, WWW, and UI library: 615 passing tests.
- `pnpm run typecheck --concurrency=1`: all 16 repository tasks pass.
- All six application source lint scripts and lint ratchets pass;
generated Docs example copies are excluded from local lint.
- Repository Prettier source check, lockfile formatting, and case hazard
check pass.
- WWW: 10 existing end-to-end checks across nine pages.
- Docs: 5 existing guide link and accessibility checks across Database
and Auth.
- WWW and Docs mobile navigation pass at desktop/mobile sizes with
normal/reduced motion; SQL-to-REST translation tabs exercise the
asynchronous feature loader without browser errors.
- Frozen-lockfile installation passes; all existing package and snapshot
resolutions are unchanged.
- Learn and UI library command palettes open, filter results, and close
with Escape without browser errors.
- Independent code review finds no actionable defects.
- `npm run build -- --filter=www --filter=docs --filter=studio
--filter=learn --filter=library --concurrency=1 --continue=always`: all
five affected applications build successfully (9 tasks including
prerequisites); asset uploads disabled for local validation.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
(no docs topics changed)

---------

Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-10-14 07:16:00 +00:00

294 lines
9.7 KiB
TypeScript

import { LumaEvent } from 'app/api-v2/luma-events/route'
import SectionContainer from 'components/Layouts/SectionContainer'
import { DEFAULT_EASE } from 'lib/animations'
import { motion, useInView } from 'motion/react'
import Image from 'next/image'
import Link from 'next/link'
import React, { PropsWithChildren, useCallback, useEffect, useRef, useState } from 'react'
import { cn } from 'ui'
import { FifteenSVG, LWSVG } from './lw15.components'
interface Props {
className?: string
meetups?: LumaEvent[]
}
interface MeetupOverlayCardProps {
meetup: LumaEvent | null
mousePosition: { x: number; y: number }
visible: boolean
}
const MotionLink = motion(Link)
const LW15Meetups = ({ className, meetups = [] }: PropsWithChildren<Props>) => {
const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 })
const [globalMousePosition, setGlobalMousePosition] = useState({ x: 0, y: 0 })
const imageRef = useRef<HTMLDivElement>(null)
const now = new Date(Date.now())
const [activeMeetup, setActiveMeetup] = useState<LumaEvent | null>(null)
const [showOverlay, setShowOverlay] = useState(false)
const ref = React.useRef(null)
const isInView = useInView(ref, { margin: '-25%', once: true })
const variants = {
reveal: {
transition: {
type: 'spring',
damping: 10,
mass: 0.75,
stiffness: 100,
staggerChildren: 0.018,
},
},
}
const meetupVariants = {
initial: {
y: '100%',
opacity: 0,
},
reveal: {
y: 0,
opacity: 1,
transition: {
ease: DEFAULT_EASE,
duration: 0.5,
},
},
}
const handleMouseMove = useCallback((e: MouseEvent) => {
// Global mouse position for overlay
setGlobalMousePosition({
x: e.clientX,
y: e.clientY,
})
// Relative mouse position for image effects
if (!imageRef.current) return
const rect = imageRef.current.getBoundingClientRect()
const x = e.clientX - rect.left
const y = e.clientY - rect.top
setMousePosition({ x, y })
}, [])
useEffect(() => {
window.addEventListener('mousemove', handleMouseMove)
return () => {
window.removeEventListener('mousemove', handleMouseMove)
}
}, [handleMouseMove])
function handleSelectMeetup(meetup: LumaEvent) {
setActiveMeetup(meetup)
setShowOverlay(true)
}
function handleMouseLeave() {
setActiveMeetup(null)
setShowOverlay(false)
}
const meetupsSortedByCity = meetups.sort((a, b) =>
getMeetupCity(a).localeCompare(getMeetupCity(b))
)
return (
<>
<MeetupOverlayCard
meetup={activeMeetup}
mousePosition={globalMousePosition}
visible={showOverlay}
/>
<SectionContainer
className={cn(
'relative max-w-none! pb-0! lg:container! flex flex-col overflow-hidden',
className
)}
id="meetups"
>
<div className="w-full leading-none">
<h3 className="text-2xl lg:text-3xl">LW15 Worldwide Meetups</h3>
<p className="text-left text-sm text-foreground-light mt-2">
Join us for community-driven meetups around the world to celebrate Launch Week 15.
</p>
</div>
<motion.div
ref={ref}
variants={variants}
animate={isInView ? 'reveal' : 'initial'}
onMouseLeave={handleMouseLeave}
className={cn(
'relative w-full z-10 text-3xl lg:text-4xl xl:text-5xl mt-24 flex flex-wrap gap-x-2 md:gap-x-3 gap-y-1',
activeMeetup && 'text-foreground-muted'
)}
>
{meetupsSortedByCity &&
meetupsSortedByCity?.map((meetup: LumaEvent, i: number) => {
const startAt = new Date(meetup.start_at)
const endAt = addHours(new Date(meetup.start_at), 3)
const after = now > startAt
const before3H = now < endAt
const liveNow = after && before3H
return (
<>
<MotionLink
variants={meetupVariants}
key={`meetup-link-${meetup.id}`}
href={meetup.url ?? ''}
target="_blank"
onClick={() => handleSelectMeetup(meetup)}
onMouseEnter={() => handleSelectMeetup(meetup)}
title={liveNow ? 'Live now' : undefined}
className={cn(
'h-10 group inline-flex items-center flex-wrap',
'leading-none! transition-colors',
meetup.id === activeMeetup?.id && 'text-foreground'
// liveNow && 'text-foreground-light'
)}
>
{liveNow && (
<div className="w-2 h-2 rounded-full bg-brand-default mr-2 mb-4 animate-pulse" />
)}
<span>{getMeetupCity(meetup)}</span>
</MotionLink>
{i !== meetups.length - 1 && (
<motion.span
variants={meetupVariants}
className="ml-0 mb-0 my-auto flex transition-colors"
>
/
</motion.span>
)}
</>
)
})}
</motion.div>
<div
ref={imageRef}
className="mx-auto h-[400px] -mt-32 -mb-20 lg:mt-0 lg:mb-0 aspect-square lg:aspect-2/1 overflow-hidden relative"
>
<Image
src="/images/launchweek/15/lw15-globe-dark.png"
alt="Meetups Globe"
width={1000}
height={1000}
quality={100}
className="absolute inset-0 bottom-auto w-full aspect-square hidden dark:block opacity-30"
/>
<Image
src="/images/launchweek/15/lw15-globe-dark.png"
alt="Meetups Globe"
width={1000}
height={1000}
quality={100}
className="absolute inset-0 bottom-auto w-full aspect-square hidden dark:block opacity-60"
style={{
maskImage: `radial-gradient(600px circle at ${mousePosition.x}px ${mousePosition.y}px, white 0%, transparent 100%)`,
WebkitMaskImage: `radial-gradient(600px circle at ${mousePosition.x}px ${mousePosition.y}px, white 0%, transparent 100%)`,
}}
/>
<Image
src="/images/launchweek/15/lw15-globe-light.png"
alt="Meetups Globe"
width={1000}
height={1000}
quality={100}
className="absolute inset-0 bottom-auto w-full aspect-square opacity-30 dark:hidden"
/>
<Image
src="/images/launchweek/15/lw15-globe-light.png"
alt="Meetups Globe"
width={1000}
height={1000}
quality={100}
className="absolute inset-0 bottom-auto w-full aspect-square dark:hidden opacity-60"
style={{
maskImage: `radial-gradient(600px circle at ${mousePosition.x}px ${mousePosition.y}px, white 0%, transparent 100%)`,
WebkitMaskImage: `radial-gradient(600px circle at ${mousePosition.x}px ${mousePosition.y}px, white 0%, transparent 100%)`,
}}
/>
</div>
</SectionContainer>
</>
)
}
const handleCountry = (country: string) => {
if (country === 'United States') return 'USA'
if (country === 'United Kingdom') return 'UK'
if (country === 'United Arab Emirates') return 'UAE'
if (country === 'Democratic Republic of the Congo') return 'Congo'
return country
}
const MeetupOverlayCard = ({ meetup, mousePosition, visible }: MeetupOverlayCardProps) => {
const show = !(!meetup || !visible)
// Calculate if overlay should appear to the left of cursor
const overlayWidth = 320
const distanceToRightEdge =
typeof window !== 'undefined' ? window.innerWidth - mousePosition.x : 1000
const shouldPositionLeft = distanceToRightEdge < overlayWidth
return (
<div
className={cn(
'fixed z-50 pointer-events-none opacity-0 transition-opacity',
show && 'opacity-100'
)}
style={{
left: shouldPositionLeft ? mousePosition.x - overlayWidth - 15 : mousePosition.x + 15,
top: mousePosition.y + 15,
}}
>
<div className="bg-black dark:bg-foreground text-white dark:text-background p-2 rounded-xs shadow-lg border w-screen max-w-xs flex flex-col gap-2">
<div className="w-full flex justify-between items-start gap-1 h-8">
<LWSVG className="h-full w-auto" />
<div className="relative h-full flex-1 overflow-hidden">
<Image
src="/images/launchweek/15/lw15-galaxy.png"
alt="Meetups Galaxy"
width={1000}
height={1000}
className="h-full w-full object-cover object-[0%_30%]"
/>
</div>
<FifteenSVG className="h-full w-auto mr-0.5" />
</div>
<div className="w-full flex justify-between gap-1 text-lg leading-none!">
<div className="">Meetup</div>
<div className="text-right">
{getMeetupCity(meetup!)}, {getMeetupCountry(meetup!)}
</div>
</div>
</div>
</div>
)
}
function addHours(start_at: Date, hours: number) {
const dateCopy = new Date(start_at)
dateCopy.setHours(dateCopy.getHours() + hours)
return dateCopy
}
const getMeetupCity = (meetup: LumaEvent) => {
if (!meetup) return ''
return (
meetup.city ??
meetup.name.split(',')[0].split('-')[1].trim() ??
meetup.name.split(',')[0].split(' ')[1].trim() ??
meetup.name
)
}
const getMeetupCountry = (meetup: LumaEvent) => handleCountry(meetup?.country ?? '')
export default LW15Meetups