import { forwardRef, type ForwardRefRenderFunction, type ReactNode, } from 'react'; import { Figure, Link, type FigureProps } from '../../../atoms'; import { Collapsible, type CollapsibleProps } from '../../../molecules'; import styles from './image-widget.module.scss'; export type ImageWidgetProps = Omit & { /** * Add a caption to the image. */ description?: FigureProps['caption']; /** * The image. */ img: ReactNode; /** * Add a link to the image. */ url?: string; }; const ImageWidgetWithRef: ForwardRefRenderFunction< HTMLDivElement, ImageWidgetProps > = ({ description, img, isCollapsed, url, ...props }, ref) => (
{url ? ( {img} ) : ( img )}
); /** * ImageWidget component * * Renders a widget that print an image and an optional text. */ export const ImageWidget = forwardRef(ImageWidgetWithRef);