@slicemachine/adapter-next 0.3.14-dev-next-release.4 → 0.3.14-dev-slice-tenplate-feature-2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,497 @@
1
+ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+ import { SharedSliceContent } from "@prismicio/types-internal/lib/content";
3
+
4
+ import { pascalCase } from "../../lib/pascalCase";
5
+
6
+ import { stripIndent } from "common-tags";
7
+
8
+ export const mocks: SharedSliceContent[] = [
9
+ {
10
+ __TYPE__: "SharedSliceContent",
11
+ variation: "default",
12
+ primary: {
13
+ title: {
14
+ __TYPE__: "StructuredTextContent",
15
+ value: [
16
+ {
17
+ type: "heading1",
18
+ content: {
19
+ text: "Collector Slices kit",
20
+ spans: [],
21
+ },
22
+ direction: "ltr",
23
+ },
24
+ ],
25
+ },
26
+ paragraph: {
27
+ __TYPE__: "StructuredTextContent",
28
+ value: [
29
+ {
30
+ type: "paragraph",
31
+ content: {
32
+ text: "It’s very easy to create stylish and beautiful prototypes for your future projects, both graphical and dynamic.",
33
+ spans: [],
34
+ },
35
+ direction: "ltr",
36
+ },
37
+ ],
38
+ },
39
+ buttonlink: {
40
+ __TYPE__: "LinkContent",
41
+ value: {
42
+ __TYPE__: "ExternalLink",
43
+ url: "https://twitter.com/prismicio",
44
+ },
45
+ },
46
+ buttonlabel: {
47
+ __TYPE__: "FieldContent",
48
+ type: "Text",
49
+ value: "Click here",
50
+ },
51
+ image: {
52
+ origin: {
53
+ id: "9aOswReDKPo",
54
+ url: "https://images.unsplash.com/photo-1523049673857-eb18f1d7b578?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMzc0NjN8MHwxfHNlYXJjaHwxOXx8ZnJ1aXR8ZW58MHx8fHwxNjkzMjUxNTMxfDA&ixlib=rb-4.0.3&q=85",
55
+ width: 8040,
56
+ height: 6024,
57
+ },
58
+ url: "https://images.unsplash.com/photo-1523049673857-eb18f1d7b578?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMzc0NjN8MHwxfHNlYXJjaHwxOXx8ZnJ1aXR8ZW58MHx8fHwxNjkzMjUxNTMxfDA&ixlib=rb-4.0.3&q=85",
59
+ width: 8040,
60
+ height: 6024,
61
+ edit: {
62
+ background: "transparent",
63
+ zoom: 1,
64
+ crop: {
65
+ x: 0,
66
+ y: 0,
67
+ },
68
+ },
69
+ credits: null,
70
+ alt: null,
71
+ __TYPE__: "ImageContent",
72
+ thumbnails: {},
73
+ },
74
+ buttonLabel: {
75
+ __TYPE__: "FieldContent",
76
+ type: "Text",
77
+ value: "Learn more",
78
+ },
79
+ },
80
+ items: [],
81
+ },
82
+ {
83
+ __TYPE__: "SharedSliceContent",
84
+ variation: "alignLeft",
85
+ primary: {
86
+ image: {
87
+ origin: {
88
+ id: "euqiHwS38Rw",
89
+ url: "https://images.unsplash.com/photo-1595475207225-428b62bda831?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMzc0NjN8MHwxfHNlYXJjaHwyMHx8ZnJ1aXR8ZW58MHx8fHwxNjkzMjUxNTMxfDA&ixlib=rb-4.0.3&q=85",
90
+ width: 2500,
91
+ height: 2500,
92
+ },
93
+ url: "https://images.unsplash.com/photo-1595475207225-428b62bda831?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMzc0NjN8MHwxfHNlYXJjaHwyMHx8ZnJ1aXR8ZW58MHx8fHwxNjkzMjUxNTMxfDA&ixlib=rb-4.0.3&q=85",
94
+ width: 2500,
95
+ height: 2500,
96
+ edit: {
97
+ background: "transparent",
98
+ zoom: 1,
99
+ crop: {
100
+ x: 0,
101
+ y: 0,
102
+ },
103
+ },
104
+ credits: null,
105
+ alt: null,
106
+ __TYPE__: "ImageContent",
107
+ thumbnails: {},
108
+ },
109
+ title: {
110
+ __TYPE__: "StructuredTextContent",
111
+ value: [
112
+ {
113
+ type: "heading1",
114
+ content: {
115
+ text: "Collector Slices kit",
116
+ spans: [],
117
+ },
118
+ direction: "ltr",
119
+ },
120
+ ],
121
+ },
122
+ paragraph: {
123
+ __TYPE__: "StructuredTextContent",
124
+ value: [
125
+ {
126
+ type: "paragraph",
127
+ content: {
128
+ text: "It’s very easy to create stylish and beautiful prototypes for your future projects, both graphical and dynamic.",
129
+ spans: [],
130
+ },
131
+ direction: "ltr",
132
+ },
133
+ ],
134
+ },
135
+ buttonlink: {
136
+ __TYPE__: "LinkContent",
137
+ value: {
138
+ __TYPE__: "ExternalLink",
139
+ url: "https://prismic.io",
140
+ },
141
+ },
142
+ buttonLabel: {
143
+ __TYPE__: "FieldContent",
144
+ type: "Text",
145
+ value: "Learn more!",
146
+ },
147
+ },
148
+ items: [
149
+ {
150
+ __TYPE__: "GroupItemContent",
151
+ value: [],
152
+ },
153
+ ],
154
+ },
155
+ ];
156
+
157
+ export const createComponentContents = (
158
+ model: SharedSlice,
159
+ isTypeScriptProject: boolean,
160
+ ): string => {
161
+ const pascalName = pascalCase(model.name);
162
+
163
+ if (isTypeScriptProject) {
164
+ return stripIndent`
165
+ import { Content, isFilled, asText } from "@prismicio/client";
166
+ import { SliceComponentProps, PrismicRichText } from "@prismicio/react";
167
+
168
+ /**
169
+ * Props for \`${pascalName}\`.
170
+ */
171
+ export type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;
172
+
173
+ /**
174
+ * Component for "${model.name}" Slices.
175
+ */
176
+ const ${pascalName} = ({ slice }: ${pascalName}Props): JSX.Element => {
177
+ const alignment = slice.variation === "alignLeft" ? "left" : "center";
178
+
179
+ return (
180
+ <section
181
+ data-slice-type={slice.slice_type}
182
+ data-slice-variation={slice.variation}
183
+ className="es-bounded es-call-to-action"
184
+ >
185
+ <div className="es-bounded__content es-call-to-action__content">
186
+ {slice.primary.image?.url && (
187
+ <img
188
+ height={600}
189
+ width={800}
190
+ src={slice.primary.image.url}
191
+ alt={slice.primary.image.alt ?? undefined}
192
+ className="es-call-to-action__image"
193
+ />
194
+ )}
195
+ <div className="es-call-to-action__content">
196
+ {isFilled.richText(slice.primary.title) && (
197
+ <h2 className="es-call-to-action__content__heading">
198
+ {asText(slice.primary.title)}
199
+ </h2>
200
+ )}
201
+ {isFilled.richText(slice.primary.paragraph) && (
202
+ <div className="es-call-to-action__content__paragraph">
203
+ <PrismicRichText field={slice.primary.paragraph} />
204
+ </div>
205
+ )}
206
+ </div>
207
+ <button
208
+ field={slice.primary.buttonLink}
209
+ className="es-call-to-action__button"
210
+ >
211
+ {slice.primary.buttonLabel || "Learn more…"}
212
+ </button>
213
+ </div>
214
+ <style>
215
+ {\`
216
+ .es-call-to-action {
217
+ background-color: #fff;
218
+ color: #333;
219
+ padding: 8vw 2rem;
220
+ }
221
+
222
+ .es-call-to-action__content {
223
+ display: grid;
224
+ gap: 2rem;
225
+ }
226
+
227
+ .es-call-to-action__image {
228
+ max-width: 14rem;
229
+ justify-self: \${alignment};
230
+ }
231
+
232
+ .es-call-to-action__content {
233
+ display: grid;
234
+ gap: 1rem;
235
+ justify-items: \${alignment};
236
+ }
237
+
238
+ .es-call-to-action__content__heading {
239
+ font-size: 2rem;
240
+ font-weight: 700;
241
+ text-align: \${alignment};
242
+ }
243
+
244
+ .es-call-to-action__content__paragraph {
245
+ font-size: 1.15rem;
246
+ max-width: 38rem;
247
+ text-align: \${alignment};
248
+ }
249
+
250
+ .es-call-to-action__button {
251
+ justify-self: \${alignment};
252
+ border-radius: 0.25rem;
253
+ display: inline-block;
254
+ font-size: 0.875rem;
255
+ line-height: 1.3;
256
+ padding: 1rem 2.625rem;
257
+ text-align: \${alignment};
258
+ transition: background-color 100ms linear;
259
+ background-color: #16745f;
260
+ color: #fff;
261
+ }
262
+
263
+ .es-call-to-action__button:hover {
264
+ background-color: #0d5e4c;
265
+ }
266
+ \`}
267
+ </style>
268
+ </section>
269
+ );
270
+ };
271
+
272
+ export default ${pascalName};
273
+ `;
274
+ }
275
+
276
+ return stripIndent`
277
+ import { PrismicRichText } from "@prismicio/react";
278
+ import { isFilled, asText } from "@prismicio/client";
279
+
280
+ /**
281
+ * @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
282
+ * @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
283
+ * @param {${pascalName}Props}
284
+ */
285
+ const ${pascalName} = ({ slice }) => {
286
+ const alignment = slice.variation === "alignLeft" ? "left" : "center";
287
+
288
+ return (
289
+ <section
290
+ data-slice-type={slice.slice_type}
291
+ data-slice-variation={slice.variation}
292
+ className="es-bounded es-call-to-action"
293
+ >
294
+ <div className="es-bounded__content es-call-to-action__content">
295
+ {slice.primary.image?.url && (
296
+ <img
297
+ height={600}
298
+ width={800}
299
+ src={slice.primary.image.url}
300
+ alt={slice.primary.image.alt ?? undefined}
301
+ className="es-call-to-action__image"
302
+ />
303
+ )}
304
+ <div className="es-call-to-action__content">
305
+ {isFilled.richText(slice.primary.title) && (
306
+ <h2 className="es-call-to-action__content__heading">
307
+ {asText(slice.primary.title)}
308
+ </h2>
309
+ )}
310
+ {isFilled.richText(slice.primary.paragraph) && (
311
+ <div className="es-call-to-action__content__paragraph">
312
+ <PrismicRichText field={slice.primary.paragraph} />
313
+ </div>
314
+ )}
315
+ </div>
316
+ <button
317
+ field={slice.primary.buttonLink}
318
+ className="es-call-to-action__button"
319
+ >
320
+ {slice.primary.buttonLabel || "Learn more…"}
321
+ </button>
322
+ </div>
323
+ <style>
324
+ {\`
325
+ .es-call-to-action {
326
+ background-color: #fff;
327
+ color: #333;
328
+ padding: 8vw 2rem;
329
+ }
330
+
331
+ .es-call-to-action__content {
332
+ display: grid;
333
+ gap: 2rem;
334
+ }
335
+
336
+ .es-call-to-action__image {
337
+ max-width: 14rem;
338
+ justify-self: \${alignment};
339
+ }
340
+
341
+ .es-call-to-action__content {
342
+ display: grid;
343
+ gap: 1rem;
344
+ justify-items: \${alignment};
345
+ }
346
+
347
+ .es-call-to-action__content__heading {
348
+ font-size: 2rem;
349
+ font-weight: 700;
350
+ text-align: \${alignment};
351
+ }
352
+
353
+ .es-call-to-action__content__paragraph {
354
+ font-size: 1.15rem;
355
+ max-width: 38rem;
356
+ text-align: \${alignment};
357
+ }
358
+
359
+ .es-call-to-action__button {
360
+ justify-self: \${alignment};
361
+ border-radius: 0.25rem;
362
+ display: inline-block;
363
+ font-size: 0.875rem;
364
+ line-height: 1.3;
365
+ padding: 1rem 2.625rem;
366
+ text-align: \${alignment};
367
+ transition: background-color 100ms linear;
368
+ background-color: #16745f;
369
+ color: #fff;
370
+ }
371
+
372
+ .es-call-to-action__button:hover {
373
+ background-color: #0d5e4c;
374
+ }
375
+ \`}
376
+ </style>
377
+ </section>
378
+ );
379
+ };
380
+
381
+ export default ${pascalName};
382
+ `;
383
+ };
384
+
385
+ export const model: SharedSlice = {
386
+ id: "call_to_action",
387
+ type: "SharedSlice",
388
+ name: "CallToAction",
389
+ description: "CallToAction",
390
+ variations: [
391
+ {
392
+ id: "default",
393
+ name: "Default",
394
+ docURL: "...",
395
+ version: "initial",
396
+ description: "Default",
397
+ imageUrl: "",
398
+ primary: {
399
+ image: {
400
+ type: "Image",
401
+ config: { label: "Image", constraint: {}, thumbnails: [] },
402
+ },
403
+ title: {
404
+ type: "StructuredText",
405
+ config: {
406
+ label: "title",
407
+ placeholder: "",
408
+ allowTargetBlank: true,
409
+ single: "heading1,heading2,heading3,heading4,heading5,heading6",
410
+ },
411
+ },
412
+ paragraph: {
413
+ type: "StructuredText",
414
+ config: {
415
+ label: "paragraph",
416
+ placeholder: "",
417
+ allowTargetBlank: true,
418
+ single:
419
+ "paragraph,preformatted,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
420
+ },
421
+ },
422
+ buttonlink: {
423
+ type: "Link",
424
+ config: {
425
+ label: "buttonLink",
426
+ placeholder: "Redirect URL for CTA button",
427
+ allowTargetBlank: true,
428
+ select: null,
429
+ },
430
+ },
431
+ buttonLabel: {
432
+ type: "Text",
433
+ config: {
434
+ label: "buttonLabel",
435
+ placeholder: "Label for CTA button",
436
+ },
437
+ },
438
+ },
439
+ items: {},
440
+ },
441
+ {
442
+ id: "alignLeft",
443
+ name: "AlignLeft",
444
+ docURL: "...",
445
+ version: "initial",
446
+ description: "Default",
447
+ imageUrl: "",
448
+ primary: {
449
+ image: {
450
+ type: "Image",
451
+ config: { label: "Image", constraint: {}, thumbnails: [] },
452
+ },
453
+ title: {
454
+ type: "StructuredText",
455
+ config: {
456
+ label: "title",
457
+ placeholder: "",
458
+ allowTargetBlank: true,
459
+ single: "heading1,heading2,heading3,heading4,heading5,heading6",
460
+ },
461
+ },
462
+ paragraph: {
463
+ type: "StructuredText",
464
+ config: {
465
+ label: "paragraph",
466
+ placeholder: "",
467
+ allowTargetBlank: true,
468
+ single:
469
+ "paragraph,preformatted,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
470
+ },
471
+ },
472
+ buttonlink: {
473
+ type: "Link",
474
+ config: {
475
+ label: "buttonLink",
476
+ placeholder: "Redirect URL for CTA button",
477
+ allowTargetBlank: true,
478
+ select: null,
479
+ },
480
+ },
481
+ buttonLabel: {
482
+ type: "Text",
483
+ config: {
484
+ label: "buttonLabel",
485
+ placeholder: "Label for CTA button",
486
+ },
487
+ },
488
+ },
489
+ items: {},
490
+ },
491
+ ],
492
+ };
493
+
494
+ export const screenshotPaths = {
495
+ default: "CallToAction/screenshot-default.png",
496
+ alignLeft: "CallToAction/screenshot-alignLeft.png",
497
+ };