-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic_Form.json
More file actions
182 lines (182 loc) · 5.36 KB
/
Basic_Form.json
File metadata and controls
182 lines (182 loc) · 5.36 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
{
"id": "fsvkgnyqtg9t6ho",
"name": "Basic Form",
"js": "import slugify from \"slugify\";\n\nfunction slugify_name(text) {\n return slugify(text, {\n replacement: \"_\", // replace spaces with underscores\n lower: false, // convert to lowercase\n strict: true, // remove special chars\n });\n}\n\n// Auto-grow textarea fields on input\nfunction autogrow(node) {\n function resize() {\n node.style.height = \"auto\";\n node.style.height = node.scrollHeight + \"px\";\n }\n\n // Grow once on mount and whenever input changes\n resize();\n node.addEventListener(\"input\", resize);\n\n return {\n destroy() {\n node.removeEventListener(\"input\", resize);\n },\n };\n}\n",
"css": "@import url(https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css);\n\n.container {\n padding-block: 2rem;\n}",
"html": "<div class=\"container\">\n <form action={form_endpoint} method=\"POST\">\n {#each form_fields as field, i}\n {#if field.type === \"textarea\"}\n <label\n ><span>{field.label}</span>\n <textarea\n name={slugify_name(field.label)}\n placeholder={field.placeholder}\n required={field.required}\n use:autogrow></textarea>\n </label> \n {:else}\n <label\n ><span>{field.label}</span>\n <input\n name={slugify_name(field.label)}\n type={field.type || \"text\"}\n placeholder={field.placeholder}\n required={field.required} />\n </label>\n {/if}\n {/each}\n <button type=\"submit\">Submit</button>\n </form>\n</div>\n",
"site": "acwh2ttxy5uo8z1",
"compiled_js": "",
"fields": [
{
"id": "d5dxc8jcalynr3b",
"key": "form_fields",
"label": "Form Fields",
"type": "repeater",
"config": null,
"parent": "",
"index": 0,
"symbol": "fsvkgnyqtg9t6ho"
},
{
"id": "84ehq81gfb0wnbp",
"key": "label",
"label": "Label",
"type": "text",
"config": null,
"parent": "d5dxc8jcalynr3b",
"index": 0,
"symbol": "fsvkgnyqtg9t6ho"
},
{
"id": "f3y8gzeo0udk7yf",
"key": "placeholder",
"label": "Placeholder",
"type": "text",
"config": null,
"parent": "d5dxc8jcalynr3b",
"index": 1,
"symbol": "fsvkgnyqtg9t6ho"
},
{
"id": "eqnw9zerqnkw0gr",
"key": "type",
"label": "Type",
"type": "select",
"config": {
"options": [
{
"value": "text",
"label": "Text",
"icon": "humbleicons:text"
},
{
"value": "email",
"label": "Email",
"icon": "ic:baseline-email"
},
{
"value": "phone",
"label": "Phone",
"icon": "ic:baseline-phone"
},
{
"value": "textarea",
"label": "Textarea",
"icon": "bi:textarea-t"
}
]
},
"parent": "d5dxc8jcalynr3b",
"index": 2,
"symbol": "fsvkgnyqtg9t6ho"
},
{
"id": "l4eq1bd796b9p4q",
"key": "form_endpoint",
"label": "Form Endpoint",
"type": "text",
"config": null,
"parent": "",
"index": 1,
"symbol": "fsvkgnyqtg9t6ho"
}
],
"entries": [
{
"id": "b9i4d9wiq3q0ipg",
"locale": "en",
"value": null,
"field": "d5dxc8jcalynr3b",
"parent": "",
"index": 0
},
{
"id": "bhi21ix6ft42yfu",
"locale": "en",
"value": null,
"field": "d5dxc8jcalynr3b",
"parent": "",
"index": 1
},
{
"id": "kg3wjy5vp20ul58",
"locale": "en",
"value": null,
"field": "d5dxc8jcalynr3b",
"parent": "",
"index": 2
},
{
"id": "kbf1tgv198d3jd6",
"locale": "en",
"value": "Name",
"field": "84ehq81gfb0wnbp",
"parent": "b9i4d9wiq3q0ipg",
"index": 0
},
{
"id": "pnqu184urgk1sm4",
"locale": "en",
"value": "Email",
"field": "84ehq81gfb0wnbp",
"parent": "bhi21ix6ft42yfu",
"index": 0
},
{
"id": "0ei6e5kqwjgbci2",
"locale": "en",
"value": "Message",
"field": "84ehq81gfb0wnbp",
"parent": "kg3wjy5vp20ul58",
"index": 0
},
{
"id": "gwyom30zq812b25",
"locale": "en",
"value": "John Doe",
"field": "f3y8gzeo0udk7yf",
"parent": "b9i4d9wiq3q0ipg",
"index": 0
},
{
"id": "oqormwac9bonulm",
"locale": "en",
"value": "jdoe@email.com",
"field": "f3y8gzeo0udk7yf",
"parent": "bhi21ix6ft42yfu",
"index": 0
},
{
"id": "djhytravhetlft5",
"locale": "en",
"value": "Hello I would like to...",
"field": "f3y8gzeo0udk7yf",
"parent": "kg3wjy5vp20ul58",
"index": 0
},
{
"id": "5fvq4d9dtyoqrf3",
"locale": "en",
"value": "email",
"field": "eqnw9zerqnkw0gr",
"parent": "bhi21ix6ft42yfu",
"index": 0
},
{
"id": "asedr44kp68p0uz",
"locale": "en",
"value": "textarea",
"field": "eqnw9zerqnkw0gr",
"parent": "kg3wjy5vp20ul58",
"index": 0
},
{
"id": "xhwxnb9ggs3qq5b",
"locale": "en",
"value": "https://formspree.io/f/abcd1234",
"field": "l4eq1bd796b9p4q",
"parent": "",
"index": 0
}
]
}