Files
supabase/apps/www/components/ImageGrid.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

145 lines
3.2 KiB
TypeScript

'use client'
import { motion } from 'motion/react'
import Image from 'next/image'
import Link from 'next/link'
import { cn } from 'ui'
interface iImages {
name: string
image: string
alt?: string
link?: string
}
type colSizes = 8 | 6 | 5 | 4 | 3 | 2
type paddingSizes = 6 | 8 | 12
interface iImageGrid {
images: iImages[]
smCols?: colSizes
mdCols?: colSizes
lgCols?: colSizes
padding?: paddingSizes
className?: string
animated?: boolean
removeFilter?: boolean
bg?: boolean
}
const ImageGrid = ({
images,
smCols = 3,
mdCols = 6,
lgCols = 8,
padding = 8,
className,
animated = false,
removeFilter = false,
bg = true,
}: iImageGrid) => {
const smBreakpoint = {
2: 'grid-cols-2',
3: 'grid-cols-3',
4: 'grid-cols-4',
5: 'grid-cols-5',
6: 'grid-cols-6',
8: 'grid-cols-8',
}
const mdBreakpoint = {
2: 'md:grid-cols-2',
3: 'md:grid-cols-3',
4: 'md:grid-cols-4',
5: 'md:grid-cols-5',
6: 'md:grid-cols-6',
8: 'md:grid-cols-8',
}
const lgBreakpoint = {
2: 'lg:grid-cols-2',
3: 'lg:grid-cols-3',
4: 'lg:grid-cols-4',
5: 'lg:grid-cols-5',
6: 'lg:grid-cols-6',
8: 'lg:grid-cols-8',
}
const imgPadding = {
6: 'h-6 ',
8: 'h-8 ',
12: 'h-12 ',
}
return (
<div
className={`grid
gap-0.5 rounded-lg overflow-hidden
items-center
${smBreakpoint[smCols]}
${mdBreakpoint[mdCols]}
${lgBreakpoint[lgCols]}
`}
>
{images.map((x, i) => {
const Container = ({ children, link }: any) => {
if (x.link) {
return (
<Link href={link}>
<div className="scale-100 transform cursor-pointer duration-100 ease-in-out hover:shadow-xs">
{children}
</div>
</Link>
)
} else {
return children
}
}
const MaybeAnimatedDiv = ({ children, ...rest }: any) =>
animated ? (
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0, transition: { delay: i / 10 } }}
{...rest}
>
{children}
</motion.div>
) : (
<div {...rest}>{children}</div>
)
return (
<Container link={x.link} key={i}>
<MaybeAnimatedDiv
key={`${x.name}-${i}`}
className={cn(
bg && 'bg-surface-200',
'w-full',
`col-span-1 flex items-center justify-center
${x.link && 'hover:bg-overlay-hover'}
p-8 ${className}`
)}
>
<div className={`relative h-8 w-full overflow-auto ${imgPadding[padding]}`}>
<Image
src={x.image}
alt={`${x.name} logo`}
fill
sizes="100%"
className={cn(
'object-scale-down object-center bg-no-repeat m-0',
!removeFilter && 'contrast-0 filter opacity-50'
)}
/>
</div>
</MaybeAnimatedDiv>
</Container>
)
})}
</div>
)
}
export default ImageGrid