@gem-sdk/pages 1.23.0-staging.31 → 1.23.0-staging.322
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/cjs/components/builder/Toolbar.js +338 -152
- package/dist/cjs/components/builder/Toolbox.js +94 -53
- package/dist/cjs/components/builder/toolbar/Onboarding.js +110 -0
- package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +1 -7
- package/dist/cjs/libs/api/get-home-page-props-v2.js +3 -1
- package/dist/cjs/libs/api/get-static-page-props-preview.js +3 -1
- package/dist/cjs/libs/google-fonts.js +6 -1
- package/dist/cjs/libs/helpers/gen-fonts.js +15 -4
- package/dist/cjs/pages/builder.js +43 -41
- package/dist/cjs/pages/collection-detail.js +12 -10
- package/dist/cjs/pages/product-detail.js +18 -16
- package/dist/cjs/pages/static-v2.js +14 -12
- package/dist/cjs/pages/static.js +13 -11
- package/dist/esm/components/builder/Toolbar.js +339 -153
- package/dist/esm/components/builder/Toolbox.js +95 -54
- package/dist/esm/components/builder/toolbar/Onboarding.js +106 -0
- package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +1 -7
- package/dist/esm/libs/api/get-home-page-props-v2.js +4 -2
- package/dist/esm/libs/api/get-static-page-props-preview.js +4 -2
- package/dist/esm/libs/google-fonts.js +6 -1
- package/dist/esm/libs/helpers/gen-fonts.js +15 -4
- package/dist/esm/pages/builder.js +44 -42
- package/dist/esm/pages/collection-detail.js +13 -11
- package/dist/esm/pages/product-detail.js +19 -17
- package/dist/esm/pages/static-v2.js +15 -13
- package/dist/esm/pages/static.js +14 -12
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -12,24 +12,23 @@ var genFonts = require('../../libs/helpers/gen-fonts.js');
|
|
|
12
12
|
var shopifyCdnWithGoogleFonts = require('../../libs/shopify-cdn-with-google-fonts.js');
|
|
13
13
|
|
|
14
14
|
const globalStyleId = 'global-style';
|
|
15
|
-
const globalFontId = 'google-font-builder';
|
|
16
|
-
const fontElementSettingClassName = 'google-font-element';
|
|
17
15
|
const Toolbox = ()=>{
|
|
18
16
|
const matchMutate = core.useMatchMutate();
|
|
19
17
|
const provider = core.useShopStore((s)=>s.provider);
|
|
20
18
|
const changeStorefrontInfo = core.useShopStore((s)=>s.changeStorefrontInfo);
|
|
19
|
+
const setDynamicProduct = core.usePageStore((s)=>s.setDynamicProduct);
|
|
20
|
+
const setDynamicCollection = core.usePageStore((s)=>s.setDynamicCollection);
|
|
21
21
|
const initState = core.useBuilderPreviewStore((s)=>s.initState);
|
|
22
22
|
const state = core.useBuilderPreviewStore((s)=>s.state);
|
|
23
23
|
const initNormalizeState = core.useBuilderPreviewStore((s)=>s.forceChangeState);
|
|
24
24
|
const forceChangeItemProp = core.useBuilderPreviewStore((s)=>s.forceChangeItemProp);
|
|
25
25
|
const changeItemPropByKey = core.useBuilderPreviewStore((s)=>s.changeItemPropByKey);
|
|
26
|
-
const setDynamicProduct = core.useBuilderPreviewStore((s)=>s.setDynamicProduct);
|
|
27
|
-
const setDynamicCollection = core.useBuilderPreviewStore((s)=>s.setDynamicCollection);
|
|
28
26
|
const addItem = core.useBuilderPreviewStore((s)=>s.addItem);
|
|
29
27
|
const moveItem = core.useBuilderPreviewStore((s)=>s.moveItem);
|
|
30
28
|
const removeItem = core.useBuilderPreviewStore((s)=>s.removeItem);
|
|
31
29
|
const addSection = core.useSectionStore((s)=>s.addSection);
|
|
32
30
|
const changeSwatches = core.useShopStore((s)=>s.changeSwatches);
|
|
31
|
+
const updateItemName = core.useBuilderPreviewStore((s)=>s.updateItemName);
|
|
33
32
|
const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
|
|
34
33
|
const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
35
34
|
const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
|
|
@@ -37,11 +36,62 @@ const Toolbox = ()=>{
|
|
|
37
36
|
const fonts = react.useMemo(()=>genFonts.getFontsFromDataBuilder(state), [
|
|
38
37
|
state
|
|
39
38
|
]);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const setFontsToHead = (className, fonts)=>{
|
|
40
|
+
// clear fonts
|
|
41
|
+
if (!fonts?.length) {
|
|
42
|
+
const googleFonts = document.querySelectorAll(`.${className}`);
|
|
43
|
+
googleFonts.forEach((googleFont)=>{
|
|
44
|
+
googleFont.remove();
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// clear fonts not use
|
|
49
|
+
const googleFonts$1 = document.querySelectorAll(`.${className}`);
|
|
50
|
+
googleFonts$1.forEach((googleFont)=>{
|
|
51
|
+
const fontName = googleFont.getAttribute('data-font');
|
|
52
|
+
const variantName = googleFont.getAttribute('data-font-variant');
|
|
53
|
+
if (!fontName || !variantName) {
|
|
54
|
+
googleFont.remove();
|
|
55
|
+
} else {
|
|
56
|
+
const isUse = fonts.find((font)=>font.family == fontName && font.variants.includes(variantName));
|
|
57
|
+
if (!isUse) {
|
|
58
|
+
googleFont.remove();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
// append new fonts
|
|
63
|
+
for (const font of fonts){
|
|
64
|
+
if (font.type !== 'custom') {
|
|
65
|
+
if (font.variants?.length) {
|
|
66
|
+
for (const variant of font.variants){
|
|
67
|
+
const cloneFont = JSON.parse(JSON.stringify(font));
|
|
68
|
+
cloneFont.variants = [
|
|
69
|
+
variant
|
|
70
|
+
]; // set single variant. Fix error reload font when change href other variant
|
|
71
|
+
const fontName = cloneFont.family;
|
|
72
|
+
const variantName = variant;
|
|
73
|
+
const url = googleFonts.createFontUrl([
|
|
74
|
+
cloneFont
|
|
75
|
+
]);
|
|
76
|
+
if (url) {
|
|
77
|
+
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
78
|
+
if (googleFont) {
|
|
79
|
+
continue;
|
|
80
|
+
} else {
|
|
81
|
+
const link = document.createElement('link');
|
|
82
|
+
link.className = className;
|
|
83
|
+
link.dataset.font = fontName;
|
|
84
|
+
link.dataset.fontVariant = variantName;
|
|
85
|
+
link.href = url;
|
|
86
|
+
link.rel = 'stylesheet';
|
|
87
|
+
document.head.appendChild(link);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
45
95
|
// Revalidate all query with key match query/
|
|
46
96
|
const onRevalidateQuery = react.useCallback(()=>{
|
|
47
97
|
matchMutate(/query\//, {
|
|
@@ -77,22 +127,8 @@ const Toolbox = ()=>{
|
|
|
77
127
|
}
|
|
78
128
|
return item;
|
|
79
129
|
});
|
|
80
|
-
const fontUrl = googleFonts.createFontUrl(font);
|
|
81
130
|
const globalStyle = document.getElementById(globalStyleId);
|
|
82
|
-
|
|
83
|
-
if (fontUrl) {
|
|
84
|
-
if (googleFont) {
|
|
85
|
-
if (googleFont.getAttribute('href') !== fontUrl) {
|
|
86
|
-
googleFont.setAttribute('href', fontUrl);
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
const link = document.createElement('link');
|
|
90
|
-
link.id = globalFontId;
|
|
91
|
-
link.href = fontUrl;
|
|
92
|
-
link.rel = 'stylesheet';
|
|
93
|
-
document.head.appendChild(link);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
131
|
+
setFontsToHead('google-font-builder', font);
|
|
96
132
|
if (globalStyle) {
|
|
97
133
|
globalStyle.innerHTML = themeStyle;
|
|
98
134
|
} else {
|
|
@@ -226,52 +262,54 @@ const Toolbox = ()=>{
|
|
|
226
262
|
changeLayoutSettings
|
|
227
263
|
]);
|
|
228
264
|
const onUpdateCreateThemeSectionCount = react.useCallback((e)=>{
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
changeCreateThemeSectionCount(
|
|
265
|
+
const count = e.detail;
|
|
266
|
+
if (!count) return;
|
|
267
|
+
changeCreateThemeSectionCount(count);
|
|
232
268
|
}, [
|
|
233
269
|
changeCreateThemeSectionCount
|
|
234
270
|
]);
|
|
235
271
|
const onUpdateShopPlan = react.useCallback((e)=>{
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
238
|
-
changeShopPlan(
|
|
272
|
+
const shopPlan = e.detail;
|
|
273
|
+
if (!shopPlan) return;
|
|
274
|
+
changeShopPlan(shopPlan);
|
|
239
275
|
}, [
|
|
240
276
|
changeShopPlan
|
|
241
277
|
]);
|
|
242
278
|
const onUpdateDynamicProduct = react.useCallback((e)=>{
|
|
243
|
-
const
|
|
244
|
-
if (!
|
|
245
|
-
setDynamicProduct(
|
|
279
|
+
const product = e.detail;
|
|
280
|
+
if (!product) return;
|
|
281
|
+
setDynamicProduct(product);
|
|
246
282
|
}, [
|
|
247
283
|
setDynamicProduct
|
|
248
284
|
]);
|
|
249
285
|
const onUpdateDynamicCollection = react.useCallback((e)=>{
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
252
|
-
setDynamicCollection(
|
|
286
|
+
const collection = e.detail;
|
|
287
|
+
if (!collection) return;
|
|
288
|
+
setDynamicCollection(collection);
|
|
253
289
|
}, [
|
|
254
290
|
setDynamicCollection
|
|
255
291
|
]);
|
|
256
292
|
react.useEffect(()=>{
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
link.dataset.font = fontId;
|
|
268
|
-
link.href = customFontUrl;
|
|
269
|
-
link.rel = 'stylesheet';
|
|
270
|
-
document.head.appendChild(link);
|
|
271
|
-
}
|
|
293
|
+
if (fonts) {
|
|
294
|
+
setFontsToHead('google-font-element', fonts);
|
|
295
|
+
}
|
|
296
|
+
}, [
|
|
297
|
+
fonts
|
|
298
|
+
]);
|
|
299
|
+
const onUpdateItemName = react.useCallback((e)=>{
|
|
300
|
+
const detail = e.detail;
|
|
301
|
+
if (detail.uid) {
|
|
302
|
+
updateItemName(detail.uid, detail.name || '');
|
|
272
303
|
}
|
|
273
304
|
}, [
|
|
274
|
-
|
|
305
|
+
updateItemName
|
|
306
|
+
]);
|
|
307
|
+
react.useEffect(()=>{
|
|
308
|
+
if (fonts) {
|
|
309
|
+
setFontsToHead('google-font-element', fonts);
|
|
310
|
+
}
|
|
311
|
+
}, [
|
|
312
|
+
fonts
|
|
275
313
|
]);
|
|
276
314
|
react.useEffect(()=>{
|
|
277
315
|
window.addEventListener('update-shop-info', onChangeShopInfo);
|
|
@@ -289,6 +327,7 @@ const Toolbox = ()=>{
|
|
|
289
327
|
window.addEventListener('update-shop-plan', onUpdateShopPlan);
|
|
290
328
|
window.addEventListener('set-dynamic-product', onUpdateDynamicProduct);
|
|
291
329
|
window.addEventListener('set-dynamic-collection', onUpdateDynamicCollection);
|
|
330
|
+
window.addEventListener('update-item-name', onUpdateItemName);
|
|
292
331
|
return ()=>{
|
|
293
332
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
294
333
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -304,6 +343,7 @@ const Toolbox = ()=>{
|
|
|
304
343
|
window.removeEventListener('update-shop-plan', onUpdateShopPlan);
|
|
305
344
|
window.removeEventListener('set-dynamic-product', onUpdateDynamicProduct);
|
|
306
345
|
window.removeEventListener('set-dynamic-collection', onUpdateDynamicCollection);
|
|
346
|
+
window.removeEventListener('update-item-name', onUpdateItemName);
|
|
307
347
|
};
|
|
308
348
|
}, [
|
|
309
349
|
onAddEntity,
|
|
@@ -320,7 +360,8 @@ const Toolbox = ()=>{
|
|
|
320
360
|
onChangeLayoutSettingData,
|
|
321
361
|
onUpdateCreateThemeSectionCount,
|
|
322
362
|
onUpdateDynamicProduct,
|
|
323
|
-
onUpdateDynamicCollection
|
|
363
|
+
onUpdateDynamicCollection,
|
|
364
|
+
onUpdateItemName
|
|
324
365
|
]);
|
|
325
366
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
326
367
|
className: "toolbox"
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
|
|
8
|
+
const Onboarding = ({ enable, position, onCloseOnboarding })=>{
|
|
9
|
+
const closeOnboarding = ()=>{
|
|
10
|
+
onCloseOnboarding();
|
|
11
|
+
};
|
|
12
|
+
const videoSrc = 'https://ucarecdn.com/de5fd2eb-4525-45a7-ad13-53960dac225e/';
|
|
13
|
+
const Video = ()=>{
|
|
14
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("video", {
|
|
15
|
+
width: "100%",
|
|
16
|
+
className: "w-full",
|
|
17
|
+
loop: true,
|
|
18
|
+
muted: true,
|
|
19
|
+
autoPlay: true,
|
|
20
|
+
playsInline: true,
|
|
21
|
+
children: [
|
|
22
|
+
/*#__PURE__*/ jsxRuntime.jsx("source", {
|
|
23
|
+
src: videoSrc,
|
|
24
|
+
type: "video/mp4"
|
|
25
|
+
}),
|
|
26
|
+
"Sorry, your browser doesn‘t support embedded videos."
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const MemoVideo = /*#__PURE__*/ react.memo(Video);
|
|
31
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
32
|
+
"data-toolbar-onboarding": true,
|
|
33
|
+
"data-toolbar-onboarding-position": position,
|
|
34
|
+
children: enable && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
35
|
+
children: [
|
|
36
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
37
|
+
"data-icon": true,
|
|
38
|
+
"data-position": position,
|
|
39
|
+
children: position === 'bottom' ? /*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
40
|
+
width: "8",
|
|
41
|
+
height: "4",
|
|
42
|
+
viewBox: "0 0 8 4",
|
|
43
|
+
fill: "none",
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
46
|
+
d: "M-1.74846e-07 4L4 -1.74846e-07L8 4L-1.74846e-07 4Z",
|
|
47
|
+
fill: "white"
|
|
48
|
+
})
|
|
49
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
50
|
+
width: "8",
|
|
51
|
+
height: "4",
|
|
52
|
+
viewBox: "0 0 8 4",
|
|
53
|
+
fill: "none",
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
55
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
56
|
+
d: "M8 3.33818e-07L4 4L4.76995e-08 7.15256e-07L8 3.33818e-07Z",
|
|
57
|
+
fill: "white"
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
62
|
+
"data-onboarding-wrapper": true,
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
65
|
+
"data-close": true,
|
|
66
|
+
type: "button",
|
|
67
|
+
onClick: closeOnboarding,
|
|
68
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
69
|
+
width: "32",
|
|
70
|
+
height: "32",
|
|
71
|
+
viewBox: "0 0 32 32",
|
|
72
|
+
fill: "none",
|
|
73
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
76
|
+
fillRule: "evenodd",
|
|
77
|
+
clipRule: "evenodd",
|
|
78
|
+
d: "M10.6464 10.6464C10.8417 10.4512 11.1583 10.4512 11.3536 10.6464L21.3536 20.6464C21.5488 20.8417 21.5488 21.1583 21.3536 21.3536C21.1583 21.5488 20.8417 21.5488 20.6464 21.3536L10.6464 11.3536C10.4512 11.1583 10.4512 10.8417 10.6464 10.6464Z",
|
|
79
|
+
fill: "#212121"
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
82
|
+
fillRule: "evenodd",
|
|
83
|
+
clipRule: "evenodd",
|
|
84
|
+
d: "M21.3536 10.6464C21.5488 10.8417 21.5488 11.1583 21.3536 11.3536L11.3536 21.3536C11.1583 21.5488 10.8417 21.5488 10.6464 21.3536C10.4512 21.1583 10.4512 20.8417 10.6464 20.6464L20.6464 10.6464C20.8417 10.4512 21.1583 10.4512 21.3536 10.6464Z",
|
|
85
|
+
fill: "#212121"
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ jsxRuntime.jsx(MemoVideo, {}),
|
|
91
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
92
|
+
"data-content": true,
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsxRuntime.jsx("h3", {
|
|
95
|
+
children: "New way to select parent element"
|
|
96
|
+
}),
|
|
97
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
98
|
+
children: "Select parent from here in case you can‘t find yours at times."
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
var Onboarding$1 = /*#__PURE__*/ react.memo(Onboarding);
|
|
109
|
+
|
|
110
|
+
exports.default = Onboarding$1;
|
|
@@ -37,11 +37,6 @@ const AddSectionImageToLayout = ({ editorImageToLayout })=>{
|
|
|
37
37
|
const totalSection = core.useBuilderPreviewStore((state)=>state.state.ROOT.childrens?.length);
|
|
38
38
|
const [link, setLink] = react.useState('');
|
|
39
39
|
const [isInput, setIsInput] = react.useState(false);
|
|
40
|
-
const onClick = (index)=>{
|
|
41
|
-
if (index === 1) {
|
|
42
|
-
setIsInput(true);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
40
|
react.useEffect(()=>{
|
|
46
41
|
if (!isInput || totalSection === 0) {
|
|
47
42
|
setLink('');
|
|
@@ -82,11 +77,10 @@ const AddSectionImageToLayout = ({ editorImageToLayout })=>{
|
|
|
82
77
|
className: "absolute top-[-12px] bg-white px-[8px] text-[14px] font-normal text-[#9E9E9E]",
|
|
83
78
|
children: "Add section"
|
|
84
79
|
}),
|
|
85
|
-
ACTIONS_DATA.map((action
|
|
80
|
+
ACTIONS_DATA.map((action)=>{
|
|
86
81
|
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
87
82
|
className: `relative mx-1 h-[60px] w-[172px] cursor-pointer flex-col items-center justify-center rounded-[3px] bg-[#F4F4F4] hover:bg-black/10 ${isInput ? 'hidden' : 'flex'}`,
|
|
88
83
|
id: action.id,
|
|
89
|
-
onClick: ()=>onClick(index),
|
|
90
84
|
"aria-hidden": true,
|
|
91
85
|
children: [
|
|
92
86
|
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
@@ -35,7 +35,8 @@ const getHomePagePropsV2 = (fetcher, shopifyFetcher)=>async ()=>{
|
|
|
35
35
|
throw new Error(`No data builder found for Home page`);
|
|
36
36
|
}
|
|
37
37
|
const homeTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
|
|
38
|
-
const [fontStyle, fallback] = await Promise.all([
|
|
38
|
+
const [elementFontStyle, fontStyle, fallback] = await Promise.all([
|
|
39
|
+
googleFonts.getFontStyleFromPageTemplate(homeTemplate),
|
|
39
40
|
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
40
41
|
getFallback.getFallbackV2(fetcher, homeTemplate)
|
|
41
42
|
]);
|
|
@@ -115,6 +116,7 @@ const getHomePagePropsV2 = (fetcher, shopifyFetcher)=>async ()=>{
|
|
|
115
116
|
return parseJson.serializableJson({
|
|
116
117
|
themeStyle: genCss.genCSS(dataBuilder?.pageStyle?.data, mobileOnly),
|
|
117
118
|
fontStyle,
|
|
119
|
+
elementFontStyle,
|
|
118
120
|
builderData: homeTemplate,
|
|
119
121
|
swr: {
|
|
120
122
|
fallback
|
|
@@ -38,7 +38,8 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
38
38
|
throw new Error(`No data builder found for slug: /preview/${slug}`);
|
|
39
39
|
}
|
|
40
40
|
const pageTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
|
|
41
|
-
const [fontStyle, fallback] = await Promise.all([
|
|
41
|
+
const [elementFontStyle, fontStyle, fallback] = await Promise.all([
|
|
42
|
+
googleFonts.getFontStyleFromPageTemplate(pageTemplate),
|
|
42
43
|
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
43
44
|
getFallback.getFallbackV2(fetcher, pageTemplate)
|
|
44
45
|
]);
|
|
@@ -120,6 +121,7 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
120
121
|
return parseJson.serializableJson({
|
|
121
122
|
themeStyle: genCss.genCSS(dataBuilder?.pageStyle?.data, mobileOnly),
|
|
122
123
|
fontStyle,
|
|
124
|
+
elementFontStyle,
|
|
123
125
|
builderData: pageTemplate,
|
|
124
126
|
pageType,
|
|
125
127
|
moneyFormat: shopMeta?.shop.moneyFormat ?? null,
|
|
@@ -9,7 +9,12 @@ async function getFontForUA(url, UA) {
|
|
|
9
9
|
headers: {
|
|
10
10
|
'User-Agent': UA
|
|
11
11
|
}
|
|
12
|
-
}).then((res)=>
|
|
12
|
+
}).then((res)=>{
|
|
13
|
+
if (res.status === 200) {
|
|
14
|
+
return res.text();
|
|
15
|
+
}
|
|
16
|
+
return '';
|
|
17
|
+
});
|
|
13
18
|
}
|
|
14
19
|
const composeFonts = (fonts)=>{
|
|
15
20
|
const uniqFonts = fonts.filter((font, index, arr)=>{
|
|
@@ -19,7 +19,12 @@ const getFontFromGroupSetting = (fonts, groupSetting)=>{
|
|
|
19
19
|
const value = groupSetting[attr];
|
|
20
20
|
if (value) {
|
|
21
21
|
const customFontFamily = value.custom?.fontFamily;
|
|
22
|
-
|
|
22
|
+
let customFontVariants = value.custom?.fontVariants;
|
|
23
|
+
if (!customFontVariants?.length) {
|
|
24
|
+
customFontVariants = [
|
|
25
|
+
value.custom?.fontWeight
|
|
26
|
+
];
|
|
27
|
+
}
|
|
23
28
|
if (customFontFamily && customFontVariants?.length) {
|
|
24
29
|
const variants = customFontVariants.map((item)=>{
|
|
25
30
|
switch(item){
|
|
@@ -36,11 +41,17 @@ const getFontFromGroupSetting = (fonts, groupSetting)=>{
|
|
|
36
41
|
if (isFontFamily) {
|
|
37
42
|
isFontFamily.variants.push(customFontWeight);
|
|
38
43
|
} else {
|
|
44
|
+
const fontVariants = [
|
|
45
|
+
customFontWeight
|
|
46
|
+
];
|
|
47
|
+
if (customFontWeight !== '700') {
|
|
48
|
+
if (variants.includes('700')) {
|
|
49
|
+
fontVariants.push('700'); // Auto add 700 for bold in editor inline
|
|
50
|
+
}
|
|
51
|
+
}
|
|
39
52
|
fonts.push({
|
|
40
53
|
family: customFontFamily,
|
|
41
|
-
variants:
|
|
42
|
-
customFontWeight
|
|
43
|
-
],
|
|
54
|
+
variants: fontVariants,
|
|
44
55
|
subsets: [],
|
|
45
56
|
type: 'google'
|
|
46
57
|
});
|
|
@@ -14,7 +14,7 @@ var ImageToLayout = require('../components/image-to-layout/ImageToLayout.js');
|
|
|
14
14
|
var AddSectionImageToLayout = require('../components/image-to-layout/AddSectionImageToLayout.js');
|
|
15
15
|
var Toolbar = require('../components/builder/Toolbar.js');
|
|
16
16
|
|
|
17
|
-
const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, pageType, editorImageToLayout, isThemeSectionEditor })=>{
|
|
17
|
+
const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, pageType, editorImageToLayout, isThemeSectionEditor, hiddenToolbar })=>{
|
|
18
18
|
const [loadSuccess, setLoadSuccess] = react.useState(false);
|
|
19
19
|
const initState = react.useMemo(()=>({
|
|
20
20
|
ROOT: {
|
|
@@ -50,48 +50,50 @@ const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, page
|
|
|
50
50
|
})
|
|
51
51
|
]
|
|
52
52
|
}),
|
|
53
|
-
/*#__PURE__*/ jsxRuntime.jsx(core.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(
|
|
53
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.PageProvider, {
|
|
54
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.BuilderComponentProvider, {
|
|
55
|
+
components: components,
|
|
56
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.SectionProvider, {
|
|
57
|
+
data: sectionData,
|
|
58
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(core.BuilderPreviewProvider, {
|
|
59
|
+
state: initState,
|
|
60
|
+
isThemeSectionEditor: isThemeSectionEditor,
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsxRuntime.jsx(Toolbox.default, {}),
|
|
63
|
+
!hiddenToolbar && /*#__PURE__*/ jsxRuntime.jsx(Toolbar.default, {}),
|
|
64
|
+
/*#__PURE__*/ jsxRuntime.jsx(PopupManager.default, {}),
|
|
65
|
+
loadSuccess && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
66
|
+
className: "builder z-1 relative",
|
|
67
|
+
children: [
|
|
68
|
+
!hiddenToolbar && (isThemeSectionEditor ? /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
69
|
+
className: "h-[40px] bg-[#f4f4f4]"
|
|
70
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx(Header.default, {})),
|
|
71
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
72
|
+
id: "storefront",
|
|
73
|
+
className: isThemeSectionEditor ? 'theme-section-editor' : '',
|
|
74
|
+
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
|
|
75
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
76
|
+
uid: "ROOT"
|
|
77
|
+
})
|
|
78
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
75
79
|
uid: "ROOT"
|
|
76
80
|
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
]
|
|
94
|
-
}, "preview")
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ jsxRuntime.jsx(ImageToLayout.default, {
|
|
83
|
+
editorImageToLayout: editorImageToLayout || false
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ jsxRuntime.jsx(AddSectionImageToLayout.default, {
|
|
86
|
+
editorImageToLayout: editorImageToLayout || false
|
|
87
|
+
}),
|
|
88
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
89
|
+
id: "visual-content"
|
|
90
|
+
}),
|
|
91
|
+
!isThemeSectionEditor && !hiddenToolbar && /*#__PURE__*/ jsxRuntime.jsx(Footer.default, {})
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
}, "preview")
|
|
96
|
+
})
|
|
95
97
|
})
|
|
96
98
|
})
|
|
97
99
|
]
|
|
@@ -40,16 +40,18 @@ const CollectionDetailPage = ({ seo, components, builderData, sectionData, theme
|
|
|
40
40
|
})
|
|
41
41
|
]
|
|
42
42
|
}),
|
|
43
|
-
/*#__PURE__*/ jsxRuntime.jsx(core.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.PageProvider, {
|
|
44
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.BuilderComponentProvider, {
|
|
45
|
+
components: components,
|
|
46
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.SectionProvider, {
|
|
47
|
+
data: sectionData,
|
|
48
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(CollectionProvider, {
|
|
49
|
+
collection: collection,
|
|
50
|
+
children: builderData && /*#__PURE__*/ jsxRuntime.jsx(core.BuilderProvider, {
|
|
51
|
+
state: builderData,
|
|
52
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.Render, {
|
|
53
|
+
uid: "ROOT"
|
|
54
|
+
})
|
|
53
55
|
})
|
|
54
56
|
})
|
|
55
57
|
})
|
|
@@ -40,23 +40,25 @@ const ProductDetailPage = ({ themeStyle, fontStyle, seo, product, components, bu
|
|
|
40
40
|
})
|
|
41
41
|
]
|
|
42
42
|
}),
|
|
43
|
-
/*#__PURE__*/ jsxRuntime.jsx(core.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.PageProvider, {
|
|
44
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.BuilderComponentProvider, {
|
|
45
|
+
components: components,
|
|
46
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.SectionProvider, {
|
|
47
|
+
data: sectionData,
|
|
48
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(ProductProvider, {
|
|
49
|
+
product: product,
|
|
50
|
+
children: [
|
|
51
|
+
builderData && /*#__PURE__*/ jsxRuntime.jsx(core.BuilderProvider, {
|
|
52
|
+
state: builderData,
|
|
53
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.Render, {
|
|
54
|
+
uid: "ROOT"
|
|
55
|
+
})
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.AddOn, {
|
|
58
|
+
name: "sticky-add-to-cart"
|
|
54
59
|
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
name: "sticky-add-to-cart"
|
|
58
|
-
})
|
|
59
|
-
]
|
|
60
|
+
]
|
|
61
|
+
})
|
|
60
62
|
})
|
|
61
63
|
})
|
|
62
64
|
})
|