import { asset } from 'fresh/runtime'
import { Picture } from ':components/Picture.tsx'
import {
	getStyleScope,
	useSmartStylesheet,
} from ':plugins/SmartStylesheetIsland.tsx'

const scope = getStyleScope(SponsorCards)

export function SponsorCards() {
	useSmartStylesheet(import.meta, { scope })

	return (
		<div class={scope}>
			{sponsors.map(SponsorCard)}
		</div>
	)
}

function SponsorCard(
	{ href, src, alt }: { href: string; src: string; alt: string },
) {
	return (
		<a class='card' href={href} target='_blank'>
			<Picture
				src={asset(src)}
				alt={alt}
				loading='lazy'
				formats={['avif']}
			/>
		</a>
	)
}

const sponsors = [
	{
		href: 'https://www.iut.u-bordeaux.fr/general/',
		src: '/assets/sponsors/iut_bordeaux.png',
		alt: 'IUT de Bordeaux',
	},
	{
		href: 'https://www.u-bordeaux.fr/',
		src: '/assets/sponsors/universite_bordeaux.png',
		alt: 'Université de Bordeaux',
	},
	{
		href: 'https://www.iut.u-bordeaux.fr/technoshop/',
		src: '/assets/sponsors/technoshop.png',
		alt: 'Technoshop',
	},
	{
		href: 'https://aquitaine.maisons-pour-la-science.org/',
		src: '/assets/sponsors/maison_pour_la_science.png',
		alt: 'Maison pour la science',
	},
	{
		href: 'https://www.math.u-bordeaux.fr/imb/spip.php',
		src: '/assets/sponsors/imb.png',
		alt: 'Institut de Mathématiques de Bordeaux',
	},
	{
		href: 'https://terre-negre.fr/',
		src: '/assets/sponsors/ehpad_terre_negre.png',
		alt: 'EHPAD Terre Nègre',
	},
	{
		href: 'https://capemploi33.org/',
		src: '/assets/sponsors/cap_emploi_33.png',
		alt: 'CAP Emploi 33',
	},
	{
		href: 'https://www.inrae.fr/',
		src: '/assets/sponsors/inrae.png',
		alt: 'INRAE',
	},
	{
		href: 'https://vegetalsignals.com/',
		src: '/assets/sponsors/vegetal-signals.png',
		alt: 'Vegetal Signals',
	},
]
