forked from Weaverse/pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subheading.tsx
147 lines (142 loc) · 3.3 KB
/
subheading.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import type {
HydrogenComponentProps,
HydrogenComponentSchema,
} from "@weaverse/hydrogen";
import type { VariantProps } from "class-variance-authority";
import { cva } from "class-variance-authority";
import { forwardRef } from "react";
import { cn } from "~/lib/cn";
let variants = cva("subheading", {
variants: {
size: {
base: "text-base",
large: "text-lg",
},
weight: {
normal: "font-normal",
medium: "font-medium",
},
alignment: {
left: "text-left",
center: "text-center",
right: "text-right",
},
},
defaultVariants: {
size: "base",
weight: "normal",
alignment: "center",
},
});
interface SubHeadingProps
extends VariantProps<typeof variants>,
HydrogenComponentProps {
as?: "h4" | "h5" | "h6" | "div" | "p";
color?: string;
content: string;
}
let SubHeading = forwardRef<
HTMLHeadingElement | HTMLParagraphElement | HTMLDivElement,
SubHeadingProps
>((props, ref) => {
let {
as: Tag = "p",
content,
color,
size,
weight,
alignment,
className,
...rest
} = props;
return (
<Tag
ref={ref}
{...rest}
style={{ color }}
className={cn(variants({ size, weight, alignment, className }))}
>
{content}
</Tag>
);
});
export default SubHeading;
export let schema: HydrogenComponentSchema = {
type: "subheading",
title: "Subheading",
inspector: [
{
group: "Subheading",
inputs: [
{
type: "select",
name: "as",
label: "Tag name",
configs: {
options: [
{ value: "h4", label: "Heading 4" },
{ value: "h5", label: "Heading 5" },
{ value: "h6", label: "Heading 6" },
{ value: "p", label: "Paragraph" },
{ value: "div", label: "Div" },
],
},
defaultValue: "p",
},
{
type: "text",
name: "content",
label: "Content",
defaultValue: "Section subheading",
placeholder: "Section subheading",
},
{
type: "color",
name: "color",
label: "Text color",
},
{
type: "select",
name: "size",
label: "Text size",
configs: {
options: [
{ value: "base", label: "Base" },
{ value: "large", label: "Large" },
],
},
defaultValue: "base",
},
{
type: "select",
name: "weight",
label: "Weight",
configs: {
options: [
{ value: "normal", label: "Normal" },
{ value: "medium", label: "Medium" },
],
},
defaultValue: "normal",
},
{
type: "toggle-group",
name: "alignment",
label: "Alignment",
configs: {
options: [
{ value: "left", label: "Left", icon: "align-start-vertical" },
{
value: "center",
label: "Center",
icon: "align-center-vertical",
},
{ value: "right", label: "Right", icon: "align-end-vertical" },
],
},
defaultValue: "center",
},
],
},
],
};