Stack.tsx 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import "./Stack.css";
  2. import React from "react";
  3. type StackProps = {
  4. children: React.ReactNode;
  5. gap?: number;
  6. align?: "start" | "center" | "end" | "baseline";
  7. justifyContent?: "center" | "space-around" | "space-between";
  8. };
  9. function RowStack({ children, gap, align, justifyContent }: StackProps) {
  10. return (
  11. <div
  12. className="Stack Stack_horizontal"
  13. style={
  14. {
  15. "--gap": gap,
  16. alignItems: align,
  17. justifyContent
  18. } as React.CSSProperties
  19. }
  20. >
  21. {children}
  22. </div>
  23. );
  24. }
  25. function ColStack({ children, gap, align, justifyContent }: StackProps) {
  26. return (
  27. <div
  28. className="Stack Stack_vertical"
  29. style={
  30. {
  31. "--gap": gap,
  32. justifyItems: align,
  33. justifyContent
  34. } as React.CSSProperties
  35. }
  36. >
  37. {children}
  38. </div>
  39. );
  40. }
  41. export default {
  42. Row: RowStack,
  43. Col: ColStack
  44. };