Skip to content
← Public packages

@kentcdodds/photo-portfolio

A fast, photo-first portfolio site you update by chatting with your agent: galleries, about, contact, and one-step rollback.

FollowFork

Files

gallery-card.tsx

40 lines · 1.2 KB · TypeScript
/** @jsxRuntime automatic */
/** @jsxImportSource remix/component */
import { coverOf } from '../../src/domain/content.ts'
import type { Gallery } from '../../src/domain/types.ts'
import type { Site } from '../data/site.ts'
import { routes } from '../routes.ts'
import { picture } from './picture.tsx'

/** Cover-photo card linking to a gallery. Covers crop to 4:3 so the grid stays even. */
export function galleryCards(
	site: Site,
	galleries: Array<Gallery>,
	options: { priorityCount?: number } = {},
) {
	return (
		<ul class="gallery-cards">
			{galleries.map((gallery, index) => (
				<li>
					<a
						class="gallery-card"
						href={routes.gallery.href({ slug: gallery.slug })}
					>
						{picture(site, coverOf(gallery), {
							sizes: '(max-width: 640px) 100vw, (max-width: 1100px) 50vw, 33vw',
							priority: index < (options.priorityCount ?? 0),
							class: 'card-photo',
						})}
						<span class="card-text">
							<span class="card-title">{gallery.title}</span>
							<span class="card-count">
								{gallery.photos.length}{' '}
								{gallery.photos.length === 1 ? 'photo' : 'photos'}
							</span>
						</span>
					</a>
				</li>
			))}
		</ul>
	)
}