1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-04-22 05:35:28 -04:00
Files
jarv.is/components/Figure/Figure.tsx
T
2025-02-07 11:33:38 -05:00

23 lines
737 B
TypeScript

import innerText from "react-innertext";
import clsx from "clsx";
import Image from "../Image";
import type { PropsWithChildren, ComponentPropsWithoutRef } from "react";
import styles from "./Figure.module.css";
export type FigureProps = Omit<ComponentPropsWithoutRef<typeof Image>, "alt"> &
PropsWithChildren<{
alt?: string; // becomes optional -- pulled from plaintext-ified caption if missing
}>;
const Figure = ({ children, alt, className, ...imageProps }: FigureProps) => {
return (
<figure className={clsx(styles.figure, className)}>
<Image alt={alt || innerText(children)} {...imageProps} />
<figcaption className={styles.caption}>{children}</figcaption>
</figure>
);
};
export default Figure;