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