veza/apps/web/src/components/ui/optimized-image/generateImageSources.ts
senke db39d87955 refactor(ui): extract OptimizedImage into optimized-image module
- types, generateImageSources, BlurPlaceholder, useImageFormatSupport
- OptimizedImage, OptimizedImageSkeleton, useImagePreloader, ResponsiveImage
- Stories: Default, WithPlaceholder, ErrorState, Loading (skeleton)
- Re-export from optimized-image.tsx; tests adapted to loading state

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-05 22:31:35 +01:00

20 lines
441 B
TypeScript

import { SUPPORTED_FORMATS } from './types';
export interface ImageSource {
src: string;
type: string;
sizes: string;
}
export function generateImageSources(
src: string,
sizes?: string,
): ImageSource[] {
const baseUrl = src.replace(/\.[^/.]+$/, '');
const sizesVal = sizes ?? '100vw';
return SUPPORTED_FORMATS.map((format) => ({
src: `${baseUrl}.${format}`,
type: `image/${format}`,
sizes: sizesVal,
}));
}