Files
Gildas Garcia 71f072ee44 fix: ImageGrid shows scrollbars (#46451)
## Problem

<img width="720" height="796" alt="image"
src="https://github.com/user-attachments/assets/830530e2-d0a0-49cd-a036-85fce7ec9bc3"
/>

## Solution

<img width="706" height="808" alt="image"
src="https://github.com/user-attachments/assets/1170eb0f-89a5-4642-98e9-7e9349312bc0"
/>

## How to test

- Fixed:
https://zone-www-dot-86t6fdcat-supabase.vercel.app/blog/supabase-series-a
- Fixed:
https://zone-www-dot-86t6fdcat-supabase.vercel.app/blog/supabase-enterprise
- Should work as before:
https://zone-www-dot-86t6fdcat-supabase.vercel.app/company
- Should work as before:
https://zone-www-dot-86t6fdcat-supabase.vercel.app/ga

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Style**
* Updated styling classes in the image grid component for improved
consistency and layout alignment.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46451?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-28 12:17:46 +02:00

145 lines
3.2 KiB
TypeScript

'use client'
import { motion } from 'framer-motion'
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