@slicemachine/adapter-next 0.3.14-dev-next-release.2 → 0.3.14-dev-slices-templates-feature.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.
- package/dist/CallToAction/screenshot-alignLeft.png +0 -0
- package/dist/CallToAction/screenshot-default.png +0 -0
- package/dist/hooks/slice-create.cjs +7 -5
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +7 -5
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/slice-template-library-read.cjs +25 -0
- package/dist/hooks/slice-template-library-read.cjs.map +1 -0
- package/dist/hooks/slice-template-library-read.d.ts +3 -0
- package/dist/hooks/slice-template-library-read.js +25 -0
- package/dist/hooks/slice-template-library-read.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs +2 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -1
- package/dist/sliceTemplates/CallToAction/index.cjs +268 -0
- package/dist/sliceTemplates/CallToAction/index.cjs.map +1 -0
- package/dist/sliceTemplates/CallToAction/index.d.ts +9 -0
- package/dist/sliceTemplates/CallToAction/index.js +268 -0
- package/dist/sliceTemplates/CallToAction/index.js.map +1 -0
- package/package.json +3 -3
- package/src/hooks/slice-create.ts +7 -5
- package/src/hooks/slice-template-library-read.ts +46 -0
- package/src/index.ts +5 -0
- package/src/plugin.ts +7 -0
- package/src/sliceTemplates/CallToAction/index.ts +271 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
SliceTemplateLibraryReadHook,
|
|
6
|
+
SliceTemplateLibraryReadHookData,
|
|
7
|
+
} from "@slicemachine/plugin-kit";
|
|
8
|
+
|
|
9
|
+
import type { PluginOptions } from "../types";
|
|
10
|
+
|
|
11
|
+
import * as CallToAction from "../sliceTemplates/CallToAction";
|
|
12
|
+
|
|
13
|
+
const initialTemplates = [CallToAction];
|
|
14
|
+
|
|
15
|
+
export const sliceTemplateLibraryRead: SliceTemplateLibraryReadHook<
|
|
16
|
+
PluginOptions
|
|
17
|
+
> = async ({
|
|
18
|
+
templateIds,
|
|
19
|
+
isTypeScriptProject,
|
|
20
|
+
}: SliceTemplateLibraryReadHookData) => {
|
|
21
|
+
const templates =
|
|
22
|
+
templateIds && templateIds.length
|
|
23
|
+
? initialTemplates.filter((t) => templateIds?.includes(t.model.id))
|
|
24
|
+
: initialTemplates;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
templates: templates.map((t) => {
|
|
28
|
+
const { mocks, model, createComponentContents, screenshotPaths } = t;
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
mocks,
|
|
32
|
+
model,
|
|
33
|
+
componentContents: createComponentContents(isTypeScriptProject),
|
|
34
|
+
screenshots: Object.entries(screenshotPaths).reduce(
|
|
35
|
+
(acc, curr) => ({
|
|
36
|
+
...acc,
|
|
37
|
+
[curr[0]]: fs.readFileSync(
|
|
38
|
+
path.join(globalThis.__dirname, curr[1]),
|
|
39
|
+
),
|
|
40
|
+
}),
|
|
41
|
+
{},
|
|
42
|
+
),
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
};
|
package/src/index.ts
CHANGED
package/src/plugin.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { projectInit } from "./hooks/project-init";
|
|
|
30
30
|
import { sliceCreate } from "./hooks/slice-create";
|
|
31
31
|
import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read";
|
|
32
32
|
import { snippetRead } from "./hooks/snippet-read";
|
|
33
|
+
import { sliceTemplateLibraryRead } from "./hooks/slice-template-library-read";
|
|
33
34
|
|
|
34
35
|
export const plugin = defineSliceMachinePlugin<PluginOptions>({
|
|
35
36
|
meta: {
|
|
@@ -155,6 +156,12 @@ export const plugin = defineSliceMachinePlugin<PluginOptions>({
|
|
|
155
156
|
});
|
|
156
157
|
});
|
|
157
158
|
|
|
159
|
+
////////////////////////////////////////////////////////////////
|
|
160
|
+
// slice-template-library:*
|
|
161
|
+
////////////////////////////////////////////////////////////////
|
|
162
|
+
|
|
163
|
+
hook("slice-template-library:read", sliceTemplateLibraryRead);
|
|
164
|
+
|
|
158
165
|
////////////////////////////////////////////////////////////////
|
|
159
166
|
// custom-type:*
|
|
160
167
|
////////////////////////////////////////////////////////////////
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
2
|
+
import { SharedSliceContent } from "@prismicio/types-internal/lib/content";
|
|
3
|
+
|
|
4
|
+
export const mocks: SharedSliceContent[] = [
|
|
5
|
+
{
|
|
6
|
+
__TYPE__: "SharedSliceContent",
|
|
7
|
+
variation: "default",
|
|
8
|
+
primary: {
|
|
9
|
+
title: {
|
|
10
|
+
__TYPE__: "StructuredTextContent",
|
|
11
|
+
value: [
|
|
12
|
+
{
|
|
13
|
+
type: "heading1",
|
|
14
|
+
content: {
|
|
15
|
+
text: "Collector Slices kit",
|
|
16
|
+
spans: [],
|
|
17
|
+
},
|
|
18
|
+
direction: "ltr",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
paragraph: {
|
|
23
|
+
__TYPE__: "StructuredTextContent",
|
|
24
|
+
value: [
|
|
25
|
+
{
|
|
26
|
+
type: "paragraph",
|
|
27
|
+
content: {
|
|
28
|
+
text: "It’s very easy to create stylish and beautiful prototypes for your future projects, both graphical and dynamic.",
|
|
29
|
+
spans: [],
|
|
30
|
+
},
|
|
31
|
+
direction: "ltr",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
buttonlink: {
|
|
36
|
+
__TYPE__: "LinkContent",
|
|
37
|
+
value: {
|
|
38
|
+
__TYPE__: "ExternalLink",
|
|
39
|
+
url: "https://twitter.com/prismicio",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
buttonlabel: {
|
|
43
|
+
__TYPE__: "FieldContent",
|
|
44
|
+
type: "Text",
|
|
45
|
+
value: "Click here",
|
|
46
|
+
},
|
|
47
|
+
image: {
|
|
48
|
+
origin: {
|
|
49
|
+
id: "9aOswReDKPo",
|
|
50
|
+
url: "https://images.unsplash.com/photo-1523049673857-eb18f1d7b578?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMzc0NjN8MHwxfHNlYXJjaHwxOXx8ZnJ1aXR8ZW58MHx8fHwxNjkzMjUxNTMxfDA&ixlib=rb-4.0.3&q=85",
|
|
51
|
+
width: 8040,
|
|
52
|
+
height: 6024,
|
|
53
|
+
},
|
|
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
|
+
edit: {
|
|
58
|
+
background: "transparent",
|
|
59
|
+
zoom: 1,
|
|
60
|
+
crop: {
|
|
61
|
+
x: 0,
|
|
62
|
+
y: 0,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
credits: null,
|
|
66
|
+
alt: null,
|
|
67
|
+
__TYPE__: "ImageContent",
|
|
68
|
+
thumbnails: {},
|
|
69
|
+
},
|
|
70
|
+
buttonLabel: {
|
|
71
|
+
__TYPE__: "FieldContent",
|
|
72
|
+
type: "Text",
|
|
73
|
+
value: "Learn more",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
items: [],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
__TYPE__: "SharedSliceContent",
|
|
80
|
+
variation: "alignLeft",
|
|
81
|
+
primary: {
|
|
82
|
+
image: {
|
|
83
|
+
origin: {
|
|
84
|
+
id: "euqiHwS38Rw",
|
|
85
|
+
url: "https://images.unsplash.com/photo-1595475207225-428b62bda831?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMzc0NjN8MHwxfHNlYXJjaHwyMHx8ZnJ1aXR8ZW58MHx8fHwxNjkzMjUxNTMxfDA&ixlib=rb-4.0.3&q=85",
|
|
86
|
+
width: 2500,
|
|
87
|
+
height: 2500,
|
|
88
|
+
},
|
|
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
|
+
edit: {
|
|
93
|
+
background: "transparent",
|
|
94
|
+
zoom: 1,
|
|
95
|
+
crop: {
|
|
96
|
+
x: 0,
|
|
97
|
+
y: 0,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
credits: null,
|
|
101
|
+
alt: null,
|
|
102
|
+
__TYPE__: "ImageContent",
|
|
103
|
+
thumbnails: {},
|
|
104
|
+
},
|
|
105
|
+
title: {
|
|
106
|
+
__TYPE__: "StructuredTextContent",
|
|
107
|
+
value: [
|
|
108
|
+
{
|
|
109
|
+
type: "heading1",
|
|
110
|
+
content: {
|
|
111
|
+
text: "Collector Slices kit",
|
|
112
|
+
spans: [],
|
|
113
|
+
},
|
|
114
|
+
direction: "ltr",
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
paragraph: {
|
|
119
|
+
__TYPE__: "StructuredTextContent",
|
|
120
|
+
value: [
|
|
121
|
+
{
|
|
122
|
+
type: "paragraph",
|
|
123
|
+
content: {
|
|
124
|
+
text: "It’s very easy to create stylish and beautiful prototypes for your future projects, both graphical and dynamic.",
|
|
125
|
+
spans: [],
|
|
126
|
+
},
|
|
127
|
+
direction: "ltr",
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
buttonlink: {
|
|
132
|
+
__TYPE__: "LinkContent",
|
|
133
|
+
value: {
|
|
134
|
+
__TYPE__: "ExternalLink",
|
|
135
|
+
url: "https://prismic.io",
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
buttonLabel: {
|
|
139
|
+
__TYPE__: "FieldContent",
|
|
140
|
+
type: "Text",
|
|
141
|
+
value: "Learn more!",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
items: [
|
|
145
|
+
{
|
|
146
|
+
__TYPE__: "GroupItemContent",
|
|
147
|
+
value: [],
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
export const createComponentContents = (
|
|
154
|
+
isTypeScriptProject: boolean,
|
|
155
|
+
): string => {
|
|
156
|
+
return isTypeScriptProject ? "t = true" : "t = false";
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const model: SharedSlice = {
|
|
160
|
+
id: "call_to_action",
|
|
161
|
+
type: "SharedSlice",
|
|
162
|
+
name: "CallToAction",
|
|
163
|
+
description: "CallToAction",
|
|
164
|
+
variations: [
|
|
165
|
+
{
|
|
166
|
+
id: "default",
|
|
167
|
+
name: "Default",
|
|
168
|
+
docURL: "...",
|
|
169
|
+
version: "initial",
|
|
170
|
+
description: "Default",
|
|
171
|
+
imageUrl: "",
|
|
172
|
+
primary: {
|
|
173
|
+
image: {
|
|
174
|
+
type: "Image",
|
|
175
|
+
config: { label: "Image", constraint: {}, thumbnails: [] },
|
|
176
|
+
},
|
|
177
|
+
title: {
|
|
178
|
+
type: "StructuredText",
|
|
179
|
+
config: {
|
|
180
|
+
label: "title",
|
|
181
|
+
placeholder: "",
|
|
182
|
+
allowTargetBlank: true,
|
|
183
|
+
single: "heading1,heading2,heading3,heading4,heading5,heading6",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
paragraph: {
|
|
187
|
+
type: "StructuredText",
|
|
188
|
+
config: {
|
|
189
|
+
label: "paragraph",
|
|
190
|
+
placeholder: "",
|
|
191
|
+
allowTargetBlank: true,
|
|
192
|
+
single:
|
|
193
|
+
"paragraph,preformatted,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
buttonlink: {
|
|
197
|
+
type: "Link",
|
|
198
|
+
config: {
|
|
199
|
+
label: "buttonLink",
|
|
200
|
+
placeholder: "Redirect URL for CTA button",
|
|
201
|
+
allowTargetBlank: true,
|
|
202
|
+
select: null,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
buttonLabel: {
|
|
206
|
+
type: "Text",
|
|
207
|
+
config: {
|
|
208
|
+
label: "buttonLabel",
|
|
209
|
+
placeholder: "Label for CTA button",
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
items: {},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: "alignLeft",
|
|
217
|
+
name: "AlignLeft",
|
|
218
|
+
docURL: "...",
|
|
219
|
+
version: "initial",
|
|
220
|
+
description: "Default",
|
|
221
|
+
imageUrl: "",
|
|
222
|
+
primary: {
|
|
223
|
+
image: {
|
|
224
|
+
type: "Image",
|
|
225
|
+
config: { label: "Image", constraint: {}, thumbnails: [] },
|
|
226
|
+
},
|
|
227
|
+
title: {
|
|
228
|
+
type: "StructuredText",
|
|
229
|
+
config: {
|
|
230
|
+
label: "title",
|
|
231
|
+
placeholder: "",
|
|
232
|
+
allowTargetBlank: true,
|
|
233
|
+
single: "heading1,heading2,heading3,heading4,heading5,heading6",
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
paragraph: {
|
|
237
|
+
type: "StructuredText",
|
|
238
|
+
config: {
|
|
239
|
+
label: "paragraph",
|
|
240
|
+
placeholder: "",
|
|
241
|
+
allowTargetBlank: true,
|
|
242
|
+
single:
|
|
243
|
+
"paragraph,preformatted,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
buttonlink: {
|
|
247
|
+
type: "Link",
|
|
248
|
+
config: {
|
|
249
|
+
label: "buttonLink",
|
|
250
|
+
placeholder: "Redirect URL for CTA button",
|
|
251
|
+
allowTargetBlank: true,
|
|
252
|
+
select: null,
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
buttonLabel: {
|
|
256
|
+
type: "Text",
|
|
257
|
+
config: {
|
|
258
|
+
label: "buttonLabel",
|
|
259
|
+
placeholder: "Label for CTA button",
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
items: {},
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export const screenshotPaths = {
|
|
269
|
+
default: ["CallToAction", "screenshot-default.png"].join("/"),
|
|
270
|
+
alignLeft: ["CallToAction", "screenshot-alignLeft.png"].join("/"),
|
|
271
|
+
};
|