summaryrefslogtreecommitdiffstats
path: root/src/ui/objects/CardImage.tsx
blob: 12b9735ed7968acff8205ecc305d345efdee8c68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type { Props as ImageProps } from "corvos/plugins/images.ts";
import type { CSSProperties } from "https://cdn.jsdelivr.net/gh/oscarotero/ssx@0.1.14/css.ts";

import { Image } from "corvos/plugins/images.ts";

export type Props = ImageProps & {
	"list"?: boolean;
	"img-class"?: unknown;
	"img-style"?: CSSProperties;
	"aspect"?: `${number} / ${number}`;
	"content-class"?: unknown;
	"children"?: JSX.Element;
};

export const CardImage = ({
	children,
	list,
	"img-class": imgClass,
	aspect,
	"content-class": contentClass,
	alt,
	class: cls,
	style,
	"img-style": imgStyle,
	...props
}: Props) => (
	<div class:list={["o-card__image", cls]} style={style}>
		<Image
			class:list={["o-card__image-img", { "l-card-list__card-image": list }, imgClass]}
			style={{
				"aspect-ratio": aspect,
				"block-size": aspect ? "auto" : undefined,
				...imgStyle,
			}}
			alt={alt}
			{...props}
		/>
		{children && <div class:list={["o-card__image-overlay", contentClass]}>{children}</div>}
	</div>
);