Skip to content

Commit 327360b

Browse files
committed
feat(storefront): Add caption to Image component
1 parent 0124919 commit 327360b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

apps/storefront/components/Image/Image.module.css

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
max-width: 800px;
44
margin: var(--fds-spacing-7) 0;
55
border-radius: var(--fds-border_radius-medium);
6+
flex-wrap: wrap;
7+
gap: var(--fds-spacing-4);
68
}
79

810
.container .img {
@@ -13,3 +15,8 @@
1315
.boxShadow {
1416
box-shadow: var(--fds-shadow-medium);
1517
}
18+
19+
.container .caption {
20+
color: var(--fds-semantic-text-neutral-subtle);
21+
font: var(--fds-typography-paragraph-small);
22+
}

apps/storefront/components/Image/Image.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ interface ImageProps {
77
alt: string;
88
src: string;
99
boxShadow: boolean;
10+
caption: string;
1011
}
1112

12-
const Image = ({ alt, src, boxShadow, ...rest }: ImageProps) => {
13+
const Image = ({ alt, src, boxShadow, caption, ...rest }: ImageProps) => {
1314
return (
14-
<div className={cl(classes.container, { [classes.boxShadow]: boxShadow })}>
15+
<figure
16+
className={cl(classes.container, { [classes.boxShadow]: boxShadow })}
17+
>
1518
<img
1619
className={classes.img}
1720
src={src}
1821
alt={alt}
1922
{...rest}
2023
></img>
21-
</div>
24+
{caption && (
25+
<figcaption className={classes.caption}>{caption}</figcaption>
26+
)}
27+
</figure>
2228
);
2329
};
2430

0 commit comments

Comments
 (0)