image.tsx 766 B

1234567891011121314151617181920212223242526
  1. "use client";
  2. import type { ComponentRenderProps } from "./types";
  3. import { baseClass, getCustomClass } from "./utils";
  4. export function Image({ element }: ComponentRenderProps) {
  5. const { props } = element;
  6. const customClass = getCustomClass(props);
  7. const hasCustomSize =
  8. customClass.includes("w-") || customClass.includes("h-");
  9. const imgStyle = hasCustomSize
  10. ? {}
  11. : {
  12. width: (props.width as number) || 80,
  13. height: (props.height as number) || 60,
  14. };
  15. return (
  16. <div
  17. className={`bg-card border border-border rounded flex items-center justify-center text-[10px] text-muted-foreground aspect-video ${baseClass} ${customClass}`}
  18. style={imgStyle}
  19. >
  20. {(props.alt as string) || "img"}
  21. </div>
  22. );
  23. }