Skip to content

Commit e9a63ca

Browse files
committed
div aspect-video for layout shift
1 parent 016a47d commit e9a63ca

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/components/react/ImageRandom.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,17 @@ const ImageRandomReact: FC<Props> = ({ galleryImages, className, ...props }) =>
5858

5959
return (
6060
<>
61-
<img
62-
{...props}
63-
src={imageSrc}
64-
alt={imageAlt}
65-
onClick={handleClick}
66-
className={cn('cursor-pointer', className)}
67-
/>
68-
69-
{!imageSrc && <div className={cn('', className)}>placeholder</div>}
61+
{imageSrc ? (
62+
<img
63+
{...props}
64+
src={imageSrc}
65+
alt={imageAlt}
66+
onClick={handleClick}
67+
className={cn('cursor-pointer', className)}
68+
/>
69+
) : (
70+
<div className={cn('aspect-video', className)} />
71+
)}
7072
</>
7173
);
7274
};

src/constants/image.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export const TW_SCREENS = {
2525
// add quality and loading in future
2626
export const IMAGE_SIZES = {
2727
FIXED: {
28-
BLUR: {
29-
width: 10,
30-
height: 10,
28+
BLUR_16_9: {
29+
width: 16,
30+
height: 9,
3131
},
3232
AVATAR: {
3333
width: 48,

src/libs/gallery/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const imageMetadataToImageProps = async (
2828

2929
const blurImageProps = {
3030
...astroImageProps,
31-
...IMAGE_SIZES.FIXED.BLUR,
31+
...IMAGE_SIZES.FIXED.BLUR_16_9,
3232
};
3333

3434
const xsImageProps = {

0 commit comments

Comments
 (0)