2020-09-26 02:48:45 +05:30
|
|
|
import "./Stack.scss";
|
2020-01-15 20:42:02 +05:00
|
|
|
|
2023-05-31 10:22:02 +02:00
|
|
|
import React, { forwardRef } from "react";
|
2020-10-19 17:14:28 +03:00
|
|
|
import clsx from "clsx";
|
2020-01-15 20:42:02 +05:00
|
|
|
|
|
|
|
type StackProps = {
|
|
|
|
children: React.ReactNode;
|
|
|
|
gap?: number;
|
2020-01-17 15:43:24 +01:00
|
|
|
align?: "start" | "center" | "end" | "baseline";
|
2020-01-17 23:53:41 +05:30
|
|
|
justifyContent?: "center" | "space-around" | "space-between";
|
2020-04-29 22:49:36 +02:00
|
|
|
className?: string | boolean;
|
2020-11-04 12:05:12 +02:00
|
|
|
style?: React.CSSProperties;
|
2023-05-31 10:22:02 +02:00
|
|
|
ref: React.RefObject<HTMLDivElement>;
|
2020-01-15 20:42:02 +05:00
|
|
|
};
|
|
|
|
|
2023-05-31 10:22:02 +02:00
|
|
|
const RowStack = forwardRef(
|
|
|
|
(
|
|
|
|
{ children, gap, align, justifyContent, className, style }: StackProps,
|
|
|
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
|
|
) => {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={clsx("Stack Stack_horizontal", className)}
|
|
|
|
style={{
|
|
|
|
"--gap": gap,
|
|
|
|
alignItems: align,
|
|
|
|
justifyContent,
|
|
|
|
...style,
|
|
|
|
}}
|
|
|
|
ref={ref}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2020-01-15 20:42:02 +05:00
|
|
|
|
2023-05-31 10:22:02 +02:00
|
|
|
const ColStack = forwardRef(
|
|
|
|
(
|
|
|
|
{ children, gap, align, justifyContent, className, style }: StackProps,
|
|
|
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
|
|
) => {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={clsx("Stack Stack_vertical", className)}
|
|
|
|
style={{
|
|
|
|
"--gap": gap,
|
|
|
|
justifyItems: align,
|
|
|
|
justifyContent,
|
|
|
|
...style,
|
|
|
|
}}
|
|
|
|
ref={ref}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2020-01-15 20:42:02 +05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
Row: RowStack,
|
2020-01-24 12:04:54 +02:00
|
|
|
Col: ColStack,
|
2020-01-15 20:42:02 +05:00
|
|
|
};
|