-
Notifications
You must be signed in to change notification settings - Fork 15
/
spacer.tsx
101 lines (97 loc) · 2.32 KB
/
spacer.tsx
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import type {
HydrogenComponentProps,
HydrogenComponentSchema,
} from "@weaverse/hydrogen";
import { forwardRef } from "react";
type SpacerProps = HydrogenComponentProps & {
mobileHeight: number;
desktopHeight: number;
backgroundColor: string;
addSeparator: boolean;
separatorColor: string;
};
let Spacer = forwardRef<HTMLDivElement, SpacerProps>((props, ref) => {
let {
mobileHeight,
desktopHeight,
backgroundColor,
addSeparator,
separatorColor,
...rest
} = props;
return (
<div
ref={ref}
{...rest}
className="w-full flex items-center justify-center h-[var(--mobile-height)] md:h-[var(--desktop-height)]"
style={
{
backgroundColor,
"--mobile-height": `${mobileHeight}px`,
"--desktop-height": `${desktopHeight}px`,
"--separator-color": separatorColor,
} as React.CSSProperties
}
>
{addSeparator && (
<div className="w-3/4 md:w-2/3 mx-auto border-t h-px border-[var(--separator-color,var(--color-border))]" />
)}
</div>
);
});
export default Spacer;
export let schema: HydrogenComponentSchema = {
type: "spacer",
title: "Spacer",
inspector: [
{
group: "Spacer",
inputs: [
{
type: "range",
label: "Mobile height",
name: "mobileHeight",
configs: {
min: 0,
max: 200,
step: 1,
unit: "px",
},
defaultValue: 50,
helpText: "Set to 0 to hide the Spacer on mobile devices",
},
{
type: "range",
label: "Desktop height",
name: "desktopHeight",
configs: {
min: 0,
max: 300,
step: 1,
unit: "px",
},
defaultValue: 100,
},
{
type: "color",
label: "Background color",
name: "backgroundColor",
defaultValue: "#00000000",
},
{
type: "switch",
label: "Add border separator",
name: "addSeparator",
defaultValue: false,
},
{
type: "color",
label: "Separator color",
name: "separatorColor",
defaultValue: "#000",
condition: "addSeparator.eq.true",
},
],
},
],
};