forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBox.tsx
More file actions
58 lines (55 loc) · 1.34 KB
/
Copy pathBox.tsx
File metadata and controls
58 lines (55 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from "react";
// Define gap values (you may need to adjust these based on your design system)
const gapValues = {
xs: "0.25rem", // 4px
sm: "0.5rem", // 8px
md: "1rem", // 16px
lg: "1.5rem", // 24px
xl: "2rem", // 32px
xxl: "3rem", // 48px
};
export const Box = ({
gap,
children,
customValue,
addlClassName,
direction = "column",
justify = "baseline",
align = "stretch",
wrap,
style,
...props
}: (
| { gap: "xs" | "sm" | "md" | "lg" | "xl" | "xxl"; customValue?: undefined }
| { gap: "custom"; customValue: string }
) & {
children: React.ReactElement | React.ReactElement[] | React.ReactNode;
addlClassName?: string;
direction?: "column" | "row" | "column-reverse" | "row-reverse";
justify?:
| "center"
| "space-between"
| "space-around"
| "end"
| "left"
| "right"
| "baseline";
align?: "center" | "end" | "start" | "baseline" | "stretch";
wrap?: "nowrap" | "wrap";
style?: React.CSSProperties;
}) => {
const boxStyle: React.CSSProperties = {
display: "flex",
flexDirection: direction,
justifyContent: justify,
alignItems: align,
gap: gap === "custom" ? customValue : gapValues[gap],
...(wrap ? { flexWrap: wrap } : {}),
...style,
};
return (
<div className={addlClassName} style={boxStyle} {...props}>
{children}
</div>
);
};