@gem-sdk/pages 1.56.0 → 1.57.0-dev.53
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/Body.js +38 -0
- package/dist/cjs/components/builder/Footer.js +2 -2
- package/dist/cjs/components/builder/Header.js +4 -1
- package/dist/cjs/components/builder/InteractionSelectOnPageHeader.js +191 -0
- package/dist/cjs/components/builder/SwitchView.js +1 -0
- package/dist/cjs/components/builder/Toolbar.js +130 -340
- package/dist/cjs/components/builder/Toolbox.js +69 -2
- package/dist/cjs/components/builder/toolbar/const.js +7 -0
- package/dist/cjs/components/builder/toolbar/utils/findDOMClosest.js +41 -0
- package/dist/cjs/components/builder/toolbar/utils/findOverflowParent.js +20 -0
- package/dist/cjs/components/builder/toolbar/utils/getChildrenByAttrSelector.js +18 -0
- package/dist/cjs/components/builder/toolbar/utils/getDOMElementParents.js +32 -0
- package/dist/cjs/components/builder/toolbar/utils/isOverParent.js +16 -0
- package/dist/cjs/components/builder/toolbar/utils/isOverToolbarPosition.js +12 -0
- package/dist/cjs/components/builder/toolbar/utils/isSection.js +8 -0
- package/dist/cjs/components/builder/toolbar/utils/notVisible.js +8 -0
- package/dist/cjs/components/builder/toolbar/utils/waitForElementToExist.js +27 -0
- package/dist/cjs/components/image-to-layout/DropElement.js +2 -0
- package/dist/cjs/libs/api/get-static-page-props-v2.js +15 -4
- package/dist/cjs/libs/google-fonts.js +20 -11
- package/dist/cjs/libs/helpers/check-option-font.js +65 -0
- package/dist/cjs/pages/builder.js +4 -11
- package/dist/cjs/pages/static-v2.js +18 -5
- package/dist/cjs/store/libs-store.js +14 -0
- package/dist/esm/components/builder/Body.js +34 -0
- package/dist/esm/components/builder/Footer.js +2 -2
- package/dist/esm/components/builder/Header.js +5 -2
- package/dist/esm/components/builder/InteractionSelectOnPageHeader.js +187 -0
- package/dist/esm/components/builder/SwitchView.js +1 -0
- package/dist/esm/components/builder/Toolbar.js +102 -312
- package/dist/esm/components/builder/Toolbox.js +69 -2
- package/dist/esm/components/builder/toolbar/const.js +4 -0
- package/dist/esm/components/builder/toolbar/utils/findDOMClosest.js +39 -0
- package/dist/esm/components/builder/toolbar/utils/findOverflowParent.js +18 -0
- package/dist/esm/components/builder/toolbar/utils/getChildrenByAttrSelector.js +16 -0
- package/dist/esm/components/builder/toolbar/utils/getDOMElementParents.js +30 -0
- package/dist/esm/components/builder/toolbar/utils/isOverParent.js +14 -0
- package/dist/esm/components/builder/toolbar/utils/isOverToolbarPosition.js +10 -0
- package/dist/esm/components/builder/toolbar/utils/isSection.js +6 -0
- package/dist/esm/components/builder/toolbar/utils/notVisible.js +6 -0
- package/dist/esm/components/builder/toolbar/utils/waitForElementToExist.js +25 -0
- package/dist/esm/components/image-to-layout/DropElement.js +2 -0
- package/dist/esm/libs/api/get-static-page-props-v2.js +16 -5
- package/dist/esm/libs/google-fonts.js +20 -11
- package/dist/esm/libs/helpers/check-option-font.js +63 -0
- package/dist/esm/pages/builder.js +5 -12
- package/dist/esm/pages/static-v2.js +18 -5
- package/dist/esm/store/libs-store.js +12 -0
- package/dist/types/index.d.ts +6 -3
- package/package.json +5 -5
- package/dist/cjs/components/builder/toolbar/Onboarding.js +0 -110
- package/dist/esm/components/builder/toolbar/Onboarding.js +0 -106
|
@@ -10,6 +10,8 @@ var googleFonts = require('../../libs/google-fonts.js');
|
|
|
10
10
|
var genCss = require('../../libs/helpers/gen-css.js');
|
|
11
11
|
var genFonts = require('../../libs/helpers/gen-fonts.js');
|
|
12
12
|
var shopifyCdnWithGoogleFonts = require('../../libs/shopify-cdn-with-google-fonts.js');
|
|
13
|
+
var libsStore = require('../../store/libs-store.js');
|
|
14
|
+
var checkOptionFont = require('../../libs/helpers/check-option-font.js');
|
|
13
15
|
|
|
14
16
|
const globalStyleId = 'global-style';
|
|
15
17
|
const Toolbox = ()=>{
|
|
@@ -35,8 +37,15 @@ const Toolbox = ()=>{
|
|
|
35
37
|
const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
|
|
36
38
|
const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
37
39
|
const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
|
|
40
|
+
const changeFontType = libsStore.libsStore((s)=>s.changeFontType);
|
|
41
|
+
const fontType = libsStore.libsStore((s)=>s.fontType);
|
|
38
42
|
const clearModal = core.useModalStore((s)=>s.clearModal);
|
|
39
43
|
const changeLimitCreateThemeSection = core.useShopStore((s)=>s.changeLimitCreateThemeSection);
|
|
44
|
+
const setInteractionIsSelectOnPage = core.usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
45
|
+
const setInteractionItem = core.usePageStore((s)=>s.setInteractionItem);
|
|
46
|
+
const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
|
|
47
|
+
const setInteractionSettingType = core.usePageStore((s)=>s.setInteractionSettingType);
|
|
48
|
+
const setSidebarMode = core.usePageStore((s)=>s.setSidebarMode);
|
|
40
49
|
const fonts = react.useMemo(()=>genFonts.getFontsFromDataBuilder(state), [
|
|
41
50
|
state
|
|
42
51
|
]);
|
|
@@ -65,6 +74,12 @@ const Toolbox = ()=>{
|
|
|
65
74
|
});
|
|
66
75
|
// append new fonts
|
|
67
76
|
for (const font of fonts){
|
|
77
|
+
if ([
|
|
78
|
+
'bunny',
|
|
79
|
+
'google'
|
|
80
|
+
].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
68
83
|
if (font.type !== 'custom') {
|
|
69
84
|
if (font.variants?.length) {
|
|
70
85
|
for (const variant of font.variants){
|
|
@@ -76,7 +91,7 @@ const Toolbox = ()=>{
|
|
|
76
91
|
const variantName = variant;
|
|
77
92
|
const url = googleFonts.createFontUrl([
|
|
78
93
|
cloneFont
|
|
79
|
-
]);
|
|
94
|
+
], undefined, fontType);
|
|
80
95
|
if (url) {
|
|
81
96
|
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
82
97
|
if (googleFont) {
|
|
@@ -279,6 +294,13 @@ const Toolbox = ()=>{
|
|
|
279
294
|
}, [
|
|
280
295
|
changeShopPlan
|
|
281
296
|
]);
|
|
297
|
+
const onUpdateFontType = react.useCallback((e)=>{
|
|
298
|
+
const fontType = e.detail;
|
|
299
|
+
if (!fontType) return;
|
|
300
|
+
changeFontType(fontType);
|
|
301
|
+
}, [
|
|
302
|
+
changeFontType
|
|
303
|
+
]);
|
|
282
304
|
const onUpdateDynamicProduct = react.useCallback((e)=>{
|
|
283
305
|
const product = e.detail;
|
|
284
306
|
if (!product) return;
|
|
@@ -337,6 +359,37 @@ const Toolbox = ()=>{
|
|
|
337
359
|
}, [
|
|
338
360
|
changeLimitCreateThemeSection
|
|
339
361
|
]);
|
|
362
|
+
const onUpdateInteractionIsSelectOnPage = react.useCallback((e)=>{
|
|
363
|
+
const isSelectOnPage = e.detail.value;
|
|
364
|
+
const mode = e.detail.mode;
|
|
365
|
+
const settingType = e.detail.settingType;
|
|
366
|
+
setInteractionIsSelectOnPage(isSelectOnPage);
|
|
367
|
+
setInteractionSelectType(mode);
|
|
368
|
+
setInteractionSettingType(settingType);
|
|
369
|
+
}, [
|
|
370
|
+
setInteractionIsSelectOnPage,
|
|
371
|
+
setInteractionSelectType,
|
|
372
|
+
setInteractionSettingType
|
|
373
|
+
]);
|
|
374
|
+
const onUpdateInteractionSettingType = react.useCallback((e)=>{
|
|
375
|
+
const settingType = e.detail.settingType;
|
|
376
|
+
setInteractionSettingType(settingType);
|
|
377
|
+
}, [
|
|
378
|
+
setInteractionSettingType
|
|
379
|
+
]);
|
|
380
|
+
const onChangeSidebarMode = react.useCallback((e)=>{
|
|
381
|
+
const mode = e.detail.mode;
|
|
382
|
+
console.log(mode);
|
|
383
|
+
setSidebarMode(mode);
|
|
384
|
+
}, [
|
|
385
|
+
setSidebarMode
|
|
386
|
+
]);
|
|
387
|
+
const onUpdateInteractionItem = react.useCallback((e)=>{
|
|
388
|
+
const interactionItem = e.detail;
|
|
389
|
+
setInteractionItem(interactionItem);
|
|
390
|
+
}, [
|
|
391
|
+
setInteractionItem
|
|
392
|
+
]);
|
|
340
393
|
react.useEffect(()=>{
|
|
341
394
|
if (fonts) {
|
|
342
395
|
setFontsToHead('google-font-element', fonts);
|
|
@@ -365,6 +418,11 @@ const Toolbox = ()=>{
|
|
|
365
418
|
window.addEventListener('set-product-offer', onUpdateProductOffers);
|
|
366
419
|
window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
367
420
|
window.addEventListener('limit-create-theme-section', onLimitCreateThemeSection);
|
|
421
|
+
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
422
|
+
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
423
|
+
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
424
|
+
window.addEventListener('change-sidebar-mode', onChangeSidebarMode);
|
|
425
|
+
window.addEventListener('update-font-type', onUpdateFontType);
|
|
368
426
|
return ()=>{
|
|
369
427
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
370
428
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -385,6 +443,10 @@ const Toolbox = ()=>{
|
|
|
385
443
|
window.removeEventListener('set-product-offer', onUpdateProductOffers);
|
|
386
444
|
window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
387
445
|
window.removeEventListener('limit-create-theme-section', onLimitCreateThemeSection);
|
|
446
|
+
window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
447
|
+
window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
448
|
+
window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
449
|
+
window.removeEventListener('update-font-type', onUpdateFontType);
|
|
388
450
|
};
|
|
389
451
|
}, [
|
|
390
452
|
onAddEntity,
|
|
@@ -406,7 +468,12 @@ const Toolbox = ()=>{
|
|
|
406
468
|
onUpdateItemAttribute,
|
|
407
469
|
onUpdateProductOffers,
|
|
408
470
|
onUpdateSalePageProductId,
|
|
409
|
-
onLimitCreateThemeSection
|
|
471
|
+
onLimitCreateThemeSection,
|
|
472
|
+
onUpdateInteractionItem,
|
|
473
|
+
onUpdateInteractionIsSelectOnPage,
|
|
474
|
+
onUpdateInteractionSettingType,
|
|
475
|
+
onUpdateFontType,
|
|
476
|
+
onChangeSidebarMode
|
|
410
477
|
]);
|
|
411
478
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
412
479
|
className: "toolbox"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const findDOMClosest = ($target, selectors)=>{
|
|
4
|
+
const closestElements = {
|
|
5
|
+
$childrenSlot: null,
|
|
6
|
+
$productFeatureImg: null,
|
|
7
|
+
$section: null,
|
|
8
|
+
$component: null,
|
|
9
|
+
$disableIframeClick: null,
|
|
10
|
+
$stickyMinimize: null,
|
|
11
|
+
$toolbar: null,
|
|
12
|
+
$gpText: null,
|
|
13
|
+
$imageDetection: null,
|
|
14
|
+
$popupTriggerButton: null
|
|
15
|
+
};
|
|
16
|
+
let currentElement = $target;
|
|
17
|
+
while(currentElement){
|
|
18
|
+
// Check for stop conditions
|
|
19
|
+
if (currentElement.matches('[data-uid="ROOT"], .builder, #storefront')) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
// Check if currentElement matches any of the selectors
|
|
23
|
+
for (const [key, selector] of Object.entries(selectors)){
|
|
24
|
+
if (!closestElements[key] && currentElement.matches(selector)) {
|
|
25
|
+
closestElements[key] = currentElement;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// If all closest elements are found, break the loop
|
|
29
|
+
if (Object.values(closestElements).every((el)=>el !== null)) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
// Move up to the parent element
|
|
33
|
+
currentElement = currentElement.parentElement;
|
|
34
|
+
}
|
|
35
|
+
// Reset ram
|
|
36
|
+
currentElement = null;
|
|
37
|
+
// Return
|
|
38
|
+
return closestElements;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.findDOMClosest = findDOMClosest;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isOverToolbarPosition = require('./isOverToolbarPosition.js');
|
|
4
|
+
var isSection = require('./isSection.js');
|
|
5
|
+
var notVisible = require('./notVisible.js');
|
|
6
|
+
|
|
7
|
+
const findOverflowParent = (element, initEl)=>{
|
|
8
|
+
const thisEl = element;
|
|
9
|
+
const origEl = initEl || thisEl;
|
|
10
|
+
if (!thisEl) return;
|
|
11
|
+
if (isSection.isSection(thisEl)) return;
|
|
12
|
+
if (notVisible.notVisible(thisEl) && isOverToolbarPosition.isOverToolbarPosition(initEl, thisEl)) return thisEl;
|
|
13
|
+
if (thisEl.parentElement) {
|
|
14
|
+
return findOverflowParent(thisEl.parentElement, origEl);
|
|
15
|
+
} else {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.findOverflowParent = findOverflowParent;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getChildrenByAttrSelector = ($el, attrSelector)=>{
|
|
4
|
+
const childLen = $el.children.length;
|
|
5
|
+
if (childLen) {
|
|
6
|
+
for(let i = 0; i < childLen; i++){
|
|
7
|
+
const children = $el.children[i];
|
|
8
|
+
if (children) {
|
|
9
|
+
const is = children.getAttribute(attrSelector);
|
|
10
|
+
if (is) {
|
|
11
|
+
return children;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.getChildrenByAttrSelector = getChildrenByAttrSelector;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getDOMElementParents = ($el, selector, limit)=>{
|
|
4
|
+
// Set up a parent array
|
|
5
|
+
const parents = [];
|
|
6
|
+
// Push each parent $elms to the array
|
|
7
|
+
while($el){
|
|
8
|
+
$el = $el.parentElement ?? undefined;
|
|
9
|
+
if ($el) {
|
|
10
|
+
if ($el.tagName === 'BODY' || $el.getAttribute('data-uid') === 'ROOT') {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
if (selector) {
|
|
14
|
+
if ($el.matches(selector)) {
|
|
15
|
+
parents.push($el);
|
|
16
|
+
if (limit && parents.length == limit) {
|
|
17
|
+
return parents;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
parents.push($el);
|
|
23
|
+
if (limit && parents.length == limit) {
|
|
24
|
+
return parents;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Return our parent array
|
|
29
|
+
return parents;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.getDOMElementParents = getDOMElementParents;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _const = require('../const.js');
|
|
4
|
+
|
|
5
|
+
const isOverParent = ({ current, parent, index, revert })=>{
|
|
6
|
+
for(let i = 0; i < index; i++){
|
|
7
|
+
let is = current.top - (_const.TOOLBAR_HOVER_HEIGHT - 1) * i >= parent.top && current.top - (_const.TOOLBAR_HOVER_HEIGHT - 1) * i <= parent.top + parent.height || current.top - (_const.TOOLBAR_HOVER_HEIGHT - 1) * i >= parent.top + parent.height && current.top - (_const.TOOLBAR_HOVER_HEIGHT - 1) * i <= parent.top;
|
|
8
|
+
if (revert) {
|
|
9
|
+
is = current.bottom + (_const.TOOLBAR_HOVER_HEIGHT - 1) * i >= parent.bottom && current.bottom + (_const.TOOLBAR_HOVER_HEIGHT - 1) * i <= parent.bottom - parent.height || current.bottom + (_const.TOOLBAR_HOVER_HEIGHT - 1) * i >= parent.bottom - parent.height && current.bottom + (_const.TOOLBAR_HOVER_HEIGHT - 1) * i <= parent.bottom;
|
|
10
|
+
}
|
|
11
|
+
if (is) return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.isOverParent = isOverParent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _const = require('../const.js');
|
|
4
|
+
|
|
5
|
+
const isOverToolbarPosition = (el, parent)=>{
|
|
6
|
+
const rect = el.getBoundingClientRect();
|
|
7
|
+
const rectP = parent.getBoundingClientRect();
|
|
8
|
+
// 32px = toolbar active height
|
|
9
|
+
return rect.top - rectP.top < _const.TOOLBAR_ACTIVE_HEIGHT + 1;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.isOverToolbarPosition = isOverToolbarPosition;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const waitForElementToExist = (selector, timeout = 200)=>{
|
|
4
|
+
return new Promise((resolve)=>{
|
|
5
|
+
let intervalID = null;
|
|
6
|
+
let timeoutID = null;
|
|
7
|
+
const findEl = ()=>{
|
|
8
|
+
const el = document.body.querySelector('#storefront')?.querySelector(selector);
|
|
9
|
+
if (el) {
|
|
10
|
+
if (intervalID) clearInterval(intervalID);
|
|
11
|
+
if (timeoutID) clearTimeout(timeoutID);
|
|
12
|
+
resolve(el);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
findEl();
|
|
16
|
+
intervalID = setInterval(()=>{
|
|
17
|
+
findEl();
|
|
18
|
+
}, 50);
|
|
19
|
+
timeoutID = setTimeout(()=>{
|
|
20
|
+
if (intervalID) clearInterval(intervalID);
|
|
21
|
+
if (timeoutID) clearTimeout(timeoutID);
|
|
22
|
+
resolve(null);
|
|
23
|
+
}, timeout);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.waitForElementToExist = waitForElementToExist;
|
|
@@ -106,11 +106,13 @@ const DropElement = ()=>{
|
|
|
106
106
|
className: "gp-flex gp-w-[291px] gp-justify-between",
|
|
107
107
|
children: [
|
|
108
108
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
109
|
+
"data-button-add-section": true,
|
|
109
110
|
onClick: ()=>dispatchEventBuildWithSectionActiveTab(true),
|
|
110
111
|
className: "gp-flex gp-h-[40px] gp-w-[136px] gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#1C1C1C] gp-text-[14px] gp-text-white hover:gp-bg-[#3B3B3B]",
|
|
111
112
|
children: "Add sections"
|
|
112
113
|
}),
|
|
113
114
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
115
|
+
"data-button-add-elements": true,
|
|
114
116
|
onClick: ()=>dispatchEventBuildWithSectionActiveTab(false),
|
|
115
117
|
className: "gp-flex gp-h-[40px] gp-w-[136px] gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#f4f4f4] gp-text-[14px] gp-text-[#212121] hover:gp-bg-[#E2E2E2]",
|
|
116
118
|
children: "Add elements"
|
|
@@ -18,7 +18,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
18
18
|
slug,
|
|
19
19
|
slugType: pageType
|
|
20
20
|
};
|
|
21
|
-
const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
|
|
21
|
+
const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
|
|
22
22
|
fetcher([
|
|
23
23
|
core.PublishedThemePagesDocument,
|
|
24
24
|
variables
|
|
@@ -28,11 +28,21 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
28
28
|
]),
|
|
29
29
|
shopifyFetcher([
|
|
30
30
|
adapterShopify.ShopMetaDocument
|
|
31
|
+
]),
|
|
32
|
+
fetcher([
|
|
33
|
+
core.PublishedShopMetasDocument,
|
|
34
|
+
{
|
|
35
|
+
keys: [
|
|
36
|
+
'source_font'
|
|
37
|
+
]
|
|
38
|
+
}
|
|
31
39
|
])
|
|
32
40
|
]);
|
|
33
41
|
if (theme.status === 'rejected') {
|
|
34
42
|
throw new Error(theme.reason?.[0]);
|
|
35
43
|
}
|
|
44
|
+
const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
|
|
45
|
+
const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
|
|
36
46
|
const dataBuilder = theme.value.publishedThemePages?.[0];
|
|
37
47
|
const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
|
|
38
48
|
if (!dataBuilder) {
|
|
@@ -40,8 +50,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
40
50
|
}
|
|
41
51
|
const pageTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
|
|
42
52
|
const [elementFontStyle, fontStyle, fallback, customFonts$1] = await Promise.all([
|
|
43
|
-
googleFonts.getFontStyleFromPageTemplate(pageTemplate),
|
|
44
|
-
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
53
|
+
googleFonts.getFontStyleFromPageTemplate(pageTemplate, sourceFont?.value),
|
|
54
|
+
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data, sourceFont?.value),
|
|
45
55
|
getFallback.getFallbackV2(fetcher, pageTemplate),
|
|
46
56
|
customFonts.getCustomFonts(themePageCustomFonts)
|
|
47
57
|
]);
|
|
@@ -141,7 +151,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
141
151
|
customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
|
|
142
152
|
customCodeBody: dataBuilder.themePageCustomCode?.body ?? null,
|
|
143
153
|
pageHandle: dataBuilder.handle ?? null,
|
|
144
|
-
customFonts: customFonts$1
|
|
154
|
+
customFonts: customFonts$1,
|
|
155
|
+
interaction: dataBuilder?.interaction
|
|
145
156
|
});
|
|
146
157
|
} catch (err) {
|
|
147
158
|
nextjs.captureException(err);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var checkOptionFont = require('./helpers/check-option-font.js');
|
|
3
4
|
var genFonts = require('./helpers/gen-fonts.js');
|
|
4
5
|
|
|
5
6
|
const CHROME_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36';
|
|
@@ -35,12 +36,17 @@ const composeFonts = (fonts)=>{
|
|
|
35
36
|
};
|
|
36
37
|
});
|
|
37
38
|
};
|
|
38
|
-
const createFontUrl = (fonts, option)=>{
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const createFontUrl = (fonts, option, fontType)=>{
|
|
40
|
+
const mainFonts = fonts.filter((font)=>{
|
|
41
|
+
return !([
|
|
42
|
+
'bunny',
|
|
43
|
+
'google'
|
|
44
|
+
].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType || 'google')) && (font.type === 'google' || font.type === 'bunny' || !font.type);
|
|
45
|
+
});
|
|
46
|
+
if (!mainFonts.length) return;
|
|
41
47
|
const params = new URLSearchParams();
|
|
42
48
|
const display = option?.display || 'swap';
|
|
43
|
-
const uniqFonts =
|
|
49
|
+
const uniqFonts = mainFonts.filter((font, index, arr)=>{
|
|
44
50
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
45
51
|
});
|
|
46
52
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
@@ -54,13 +60,16 @@ const createFontUrl = (fonts, option)=>{
|
|
|
54
60
|
if (option?.effect) {
|
|
55
61
|
params.append('effect', option.effect);
|
|
56
62
|
}
|
|
57
|
-
|
|
63
|
+
const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
|
|
64
|
+
const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
65
|
+
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
58
66
|
};
|
|
59
|
-
|
|
67
|
+
// eslint-disable-next-line max-params
|
|
68
|
+
async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
60
69
|
/**
|
|
61
70
|
* The order of IE -> Chrome is important, other wise chrome starts loading woff1.
|
|
62
71
|
* CSS cascading 🤷♂️.
|
|
63
|
-
*/ const url = createFontUrl(fonts, option);
|
|
72
|
+
*/ const url = createFontUrl(fonts, option, fontType);
|
|
64
73
|
if (!url) return '';
|
|
65
74
|
try {
|
|
66
75
|
if (isImportFontByUrl) return `@import url('${url}');`;
|
|
@@ -82,7 +91,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true) {
|
|
|
82
91
|
return '';
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
|
-
const getFontFromGlobalStyle = (data)=>{
|
|
94
|
+
const getFontFromGlobalStyle = (data, sourceFont)=>{
|
|
86
95
|
if (!data) return '';
|
|
87
96
|
try {
|
|
88
97
|
const globalStyle = JSON.parse(data);
|
|
@@ -90,14 +99,14 @@ const getFontFromGlobalStyle = (data)=>{
|
|
|
90
99
|
const fonts = Object.entries(fontData).map(([, value])=>{
|
|
91
100
|
return value;
|
|
92
101
|
});
|
|
93
|
-
return getFonts(fonts);
|
|
102
|
+
return getFonts(fonts, undefined, undefined, sourceFont);
|
|
94
103
|
} catch {
|
|
95
104
|
return '';
|
|
96
105
|
}
|
|
97
106
|
};
|
|
98
|
-
async function getFontStyleFromPageTemplate(pageTemplate) {
|
|
107
|
+
async function getFontStyleFromPageTemplate(pageTemplate, sourceFont) {
|
|
99
108
|
const fontStyle = pageTemplate.map((sectionData)=>{
|
|
100
|
-
return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data));
|
|
109
|
+
return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data), undefined, undefined, sourceFont);
|
|
101
110
|
});
|
|
102
111
|
return await Promise.all(fontStyle);
|
|
103
112
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const listFontsNotInBunny = [
|
|
4
|
+
'Anton SC',
|
|
5
|
+
'Arsenal SC',
|
|
6
|
+
'Baskervville SC',
|
|
7
|
+
'Beiruti',
|
|
8
|
+
'Bodoni Moda SC',
|
|
9
|
+
'Bona Nova SC',
|
|
10
|
+
'Bungee Tint',
|
|
11
|
+
'Edu AU VIC WA NT Hand',
|
|
12
|
+
'Fustat',
|
|
13
|
+
'Ga Maamli',
|
|
14
|
+
'Kalnia Glaze',
|
|
15
|
+
'Maname',
|
|
16
|
+
'Matemasie',
|
|
17
|
+
'Material Icons',
|
|
18
|
+
'Material Icons Outlined',
|
|
19
|
+
'Material Icons Round',
|
|
20
|
+
'Material Icons Sharp',
|
|
21
|
+
'Material Icons Two Tone',
|
|
22
|
+
'Material Symbols Outlined',
|
|
23
|
+
'Material Symbols Rounded',
|
|
24
|
+
'Material Symbols Sharp',
|
|
25
|
+
'Moderustic',
|
|
26
|
+
'New Amsterdam',
|
|
27
|
+
'Playwrite AR',
|
|
28
|
+
'Playwrite AT',
|
|
29
|
+
'Playwrite BE VLG',
|
|
30
|
+
'Playwrite BE WAL',
|
|
31
|
+
'Playwrite CL',
|
|
32
|
+
'Playwrite CU',
|
|
33
|
+
'Playwrite CZ',
|
|
34
|
+
'Playwrite DK Loopet',
|
|
35
|
+
'Playwrite DK Uloopet',
|
|
36
|
+
'Playwrite HR',
|
|
37
|
+
'Playwrite HR Lijeva',
|
|
38
|
+
'Playwrite HU',
|
|
39
|
+
'Playwrite PE',
|
|
40
|
+
'SUSE',
|
|
41
|
+
'Sankofa Display',
|
|
42
|
+
'Wittgenstein',
|
|
43
|
+
'Zain'
|
|
44
|
+
];
|
|
45
|
+
const listFontsNotInGoogle = [
|
|
46
|
+
'Arima Madurai',
|
|
47
|
+
'Coda Caption',
|
|
48
|
+
'Fredoka One',
|
|
49
|
+
'Gentium Book Basic',
|
|
50
|
+
'Kantumruy',
|
|
51
|
+
'Merienda One',
|
|
52
|
+
'Source Sans Pro',
|
|
53
|
+
'Source Serif Pro',
|
|
54
|
+
'Briem Hand',
|
|
55
|
+
'Pushster'
|
|
56
|
+
];
|
|
57
|
+
const objectFont = {
|
|
58
|
+
bunny: listFontsNotInBunny,
|
|
59
|
+
google: listFontsNotInGoogle
|
|
60
|
+
};
|
|
61
|
+
const checkNotInOptionFont = (currentfont, type)=>{
|
|
62
|
+
return objectFont?.[type]?.includes(currentfont);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.checkNotInOptionFont = checkNotInOptionFont;
|
|
@@ -8,12 +8,12 @@ var react = require('react');
|
|
|
8
8
|
var Toolbox = require('../components/builder/Toolbox.js');
|
|
9
9
|
var Header = require('../components/builder/Header.js');
|
|
10
10
|
var Footer = require('../components/builder/Footer.js');
|
|
11
|
-
var CollectionGlobalProvider = require('./CollectionGlobalProvider.js');
|
|
12
11
|
var PopupManager = require('../components/builder/PopupManager.js');
|
|
13
12
|
var ImageToLayout = require('../components/image-to-layout/ImageToLayout.js');
|
|
14
13
|
var AddSectionImageToLayout = require('../components/image-to-layout/AddSectionImageToLayout.js');
|
|
15
14
|
var Toolbar = require('../components/builder/Toolbar.js');
|
|
16
15
|
var SwitchView = require('../components/builder/SwitchView.js');
|
|
16
|
+
var Body = require('../components/builder/Body.js');
|
|
17
17
|
|
|
18
18
|
const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, pageType, editorImageToLayout, isThemeSectionEditor, hiddenToolbar, pageName, isOriginTemplate })=>{
|
|
19
19
|
const [loadSuccess, setLoadSuccess] = react.useState(false);
|
|
@@ -83,16 +83,9 @@ const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, page
|
|
|
83
83
|
isOriginTemplate: isOriginTemplate,
|
|
84
84
|
openPageSetting: openPageSetting
|
|
85
85
|
})),
|
|
86
|
-
/*#__PURE__*/ jsxRuntime.jsx(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
|
|
90
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
91
|
-
uid: "ROOT"
|
|
92
|
-
})
|
|
93
|
-
}) : /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
94
|
-
uid: "ROOT"
|
|
95
|
-
})
|
|
86
|
+
/*#__PURE__*/ jsxRuntime.jsx(Body.default, {
|
|
87
|
+
pageType: pageType,
|
|
88
|
+
isThemeSectionEditor: isThemeSectionEditor
|
|
96
89
|
}),
|
|
97
90
|
/*#__PURE__*/ jsxRuntime.jsx(ImageToLayout.default, {
|
|
98
91
|
editorImageToLayout: editorImageToLayout || false
|
|
@@ -9,9 +9,11 @@ var useTrackingView = require('../libs/hooks/use-tracking-view.js');
|
|
|
9
9
|
var parseHtml = require('../libs/parse-html.js');
|
|
10
10
|
var Header = require('../components/builder/Header.js');
|
|
11
11
|
var FooterForPostPurchase = require('../components/FooterForPostPurchase.js');
|
|
12
|
+
var Script = require('next/script');
|
|
12
13
|
|
|
13
|
-
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview })=>{
|
|
14
|
+
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
|
|
14
15
|
const router$1 = router.useRouter();
|
|
16
|
+
const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
|
|
15
17
|
useTrackingView.useTrackingView(shopToken, pageHandle, router$1.isFallback);
|
|
16
18
|
if (router$1.isFallback) {
|
|
17
19
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
@@ -81,17 +83,28 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
81
83
|
isPostPurchase && /*#__PURE__*/ jsxRuntime.jsx(Header.default, {
|
|
82
84
|
pageType: "POST_PURCHASE"
|
|
83
85
|
}),
|
|
86
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
87
|
+
dangerouslySetInnerHTML: {
|
|
88
|
+
__html: `<div id="gp-interaction" style="display: none;">${JSON.stringify(interaction?.value || [])}</div>`
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
84
91
|
/*#__PURE__*/ jsxRuntime.jsx(core.SectionProvider, {
|
|
85
92
|
data: sectionData,
|
|
86
|
-
children: builderData?.map((builder)=>/*#__PURE__*/ jsxRuntime.
|
|
93
|
+
children: builderData?.map((builder)=>/*#__PURE__*/ jsxRuntime.jsxs(core.BuilderProvider, {
|
|
87
94
|
state: builder.data,
|
|
88
95
|
lazy: builder.lazy,
|
|
89
96
|
priority: builder.priority,
|
|
90
97
|
isPostPurchase: isPostPurchase,
|
|
91
98
|
isPreview: isPreview,
|
|
92
|
-
children:
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
children: [
|
|
100
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Render, {
|
|
101
|
+
uid: builder.uid
|
|
102
|
+
}),
|
|
103
|
+
/*#__PURE__*/ jsxRuntime.jsx(Script, {
|
|
104
|
+
defer: true,
|
|
105
|
+
src: `${baseAssetURL}/assets-v2/gp-flow-action-lip.js`
|
|
106
|
+
})
|
|
107
|
+
]
|
|
95
108
|
}, builder.uid))
|
|
96
109
|
}),
|
|
97
110
|
isPostPurchase && /*#__PURE__*/ jsxRuntime.jsx(FooterForPostPurchase.default, {
|