generated from Weaverse/pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.tsx
83 lines (78 loc) · 1.91 KB
/
page.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
import { useLoaderData } from "@remix-run/react";
import type {
HydrogenComponentProps,
HydrogenComponentSchema,
} from "@weaverse/hydrogen";
import { forwardRef } from "react";
import type { PageDetailsQuery } from "storefrontapi.generated";
import { PageHeader } from "~/modules/text";
interface PageProps extends HydrogenComponentProps {
paddingTop: number;
paddingBottom: number;
}
let Page = forwardRef<HTMLElement, PageProps>((props, ref) => {
let { page } = useLoaderData<PageDetailsQuery>();
let { paddingTop, paddingBottom, ...rest } = props;
if (page) {
return (
<section ref={ref} {...rest}>
<div
className="grid w-full gap-8 px-6 md:px-8 lg:px-12 justify-items-start"
style={{
paddingTop: `${paddingTop}px`,
paddingBottom: `${paddingBottom}px`,
}}
>
<PageHeader heading={page.title}>
<div
suppressHydrationWarning
dangerouslySetInnerHTML={{ __html: page.body }}
className="prose dark:prose-invert"
/>
</PageHeader>
</div>
</section>
);
}
return <section ref={ref} {...rest} />;
});
export default Page;
export let schema: HydrogenComponentSchema = {
type: "page",
title: "Page",
limit: 1,
enabledOn: {
pages: ["PAGE"],
},
inspector: [
{
group: "Page",
inputs: [
{
type: "range",
label: "Top padding",
name: "paddingTop",
configs: {
min: 0,
max: 100,
step: 4,
unit: "px",
},
defaultValue: 32,
},
{
type: "range",
label: "Bottom padding",
name: "paddingBottom",
configs: {
min: 0,
max: 100,
step: 4,
unit: "px",
},
defaultValue: 32,
},
],
},
],
};