feat: add Picture component using Astro Picture

This commit is contained in:
Stefan Imhoff
2023-05-16 21:55:18 +02:00
parent 06af41b864
commit 391b52a698
2 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
---
import cx from 'classnames';
import { Picture } from '@astrojs/image/components';
interface Props {
alt?: string;
aspectRatio?: number | `${number}:${number}`;
class?: string;
noMargin?: boolean;
sizes?: string;
src: string;
widths: number[];
}
const { alt, aspectRatio, class: className, noMargin, sizes, src, widths, ...props } = Astro.props;
const classes = cx('image-shadow mbe-10 mbs-0', { 'mbe-0': noMargin }, className);
---
<div class={classes}>
<Picture
alt={alt || ''}
aspectRatio={aspectRatio}
class="block h-auto w-full rounded-1 border-1 border-solid border-black/[0.1] bg-black/[0.1] shadow shadow-black/10 dark:border-white/[0.1] dark:opacity-[0.87] dark:shadow-white/10"
sizes={sizes}
src={src}
widths={widths}
{...props}
/>
</div>

View File

@@ -4,6 +4,7 @@ import EmailLink from './EmailLink.astro';
import Image from './Image.astro'; import Image from './Image.astro';
import MoreLink from './MoreLink.astro'; import MoreLink from './MoreLink.astro';
import Pagination from './Pagination.astro'; import Pagination from './Pagination.astro';
import Picture from './Picture.astro';
import ProjectContainer from './ProjectContainer.astro'; import ProjectContainer from './ProjectContainer.astro';
import ProjectContent from './ProjectContent.astro'; import ProjectContent from './ProjectContent.astro';
import ProjectImage from './ProjectImage.astro'; import ProjectImage from './ProjectImage.astro';
@@ -38,6 +39,7 @@ export {
Image, Image,
MoreLink, MoreLink,
Pagination, Pagination,
Picture,
ProjectContainer, ProjectContainer,
ProjectContent, ProjectContent,
ProjectImage, ProjectImage,