2020-01-15 20:42:02 +05:00
|
|
|
import "./Stack.css";
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
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-01-15 20:42:02 +05:00
|
|
|
};
|
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
const RowStack = ({
|
2020-04-29 22:49:36 +02:00
|
|
|
children,
|
|
|
|
gap,
|
|
|
|
align,
|
|
|
|
justifyContent,
|
|
|
|
className,
|
2020-05-20 16:21:37 +03:00
|
|
|
}: StackProps) => {
|
2020-01-15 20:42:02 +05:00
|
|
|
return (
|
|
|
|
<div
|
2020-04-29 22:49:36 +02:00
|
|
|
className={`Stack Stack_horizontal ${className || ""}`}
|
2020-01-17 23:53:41 +05:30
|
|
|
style={
|
|
|
|
{
|
|
|
|
"--gap": gap,
|
|
|
|
alignItems: align,
|
2020-01-24 12:04:54 +02:00
|
|
|
justifyContent,
|
2020-01-17 23:53:41 +05:30
|
|
|
} as React.CSSProperties
|
|
|
|
}
|
2020-01-15 20:42:02 +05:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
2020-05-20 16:21:37 +03:00
|
|
|
};
|
2020-01-15 20:42:02 +05:00
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
const ColStack = ({
|
2020-04-29 22:49:36 +02:00
|
|
|
children,
|
|
|
|
gap,
|
|
|
|
align,
|
|
|
|
justifyContent,
|
|
|
|
className,
|
2020-05-20 16:21:37 +03:00
|
|
|
}: StackProps) => {
|
2020-01-15 20:42:02 +05:00
|
|
|
return (
|
|
|
|
<div
|
2020-04-29 22:49:36 +02:00
|
|
|
className={`Stack Stack_vertical ${className || ""}`}
|
2020-01-17 23:53:41 +05:30
|
|
|
style={
|
|
|
|
{
|
|
|
|
"--gap": gap,
|
|
|
|
justifyItems: align,
|
2020-01-24 12:04:54 +02:00
|
|
|
justifyContent,
|
2020-01-17 23:53:41 +05:30
|
|
|
} as React.CSSProperties
|
|
|
|
}
|
2020-01-15 20:42:02 +05:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
2020-05-20 16:21:37 +03:00
|
|
|
};
|
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
|
|
|
};
|