@schalkneethling/miyagi-core 4.4.2 → 4.4.3
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/README.md +7 -2
- package/api/app.js +16 -16
- package/api/index.js +263 -262
- package/bin/miyagi.js +1 -1
- package/dist/css/iframe.css +6 -30
- package/frontend/assets/css/iframe/accordion-tabs.css +39 -39
- package/frontend/assets/css/iframe/jsontree.js.css +149 -149
- package/frontend/assets/css/iframe/prism.css +45 -45
- package/frontend/assets/css/iframe/styleguide/colors.css +27 -27
- package/frontend/assets/css/iframe/styleguide/fonts.css +23 -23
- package/frontend/assets/css/iframe/styleguide/index.css +58 -58
- package/frontend/assets/css/iframe/styleguide/spacings.css +10 -10
- package/frontend/assets/css/iframe.css +191 -191
- package/frontend/assets/css/main/menu/config-switcher.css +21 -21
- package/frontend/assets/css/main/menu/config-switchers.css +34 -34
- package/frontend/assets/css/main/menu/goto.css +16 -16
- package/frontend/assets/css/main/menu/nav.css +49 -49
- package/frontend/assets/css/main/menu/search.css +34 -34
- package/frontend/assets/css/main/menu/title.css +18 -18
- package/frontend/assets/css/main/menu.css +89 -89
- package/frontend/assets/css/main/reset.css +47 -47
- package/frontend/assets/css/main.css +41 -41
- package/frontend/assets/css/shared.css +16 -16
- package/frontend/assets/css/tokens.css +108 -107
- package/frontend/assets/js/_accordion-tabs.js +392 -392
- package/frontend/assets/js/_goto.js +59 -59
- package/frontend/assets/js/_iframe-links.js +14 -14
- package/frontend/assets/js/_is-triggered.js +3 -3
- package/frontend/assets/js/_main.js +369 -369
- package/frontend/assets/js/_mock-data.js +8 -8
- package/frontend/assets/js/_prism.js +1082 -1081
- package/frontend/assets/js/_search.js +186 -186
- package/frontend/assets/js/_socket.js +44 -44
- package/frontend/assets/js/config-switcher/development-mode.js +38 -38
- package/frontend/assets/js/config-switcher/index.js +55 -55
- package/frontend/assets/js/config-switcher/text-direction.js +22 -22
- package/frontend/assets/js/config-switcher/theme.js +68 -68
- package/frontend/assets/js/iframe.build.js +25 -25
- package/frontend/assets/js/iframe.js +38 -38
- package/frontend/assets/js/jsontree.js +979 -976
- package/frontend/assets/js/main.build.js +29 -29
- package/frontend/assets/js/main.js +31 -31
- package/frontend/assets/js/styleguide/color-converter.js +652 -652
- package/frontend/assets/js/styleguide/index.js +100 -100
- package/lib/build/index.js +1014 -1020
- package/lib/cli/app.js +16 -16
- package/lib/cli/component.js +50 -50
- package/lib/cli/doctor.js +130 -121
- package/lib/cli/drupal-assets.js +163 -157
- package/lib/cli/lint.js +196 -196
- package/lib/cli/run.js +150 -146
- package/lib/config.js +86 -86
- package/lib/constants/lint-log-levels.js +6 -6
- package/lib/drupal/load-assets-config.js +59 -60
- package/lib/drupal/resolve-library-assets.js +132 -141
- package/lib/errors.js +20 -20
- package/lib/generator/component.js +124 -124
- package/lib/generator/mocks.js +156 -156
- package/lib/helpers.js +68 -68
- package/lib/i18n/en.js +93 -93
- package/lib/i18n/index.js +8 -8
- package/lib/index.js +13 -13
- package/lib/init/args.js +153 -153
- package/lib/init/config.js +452 -438
- package/lib/init/engines.js +41 -41
- package/lib/init/index.js +83 -83
- package/lib/init/rendering.js +3 -3
- package/lib/init/static.js +90 -90
- package/lib/init/twing/cache.js +27 -27
- package/lib/init/twing/functions.js +37 -37
- package/lib/init/views.js +5 -5
- package/lib/logger.js +72 -72
- package/lib/mocks/get.js +88 -88
- package/lib/mocks/index.js +2 -2
- package/lib/mocks/resolve/ref.js +447 -447
- package/lib/mocks/resolve/tpl.js +218 -218
- package/lib/mocks/resolve.js +154 -154
- package/lib/render/helpers/resolve-assets.js +29 -39
- package/lib/render/helpers.js +27 -27
- package/lib/render/index.js +18 -18
- package/lib/render/views/iframe/component.docs.js +50 -50
- package/lib/render/views/iframe/component.js +249 -248
- package/lib/render/views/iframe/design-tokens/colors.js +38 -38
- package/lib/render/views/iframe/design-tokens/index.js +3 -3
- package/lib/render/views/iframe/design-tokens/sizes.js +35 -35
- package/lib/render/views/iframe/design-tokens/typography.js +37 -37
- package/lib/render/views/iframe/docs.js +42 -42
- package/lib/render/views/iframe/index.js +28 -28
- package/lib/render/views/iframe/variation.js +89 -89
- package/lib/render/views/iframe/variation.standalone.js +69 -68
- package/lib/render/views/main/component.docs.js +38 -38
- package/lib/render/views/main/component.js +55 -55
- package/lib/render/views/main/design-tokens.js +38 -38
- package/lib/render/views/main/docs.js +33 -33
- package/lib/render/views/main/index.js +33 -33
- package/lib/state/components.js +99 -99
- package/lib/state/css.js +33 -33
- package/lib/state/docs.js +72 -72
- package/lib/state/file-contents.js +154 -154
- package/lib/state/helpers.js +53 -53
- package/lib/state/index.js +39 -39
- package/lib/state/menu/index.js +202 -202
- package/lib/state/menu/structure.js +84 -84
- package/lib/state/partials.js +12 -12
- package/lib/state/source-tree.js +51 -51
- package/lib/styleguide/color-names.js +148 -148
- package/lib/styleguide/colors.js +113 -113
- package/lib/styleguide/helpers.js +33 -33
- package/lib/styleguide/index.js +4 -4
- package/lib/styleguide/media-queries.js +18 -18
- package/lib/styleguide/spacings.js +22 -22
- package/lib/styleguide/typography.js +46 -46
- package/lib/validator/mocks.js +110 -83
- package/lib/validator/schemas.js +236 -227
- package/package.json +118 -117
|
@@ -18,105 +18,105 @@ import log from "../../../logger.js";
|
|
|
18
18
|
* @param {boolean} [object.noCli]
|
|
19
19
|
*/
|
|
20
20
|
export default async function renderIframeComponent({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
res,
|
|
22
|
+
component,
|
|
23
|
+
cb,
|
|
24
|
+
cookies,
|
|
25
|
+
noCli,
|
|
26
26
|
}) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
const hasTemplate =
|
|
28
|
+
component.paths.tpl &&
|
|
29
|
+
Object.values(global.state.partials).includes(component.paths.tpl.full);
|
|
30
|
+
const componentJson = (await getComponentData(component)) || [];
|
|
31
|
+
const componentDocumentation =
|
|
32
|
+
global.state.fileContents[path.join(component.paths.dir.full, "README.md")];
|
|
33
|
+
const componentSchema =
|
|
34
|
+
global.state.fileContents[component.paths.schema.full];
|
|
35
|
+
const componentTemplate = hasTemplate
|
|
36
|
+
? global.state.fileContents[component.paths.tpl.full]
|
|
37
|
+
: null;
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
let mockFilePath;
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
const defaultMockDataPath = component.paths.mocks.full(
|
|
42
|
+
global.config.files.mocks.extension[0],
|
|
43
|
+
);
|
|
44
|
+
const jsMockDataPath = component.paths.mocks.full(
|
|
45
|
+
global.config.files.mocks.extension[1],
|
|
46
|
+
);
|
|
47
|
+
const jsMockData = global.state.fileContents[jsMockDataPath];
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
if (jsMockData) {
|
|
50
|
+
mockFilePath = jsMockDataPath;
|
|
51
|
+
} else {
|
|
52
|
+
mockFilePath = defaultMockDataPath;
|
|
53
|
+
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
const componentMocks = global.state.fileContents[mockFilePath];
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
let componentSchemaString;
|
|
58
|
+
if (componentSchema) {
|
|
59
|
+
if (["yaml", "yml"].includes(global.config.files.schema.extension)) {
|
|
60
|
+
componentSchemaString = jsonToYaml.dump(componentSchema);
|
|
61
|
+
} else {
|
|
62
|
+
componentSchemaString = JSON.stringify(componentSchema, null, 2);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
let componentMocksString;
|
|
67
|
+
if (componentMocks) {
|
|
68
|
+
if (["yaml", "yml"].includes(global.config.files.mocks.extension[0])) {
|
|
69
|
+
componentMocksString = jsonToYaml.dump(componentMocks);
|
|
70
|
+
} else {
|
|
71
|
+
componentMocksString = JSON.stringify(componentMocks, null, 2);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
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
|
-
|
|
75
|
+
const fileContents = {
|
|
76
|
+
schema: componentSchema
|
|
77
|
+
? {
|
|
78
|
+
string: componentSchemaString,
|
|
79
|
+
type: global.config.files.schema.extension,
|
|
80
|
+
file: path.join(
|
|
81
|
+
global.config.components.folder,
|
|
82
|
+
component.paths.schema.short,
|
|
83
|
+
),
|
|
84
|
+
}
|
|
85
|
+
: null,
|
|
86
|
+
mocks: componentMocks
|
|
87
|
+
? {
|
|
88
|
+
string: componentMocksString,
|
|
89
|
+
type: global.config.files.mocks.extension[0],
|
|
90
|
+
file: path.join(
|
|
91
|
+
global.config.components.folder,
|
|
92
|
+
helpers.getShortPathFromFullPath(mockFilePath),
|
|
93
|
+
),
|
|
94
|
+
}
|
|
95
|
+
: null,
|
|
96
|
+
template: componentTemplate
|
|
97
|
+
? {
|
|
98
|
+
string: componentTemplate,
|
|
99
|
+
type: global.config.files.templates.extension,
|
|
100
|
+
file: path.join(
|
|
101
|
+
global.config.components.folder,
|
|
102
|
+
helpers.getShortPathFromFullPath(component.paths.tpl.full),
|
|
103
|
+
),
|
|
104
|
+
}
|
|
105
|
+
: null,
|
|
106
|
+
};
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
await renderVariations({
|
|
109
|
+
res,
|
|
110
|
+
component,
|
|
111
|
+
context: componentJson.filter((entry) => entry !== null),
|
|
112
|
+
componentDocumentation,
|
|
113
|
+
fileContents,
|
|
114
|
+
name: component.name,
|
|
115
|
+
cb,
|
|
116
|
+
templateFilePath: hasTemplate ? component.paths.tpl.full : null,
|
|
117
|
+
cookies,
|
|
118
|
+
noCli,
|
|
119
|
+
});
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
@@ -153,138 +153,139 @@ export default async function renderIframeComponent({
|
|
|
153
153
|
* @returns {Promise}
|
|
154
154
|
*/
|
|
155
155
|
async function renderVariations({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
res,
|
|
157
|
+
component,
|
|
158
|
+
context,
|
|
159
|
+
componentDocumentation,
|
|
160
|
+
fileContents,
|
|
161
|
+
name,
|
|
162
|
+
cb,
|
|
163
|
+
templateFilePath,
|
|
164
|
+
cookies,
|
|
165
|
+
noCli,
|
|
166
166
|
}) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
const variations = [];
|
|
168
|
+
const promises = [];
|
|
169
|
+
const validatedMocks = validateMocks(component, context, noCli);
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
if (templateFilePath) {
|
|
172
|
+
if (context.length > 0) {
|
|
173
|
+
for (let i = 0, len = context.length; i < len; i += 1) {
|
|
174
|
+
const entry = context[i];
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
variations[i] = getData(
|
|
177
|
+
context[i].name,
|
|
178
|
+
component.paths.dir.short,
|
|
179
|
+
entry,
|
|
180
|
+
validatedMocks,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
promises.push(Promise.resolve());
|
|
186
|
+
}
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
let schemaJson;
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
if (fileContents?.schema?.string) {
|
|
191
|
+
try {
|
|
192
|
+
schemaJson = JSON.stringify(jsonToYaml.load(fileContents.schema.string));
|
|
193
|
+
} catch (err) {
|
|
194
|
+
log("error", null, err);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
let mocksJson;
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
if (fileContents?.mocks?.string) {
|
|
201
|
+
try {
|
|
202
|
+
mocksJson = JSON.stringify(jsonToYaml.load(fileContents.mocks.string));
|
|
203
|
+
} catch (err) {
|
|
204
|
+
log("error", null, err);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
208
|
+
return Promise.all(promises)
|
|
209
|
+
.then(async () => {
|
|
210
|
+
const themeMode = getThemeMode(cookies);
|
|
211
|
+
const renderFileTabs = !!(
|
|
212
|
+
fileContents.schema ||
|
|
213
|
+
fileContents.mocks ||
|
|
214
|
+
fileContents.template
|
|
215
|
+
);
|
|
216
|
+
const componentsEntry = global.state.components.find(
|
|
217
|
+
({ shortPath }) => shortPath === component.paths.dir.short,
|
|
218
|
+
);
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
const componentDeclaredAssets =
|
|
221
|
+
context.length > 0 ? context[0].$assets || null : null;
|
|
222
|
+
const { cssFiles, jsFilesHead, jsFilesBody } = resolveAssets(
|
|
223
|
+
componentDeclaredAssets,
|
|
224
|
+
);
|
|
224
225
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
226
|
+
await res.render(
|
|
227
|
+
"iframe_component.twig.miyagi",
|
|
228
|
+
{
|
|
229
|
+
lang: global.config.ui.lang,
|
|
230
|
+
variations,
|
|
231
|
+
cssFiles,
|
|
232
|
+
jsFilesHead,
|
|
233
|
+
jsFilesBody,
|
|
234
|
+
assets: {
|
|
235
|
+
css: componentsEntry
|
|
236
|
+
? componentsEntry.assets.css
|
|
237
|
+
? path.join("/", componentsEntry.assets.css)
|
|
238
|
+
: false
|
|
239
|
+
: false,
|
|
240
|
+
js: componentsEntry
|
|
241
|
+
? componentsEntry.assets.js
|
|
242
|
+
? path.join("/", componentsEntry.assets.js)
|
|
243
|
+
: false
|
|
244
|
+
: false,
|
|
245
|
+
},
|
|
246
|
+
miyagiDev: !!process.env.MIYAGI_DEVELOPMENT,
|
|
247
|
+
prod: process.env.NODE_ENV === "production",
|
|
248
|
+
projectName: config.projectName,
|
|
249
|
+
userProjectName: global.config.projectName,
|
|
250
|
+
isBuild: global.config.isBuild,
|
|
251
|
+
userUiConfig: getUserUiConfig(cookies),
|
|
252
|
+
theme: themeMode
|
|
253
|
+
? Object.assign(global.config.ui.theme, { mode: themeMode })
|
|
254
|
+
: global.config.ui.theme,
|
|
255
|
+
documentation: componentDocumentation,
|
|
256
|
+
schema: schemaJson,
|
|
257
|
+
schemaError:
|
|
258
|
+
validatedMocks?.length > 0 && validatedMocks[0].type === "schema"
|
|
259
|
+
? validatedMocks[0].data.map((error) => error.message).join("\n")
|
|
260
|
+
: null,
|
|
261
|
+
mocks: mocksJson,
|
|
262
|
+
template: fileContents.template,
|
|
263
|
+
renderInformation: renderFileTabs || variations.length > 0,
|
|
264
|
+
renderFileTabs,
|
|
265
|
+
folder: path.join(
|
|
266
|
+
global.config.components.folder,
|
|
267
|
+
component.paths.dir.short,
|
|
268
|
+
),
|
|
269
|
+
name: componentDocumentation?.includes("<h1>") ? null : name,
|
|
270
|
+
uiTextDirection: global.config.ui.textDirection,
|
|
271
|
+
componentLanguage: global.config.components.lang,
|
|
272
|
+
},
|
|
273
|
+
(html) => {
|
|
274
|
+
if (res.send) {
|
|
275
|
+
res.send(html);
|
|
276
|
+
}
|
|
276
277
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
278
|
+
if (cb) {
|
|
279
|
+
cb(null, html);
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
);
|
|
283
|
+
})
|
|
284
|
+
.catch(() => {
|
|
285
|
+
if (cb) {
|
|
286
|
+
cb(true);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
288
289
|
}
|
|
289
290
|
|
|
290
291
|
/**
|
|
@@ -295,46 +296,46 @@ async function renderVariations({
|
|
|
295
296
|
* @returns {object}
|
|
296
297
|
*/
|
|
297
298
|
function getData(variation, shortPath, entry, validatedMocks) {
|
|
298
|
-
|
|
299
|
+
let standaloneUrl;
|
|
299
300
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
301
|
+
if (global.config.isBuild) {
|
|
302
|
+
standaloneUrl = `component-${helpers.normalizeString(
|
|
303
|
+
shortPath,
|
|
304
|
+
)}-variation-${helpers.normalizeString(variation)}.html`;
|
|
305
|
+
} else {
|
|
306
|
+
standaloneUrl = `/component?file=${shortPath}&variation=${encodeURIComponent(
|
|
307
|
+
variation,
|
|
308
|
+
)}`;
|
|
309
|
+
}
|
|
309
310
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
311
|
+
const data = {
|
|
312
|
+
url: global.config.isBuild
|
|
313
|
+
? `component-${helpers.normalizeString(
|
|
314
|
+
shortPath,
|
|
315
|
+
)}-variation-${helpers.normalizeString(variation)}-embedded.html`
|
|
316
|
+
: `/component?file=${shortPath}&variation=${variation}&embedded=true`,
|
|
317
|
+
file: shortPath,
|
|
318
|
+
variation,
|
|
319
|
+
normalizedVariation: helpers.normalizeString(variation),
|
|
320
|
+
standaloneUrl,
|
|
321
|
+
mockData: JSON.stringify(entry.raw),
|
|
322
|
+
mockDataResolved: JSON.stringify(entry.resolved),
|
|
323
|
+
};
|
|
323
324
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
const validationEntry = validatedMocks?.find(
|
|
326
|
+
(item) => item.variant === entry.name,
|
|
327
|
+
);
|
|
327
328
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
329
|
+
if (validationEntry) {
|
|
330
|
+
data.mockValidation = {
|
|
331
|
+
valid: false,
|
|
332
|
+
copy: t("validator.mocks.invalid"),
|
|
333
|
+
};
|
|
334
|
+
} else {
|
|
335
|
+
data.mockValidation = {
|
|
336
|
+
valid: true,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
338
339
|
|
|
339
|
-
|
|
340
|
+
return data;
|
|
340
341
|
}
|
|
@@ -9,44 +9,44 @@ import { getColors, getMediaQueries } from "../../../../styleguide/index.js";
|
|
|
9
9
|
* @param {object} o.cookies
|
|
10
10
|
*/
|
|
11
11
|
export default async function ({ res, cb, cookies }) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
const colors = global.state.css
|
|
13
|
+
? getColors(
|
|
14
|
+
global.state.css,
|
|
15
|
+
global.config.assets.customProperties.prefixes.color,
|
|
16
|
+
)
|
|
17
|
+
: [];
|
|
18
|
+
const mediaQueries = global.state.css
|
|
19
|
+
? getMediaQueries(global.state.css)
|
|
20
|
+
: [];
|
|
21
|
+
const themeMode = getThemeMode(cookies);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
await res.render(
|
|
24
|
+
"design-tokens/colors.twig.miyagi",
|
|
25
|
+
{
|
|
26
|
+
additionalCssFiles: global.config.assets?.customProperties?.files || [],
|
|
27
|
+
colors:
|
|
28
|
+
colors.map(({ styles }) => styles.length).reduce((a, b) => a + b, 0) > 0
|
|
29
|
+
? colors
|
|
30
|
+
: [],
|
|
31
|
+
isBuild: global.config.isBuild,
|
|
32
|
+
lang: global.config.ui.lang,
|
|
33
|
+
mediaQueries,
|
|
34
|
+
miyagiDev: !!process.env.MIYAGI_DEVELOPMENT,
|
|
35
|
+
projectName: config.projectName,
|
|
36
|
+
userUiConfig: getUserUiConfig(cookies),
|
|
37
|
+
theme: themeMode
|
|
38
|
+
? Object.assign(global.config.ui.theme, { mode: themeMode })
|
|
39
|
+
: global.config.ui.theme,
|
|
40
|
+
uiTextDirection: global.config.ui.textDirection,
|
|
41
|
+
},
|
|
42
|
+
(html) => {
|
|
43
|
+
if (res.send) {
|
|
44
|
+
res.send(html);
|
|
45
|
+
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
if (cb) {
|
|
48
|
+
cb(null, html);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
52
|
}
|