Stack.tsx 1.0 KB

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