@slicemachine/adapter-next 0.3.14-dev-slices-templates-feature.2 → 0.3.14-dev-next-release.5

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.
@@ -1,503 +0,0 @@
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 Link from "next/link";
166
- import { Content, isFilled, asLink, asText } from "@prismicio/client";
167
- import { SliceComponentProps, PrismicRichText } from "@prismicio/react";
168
-
169
- /**
170
- * Props for \`${pascalName}\`.
171
- */
172
- export type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;
173
-
174
- /**
175
- * Component for "${model.name}" Slices.
176
- */
177
- const ${pascalName} = ({ slice }: ${pascalName}Props): JSX.Element => {
178
- const alignment = slice.variation === "alignLeft" ? "left" : "center";
179
-
180
- return (
181
- <section
182
- data-slice-type={slice.slice_type}
183
- data-slice-variation={slice.variation}
184
- className="es-bounded es-call-to-action"
185
- >
186
- <div className="es-bounded__content es-call-to-action__content">
187
- {slice.primary.image?.url && (
188
- <img
189
- height={600}
190
- width={800}
191
- src={slice.primary.image.url}
192
- alt={slice.primary.image.alt ?? undefined}
193
- className="es-call-to-action__image"
194
- />
195
- )}
196
- <div className="es-call-to-action__content">
197
- {isFilled.richText(slice.primary.title) && (
198
- <h2 className="es-call-to-action__content__heading">
199
- {asText(slice.primary.title)}
200
- </h2>
201
- )}
202
- {isFilled.richText(slice.primary.paragraph) && (
203
- <div className="es-call-to-action__content__paragraph">
204
- <PrismicRichText field={slice.primary.paragraph} />
205
- </div>
206
- )}
207
- </div>
208
- {isFilled.link(slice.primary.buttonLink) ? (
209
- <Link
210
- className="es-call-to-action__button"
211
- href={asLink(slice.primary.buttonLink)}
212
- >
213
- {slice.primary.buttonLabel || "Learn more…"}
214
- </Link>
215
- ) : null}
216
- </div>
217
- <style>
218
- {\`
219
- .es-call-to-action {
220
- background-color: #fff;
221
- color: #333;
222
- padding: 8vw 2rem;
223
- }
224
-
225
- .es-call-to-action__content {
226
- display: grid;
227
- gap: 2rem;
228
- }
229
-
230
- .es-call-to-action__image {
231
- max-width: 14rem;
232
- justify-self: \${alignment};
233
- }
234
-
235
- .es-call-to-action__content {
236
- display: grid;
237
- gap: 1rem;
238
- justify-items: \${alignment};
239
- }
240
-
241
- .es-call-to-action__content__heading {
242
- font-size: 2rem;
243
- font-weight: 700;
244
- text-align: \${alignment};
245
- }
246
-
247
- .es-call-to-action__content__paragraph {
248
- font-size: 1.15rem;
249
- max-width: 38rem;
250
- text-align: \${alignment};
251
- }
252
-
253
- .es-call-to-action__button {
254
- justify-self: \${alignment};
255
- border-radius: 0.25rem;
256
- display: inline-block;
257
- font-size: 0.875rem;
258
- line-height: 1.3;
259
- padding: 1rem 2.625rem;
260
- text-align: \${alignment};
261
- transition: background-color 100ms linear;
262
- background-color: #16745f;
263
- color: #fff;
264
- }
265
-
266
- .es-call-to-action__button:hover {
267
- background-color: #0d5e4c;
268
- }
269
- \`}
270
- </style>
271
- </section>
272
- );
273
- };
274
-
275
- export default ${pascalName};
276
- `;
277
- }
278
-
279
- return stripIndent`
280
- import Link from "next/link";
281
- import { PrismicRichText } from "@prismicio/react";
282
- import { isFilled, asLink, asText } from "@prismicio/client";
283
-
284
- /**
285
- * @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
286
- * @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
287
- * @param {${pascalName}Props}
288
- */
289
- const ${pascalName} = ({ slice }) => {
290
- const alignment = slice.variation === "alignLeft" ? "left" : "center";
291
-
292
- return (
293
- <section
294
- data-slice-type={slice.slice_type}
295
- data-slice-variation={slice.variation}
296
- className="es-bounded es-call-to-action"
297
- >
298
- <div className="es-bounded__content es-call-to-action__content">
299
- {slice.primary.image?.url && (
300
- <img
301
- height={600}
302
- width={800}
303
- src={slice.primary.image.url}
304
- alt={slice.primary.image.alt ?? undefined}
305
- className="es-call-to-action__image"
306
- />
307
- )}
308
- <div className="es-call-to-action__content">
309
- {isFilled.richText(slice.primary.title) && (
310
- <h2 className="es-call-to-action__content__heading">
311
- {asText(slice.primary.title)}
312
- </h2>
313
- )}
314
- {isFilled.richText(slice.primary.paragraph) && (
315
- <div className="es-call-to-action__content__paragraph">
316
- <PrismicRichText field={slice.primary.paragraph} />
317
- </div>
318
- )}
319
- </div>
320
- {isFilled.link(slice.primary.buttonLink) ? (
321
- <Link
322
- className="es-call-to-action__button"
323
- href={asLink(slice.primary.buttonLink)}
324
- >
325
- {slice.primary.buttonLabel || "Learn more…"}
326
- </Link>
327
- ) : null}
328
- </div>
329
- <style>
330
- {\`
331
- .es-call-to-action {
332
- background-color: #fff;
333
- color: #333;
334
- padding: 8vw 2rem;
335
- }
336
-
337
- .es-call-to-action__content {
338
- display: grid;
339
- gap: 2rem;
340
- }
341
-
342
- .es-call-to-action__image {
343
- max-width: 14rem;
344
- justify-self: \${alignment};
345
- }
346
-
347
- .es-call-to-action__content {
348
- display: grid;
349
- gap: 1rem;
350
- justify-items: \${alignment};
351
- }
352
-
353
- .es-call-to-action__content__heading {
354
- font-size: 2rem;
355
- font-weight: 700;
356
- text-align: \${alignment};
357
- }
358
-
359
- .es-call-to-action__content__paragraph {
360
- font-size: 1.15rem;
361
- max-width: 38rem;
362
- text-align: \${alignment};
363
- }
364
-
365
- .es-call-to-action__button {
366
- justify-self: \${alignment};
367
- border-radius: 0.25rem;
368
- display: inline-block;
369
- font-size: 0.875rem;
370
- line-height: 1.3;
371
- padding: 1rem 2.625rem;
372
- text-align: \${alignment};
373
- transition: background-color 100ms linear;
374
- background-color: #16745f;
375
- color: #fff;
376
- }
377
-
378
- .es-call-to-action__button:hover {
379
- background-color: #0d5e4c;
380
- }
381
- \`}
382
- </style>
383
- </section>
384
- );
385
- };
386
-
387
- export default ${pascalName};
388
- `;
389
- };
390
-
391
- export const model: SharedSlice = {
392
- id: "call_to_action",
393
- type: "SharedSlice",
394
- name: "CallToAction",
395
- description: "CallToAction",
396
- variations: [
397
- {
398
- id: "default",
399
- name: "Default",
400
- docURL: "...",
401
- version: "initial",
402
- description: "Default",
403
- imageUrl: "",
404
- primary: {
405
- image: {
406
- type: "Image",
407
- config: { label: "Image", constraint: {}, thumbnails: [] },
408
- },
409
- title: {
410
- type: "StructuredText",
411
- config: {
412
- label: "title",
413
- placeholder: "",
414
- allowTargetBlank: true,
415
- single: "heading1,heading2,heading3,heading4,heading5,heading6",
416
- },
417
- },
418
- paragraph: {
419
- type: "StructuredText",
420
- config: {
421
- label: "paragraph",
422
- placeholder: "",
423
- allowTargetBlank: true,
424
- single:
425
- "paragraph,preformatted,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
426
- },
427
- },
428
- buttonlink: {
429
- type: "Link",
430
- config: {
431
- label: "buttonLink",
432
- placeholder: "Redirect URL for CTA button",
433
- allowTargetBlank: true,
434
- select: null,
435
- },
436
- },
437
- buttonLabel: {
438
- type: "Text",
439
- config: {
440
- label: "buttonLabel",
441
- placeholder: "Label for CTA button",
442
- },
443
- },
444
- },
445
- items: {},
446
- },
447
- {
448
- id: "alignLeft",
449
- name: "AlignLeft",
450
- docURL: "...",
451
- version: "initial",
452
- description: "Default",
453
- imageUrl: "",
454
- primary: {
455
- image: {
456
- type: "Image",
457
- config: { label: "Image", constraint: {}, thumbnails: [] },
458
- },
459
- title: {
460
- type: "StructuredText",
461
- config: {
462
- label: "title",
463
- placeholder: "",
464
- allowTargetBlank: true,
465
- single: "heading1,heading2,heading3,heading4,heading5,heading6",
466
- },
467
- },
468
- paragraph: {
469
- type: "StructuredText",
470
- config: {
471
- label: "paragraph",
472
- placeholder: "",
473
- allowTargetBlank: true,
474
- single:
475
- "paragraph,preformatted,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
476
- },
477
- },
478
- buttonlink: {
479
- type: "Link",
480
- config: {
481
- label: "buttonLink",
482
- placeholder: "Redirect URL for CTA button",
483
- allowTargetBlank: true,
484
- select: null,
485
- },
486
- },
487
- buttonLabel: {
488
- type: "Text",
489
- config: {
490
- label: "buttonLabel",
491
- placeholder: "Label for CTA button",
492
- },
493
- },
494
- },
495
- items: {},
496
- },
497
- ],
498
- };
499
-
500
- export const screenshotPaths = {
501
- default: "CallToAction/screenshot-default.png",
502
- alignLeft: "CallToAction/screenshot-alignLeft.png",
503
- };