stack.tsx 608 B

1234567891011121314151617181920
  1. "use client";
  2. import type { ComponentRenderProps } from "./types";
  3. import { baseClass, getCustomClass } from "./utils";
  4. export function Stack({ element, children }: ComponentRenderProps) {
  5. const { props } = element;
  6. const customClass = getCustomClass(props);
  7. const isHorizontal = props.direction === "horizontal";
  8. const stackGap =
  9. props.gap === "lg" ? "gap-3" : props.gap === "sm" ? "gap-1" : "gap-2";
  10. return (
  11. <div
  12. className={`flex ${isHorizontal ? "flex-row flex-wrap items-center" : "flex-col"} ${stackGap} ${baseClass} ${customClass}`}
  13. >
  14. {children}
  15. </div>
  16. );
  17. }