card.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use client";
  2. import type { ComponentRenderProps } from "./types";
  3. import { baseClass, getCustomClass } from "./utils";
  4. export function Card({ element, children }: ComponentRenderProps) {
  5. const { props } = element;
  6. const customClass = getCustomClass(props);
  7. const maxWidthClass =
  8. props.maxWidth === "sm"
  9. ? "max-w-xs sm:min-w-[280px]"
  10. : props.maxWidth === "md"
  11. ? "max-w-sm sm:min-w-[320px]"
  12. : props.maxWidth === "lg"
  13. ? "max-w-md sm:min-w-[360px]"
  14. : "w-full";
  15. const centeredClass = props.centered ? "mx-auto" : "";
  16. return (
  17. <div
  18. className={`border border-border rounded-lg p-3 bg-background overflow-hidden ${maxWidthClass} ${centeredClass} ${baseClass} ${customClass}`}
  19. >
  20. {props.title ? (
  21. <div className="font-semibold text-sm mb-1 text-left">
  22. {props.title as string}
  23. </div>
  24. ) : null}
  25. {props.description ? (
  26. <div className="text-[10px] text-muted-foreground mb-2 text-left">
  27. {props.description as string}
  28. </div>
  29. ) : null}
  30. <div className="space-y-2">{children}</div>
  31. </div>
  32. );
  33. }