summaryrefslogtreecommitdiffstats
path: root/src/ui/objects/CardImage.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/objects/CardImage.tsx')
-rw-r--r--src/ui/objects/CardImage.tsx40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/ui/objects/CardImage.tsx b/src/ui/objects/CardImage.tsx
new file mode 100644
index 0000000..12b9735
--- /dev/null
+++ b/src/ui/objects/CardImage.tsx
@@ -0,0 +1,40 @@
1import type { Props as ImageProps } from "corvos/plugins/images.ts";
2import type { CSSProperties } from "https://cdn.jsdelivr.net/gh/oscarotero/ssx@0.1.14/css.ts";
3
4import { Image } from "corvos/plugins/images.ts";
5
6export type Props = ImageProps & {
7 "list"?: boolean;
8 "img-class"?: unknown;
9 "img-style"?: CSSProperties;
10 "aspect"?: `${number} / ${number}`;
11 "content-class"?: unknown;
12 "children"?: JSX.Element;
13};
14
15export const CardImage = ({
16 children,
17 list,
18 "img-class": imgClass,
19 aspect,
20 "content-class": contentClass,
21 alt,
22 class: cls,
23 style,
24 "img-style": imgStyle,
25 ...props
26}: Props) => (
27 <div class:list={["o-card__image", cls]} style={style}>
28 <Image
29 class:list={["o-card__image-img", { "l-card-list__card-image": list }, imgClass]}
30 style={{
31 "aspect-ratio": aspect,
32 "block-size": aspect ? "auto" : undefined,
33 ...imgStyle,
34 }}
35 alt={alt}
36 {...props}
37 />
38 {children && <div class:list={["o-card__image-overlay", contentClass]}>{children}</div>}
39 </div>
40);