@gem-sdk/pages 1.53.0-dev.8 → 1.53.0-dev.89
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 +28 -0
- package/dist/cjs/components/builder/Header.js +0 -1
- package/dist/cjs/components/builder/InteractionSelectOnPageHeader.js +11 -13
- package/dist/cjs/components/builder/PopupManager.js +1 -1
- package/dist/cjs/components/builder/Toolbox.js +29 -3
- package/dist/cjs/libs/google-fonts.js +10 -7
- package/dist/cjs/libs/hooks/useSelectModeInteraction.js +16 -0
- package/dist/cjs/pages/builder.js +4 -11
- package/dist/cjs/store/libs-store.js +14 -0
- package/dist/esm/components/builder/Body.js +24 -0
- package/dist/esm/components/builder/Header.js +0 -1
- package/dist/esm/components/builder/InteractionSelectOnPageHeader.js +11 -13
- package/dist/esm/components/builder/PopupManager.js +1 -1
- package/dist/esm/components/builder/Toolbox.js +29 -3
- package/dist/esm/libs/google-fonts.js +10 -7
- package/dist/esm/libs/hooks/useSelectModeInteraction.js +14 -0
- package/dist/esm/pages/builder.js +5 -12
- package/dist/esm/store/libs-store.js +12 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
var core = require('@gem-sdk/core');
|
|
8
|
+
var CollectionGlobalProvider = require('../../pages/CollectionGlobalProvider.js');
|
|
9
|
+
|
|
10
|
+
const Body = ({ pageType, isThemeSectionEditor })=>{
|
|
11
|
+
const interactionData = core.usePageStore((s)=>s.interactionData);
|
|
12
|
+
const isInteractionSelectModeClass = react.useMemo(()=>interactionData?.isSelectOnPage ? 'interaction-select-mode' : '', [
|
|
13
|
+
interactionData?.isSelectOnPage
|
|
14
|
+
]);
|
|
15
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
16
|
+
id: "storefront",
|
|
17
|
+
className: `${isThemeSectionEditor ? 'theme-section-editor' : ''} ${pageType === 'POST_PURCHASE' ? 'post-purchase-page' : ''} ${isInteractionSelectModeClass}`,
|
|
18
|
+
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
|
|
19
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
20
|
+
uid: "ROOT"
|
|
21
|
+
})
|
|
22
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
23
|
+
uid: "ROOT"
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.default = Body;
|
|
@@ -25,7 +25,6 @@ const Header = (props)=>{
|
|
|
25
25
|
const isSelectOnPage = core.usePageStore((s)=>s.interactionData?.isSelectOnPage);
|
|
26
26
|
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
27
27
|
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
28
|
-
console.log('isSelectOnPage', isSelectOnPage);
|
|
29
28
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
30
29
|
children: [
|
|
31
30
|
/*#__PURE__*/ jsxRuntime.jsx(SwitchView.default, {}),
|
|
@@ -4,11 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var core = require('@gem-sdk/core');
|
|
7
|
+
var useSelectModeInteraction = require('../../libs/hooks/useSelectModeInteraction.js');
|
|
7
8
|
|
|
8
9
|
const InteractionSelectOnPageHeader = ()=>{
|
|
9
10
|
const selectType = core.usePageStore((s)=>s.interactionData?.selectType);
|
|
10
11
|
const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
|
|
11
12
|
const { closeSelectOnPage } = core.useInteraction();
|
|
13
|
+
const { changeSelectMode } = useSelectModeInteraction.useSelectModeInteraction();
|
|
14
|
+
const handleSetInteraction = (type)=>{
|
|
15
|
+
setInteractionSelectType(type);
|
|
16
|
+
changeSelectMode(type);
|
|
17
|
+
};
|
|
12
18
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
13
19
|
children: [
|
|
14
20
|
/*#__PURE__*/ jsxRuntime.jsxs("header", {
|
|
@@ -22,21 +28,13 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
22
28
|
className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-1",
|
|
23
29
|
children: [
|
|
24
30
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'element' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
28
|
-
style: {
|
|
29
|
-
cursor: "url('https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-45eb24ff-a9ee-48ac-af8b-eac35e11918d.png?v=1724038301'), auto"
|
|
30
|
-
},
|
|
31
|
+
onClick: ()=>handleSetInteraction('ELEMENT'),
|
|
32
|
+
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'ELEMENT' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
31
33
|
children: "Choose an element on page"
|
|
32
34
|
}),
|
|
33
35
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'page' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
37
|
-
style: {
|
|
38
|
-
cursor: "url('https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-45eb24ff-a9ee-48ac-af8b-eac35e11918d.png?v=1724038301'), auto"
|
|
39
|
-
},
|
|
36
|
+
onClick: ()=>handleSetInteraction('PAGE'),
|
|
37
|
+
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'PAGE' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
40
38
|
children: "Use entire page"
|
|
41
39
|
})
|
|
42
40
|
]
|
|
@@ -59,7 +57,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
59
57
|
]
|
|
60
58
|
}),
|
|
61
59
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
62
|
-
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-border-[#3C67FF]
|
|
60
|
+
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-border-[#3C67FF] gp-mt-[40px] gp-z-[999] ${selectType === 'PAGE' ? 'gp-z-[999] gp-border-[4px] gp-bg-[#3c67ff]/[0.25]' : 'gp-border-[2px] gp-pointer-events-none'}`,
|
|
63
61
|
style: {
|
|
64
62
|
height: 'calc(100% - 40px)'
|
|
65
63
|
}
|
|
@@ -33,7 +33,7 @@ const PopupManager = ()=>{
|
|
|
33
33
|
onSetActiveModal
|
|
34
34
|
]);
|
|
35
35
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
36
|
-
className: "gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",
|
|
36
|
+
className: "gp-popup-trigger-button gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",
|
|
37
37
|
children: popups?.map((item)=>{
|
|
38
38
|
const display = item?.advanced?.d;
|
|
39
39
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
@@ -10,6 +10,7 @@ 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');
|
|
13
14
|
|
|
14
15
|
const globalStyleId = 'global-style';
|
|
15
16
|
const Toolbox = ()=>{
|
|
@@ -35,10 +36,13 @@ const Toolbox = ()=>{
|
|
|
35
36
|
const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
|
|
36
37
|
const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
37
38
|
const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
|
|
39
|
+
const changeFontType = libsStore.libsStore((s)=>s.changeFontType);
|
|
40
|
+
const fontType = libsStore.libsStore((s)=>s.fontType);
|
|
38
41
|
const clearModal = core.useModalStore((s)=>s.clearModal);
|
|
39
42
|
const setInteractionIsSelectOnPage = core.usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
40
43
|
const setInteractionItem = core.usePageStore((s)=>s.setInteractionItem);
|
|
41
44
|
const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
|
|
45
|
+
const setInteractionSettingType = core.usePageStore((s)=>s.setInteractionSettingType);
|
|
42
46
|
const fonts = react.useMemo(()=>genFonts.getFontsFromDataBuilder(state), [
|
|
43
47
|
state
|
|
44
48
|
]);
|
|
@@ -78,7 +82,7 @@ const Toolbox = ()=>{
|
|
|
78
82
|
const variantName = variant;
|
|
79
83
|
const url = googleFonts.createFontUrl([
|
|
80
84
|
cloneFont
|
|
81
|
-
]);
|
|
85
|
+
], undefined, fontType);
|
|
82
86
|
if (url) {
|
|
83
87
|
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
84
88
|
if (googleFont) {
|
|
@@ -281,6 +285,13 @@ const Toolbox = ()=>{
|
|
|
281
285
|
}, [
|
|
282
286
|
changeShopPlan
|
|
283
287
|
]);
|
|
288
|
+
const onUpdateFontType = react.useCallback((e)=>{
|
|
289
|
+
const fontType = e.detail;
|
|
290
|
+
if (!fontType) return;
|
|
291
|
+
changeFontType(fontType);
|
|
292
|
+
}, [
|
|
293
|
+
changeFontType
|
|
294
|
+
]);
|
|
284
295
|
const onUpdateDynamicProduct = react.useCallback((e)=>{
|
|
285
296
|
const product = e.detail;
|
|
286
297
|
if (!product) return;
|
|
@@ -335,11 +346,20 @@ const Toolbox = ()=>{
|
|
|
335
346
|
const onUpdateInteractionIsSelectOnPage = react.useCallback((e)=>{
|
|
336
347
|
const isSelectOnPage = e.detail.value;
|
|
337
348
|
const mode = e.detail.mode;
|
|
349
|
+
const settingType = e.detail.settingType;
|
|
338
350
|
setInteractionIsSelectOnPage(isSelectOnPage);
|
|
339
351
|
setInteractionSelectType(mode);
|
|
352
|
+
setInteractionSettingType(settingType);
|
|
340
353
|
}, [
|
|
341
354
|
setInteractionIsSelectOnPage,
|
|
342
|
-
setInteractionSelectType
|
|
355
|
+
setInteractionSelectType,
|
|
356
|
+
setInteractionSettingType
|
|
357
|
+
]);
|
|
358
|
+
const onUpdateInteractionSettingType = react.useCallback((e)=>{
|
|
359
|
+
const settingType = e.detail.settingType;
|
|
360
|
+
setInteractionSettingType(settingType);
|
|
361
|
+
}, [
|
|
362
|
+
setInteractionSettingType
|
|
343
363
|
]);
|
|
344
364
|
const onUpdateInteractionItem = react.useCallback((e)=>{
|
|
345
365
|
const interactionItem = e.detail;
|
|
@@ -376,6 +396,8 @@ const Toolbox = ()=>{
|
|
|
376
396
|
window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
377
397
|
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
378
398
|
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
399
|
+
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
400
|
+
window.addEventListener('update-font-type', onUpdateFontType);
|
|
379
401
|
return ()=>{
|
|
380
402
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
381
403
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -397,6 +419,8 @@ const Toolbox = ()=>{
|
|
|
397
419
|
window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
398
420
|
window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
399
421
|
window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
422
|
+
window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
423
|
+
window.removeEventListener('update-font-type', onUpdateFontType);
|
|
400
424
|
};
|
|
401
425
|
}, [
|
|
402
426
|
onAddEntity,
|
|
@@ -419,7 +443,9 @@ const Toolbox = ()=>{
|
|
|
419
443
|
onUpdateProductOffers,
|
|
420
444
|
onUpdateSalePageProductId,
|
|
421
445
|
onUpdateInteractionItem,
|
|
422
|
-
onUpdateInteractionIsSelectOnPage
|
|
446
|
+
onUpdateInteractionIsSelectOnPage,
|
|
447
|
+
onUpdateInteractionSettingType,
|
|
448
|
+
onUpdateFontType
|
|
423
449
|
]);
|
|
424
450
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
425
451
|
className: "toolbox"
|
|
@@ -35,12 +35,12 @@ const composeFonts = (fonts)=>{
|
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
-
const createFontUrl = (fonts, option)=>{
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
38
|
+
const createFontUrl = (fonts, option, fontType)=>{
|
|
39
|
+
const mainFonts = fonts.filter((font)=>font.type === 'google' || !font.type || font.type === 'bunny');
|
|
40
|
+
if (!mainFonts.length) return;
|
|
41
41
|
const params = new URLSearchParams();
|
|
42
42
|
const display = option?.display || 'swap';
|
|
43
|
-
const uniqFonts =
|
|
43
|
+
const uniqFonts = mainFonts.filter((font, index, arr)=>{
|
|
44
44
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
45
45
|
});
|
|
46
46
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
@@ -54,13 +54,16 @@ const createFontUrl = (fonts, option)=>{
|
|
|
54
54
|
if (option?.effect) {
|
|
55
55
|
params.append('effect', option.effect);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
|
|
58
|
+
const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
59
|
+
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
58
60
|
};
|
|
59
|
-
|
|
61
|
+
// eslint-disable-next-line max-params
|
|
62
|
+
async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
60
63
|
/**
|
|
61
64
|
* The order of IE -> Chrome is important, other wise chrome starts loading woff1.
|
|
62
65
|
* CSS cascading 🤷♂️.
|
|
63
|
-
*/ const url = createFontUrl(fonts, option);
|
|
66
|
+
*/ const url = createFontUrl(fonts, option, fontType);
|
|
64
67
|
if (!url) return '';
|
|
65
68
|
try {
|
|
66
69
|
if (isImportFontByUrl) return `@import url('${url}');`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const useSelectModeInteraction = ()=>{
|
|
4
|
+
const changeSelectMode = (mode)=>{
|
|
5
|
+
const event = new CustomEvent('editor:interaction:change-select-mode', {
|
|
6
|
+
bubbles: true,
|
|
7
|
+
detail: mode
|
|
8
|
+
});
|
|
9
|
+
window.dispatchEvent(event);
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
changeSelectMode
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.useSelectModeInteraction = useSelectModeInteraction;
|
|
@@ -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);
|
|
@@ -77,16 +77,9 @@ const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, page
|
|
|
77
77
|
pageType: pageType,
|
|
78
78
|
isOriginTemplate: isOriginTemplate
|
|
79
79
|
})),
|
|
80
|
-
/*#__PURE__*/ jsxRuntime.jsx(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
|
|
84
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
85
|
-
uid: "ROOT"
|
|
86
|
-
})
|
|
87
|
-
}) : /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
88
|
-
uid: "ROOT"
|
|
89
|
-
})
|
|
80
|
+
/*#__PURE__*/ jsxRuntime.jsx(Body.default, {
|
|
81
|
+
pageType: pageType,
|
|
82
|
+
isThemeSectionEditor: isThemeSectionEditor
|
|
90
83
|
}),
|
|
91
84
|
/*#__PURE__*/ jsxRuntime.jsx(ImageToLayout.default, {
|
|
92
85
|
editorImageToLayout: editorImageToLayout || false
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { usePageStore, RenderPreview } from '@gem-sdk/core';
|
|
4
|
+
import CollectionGlobalProvider from '../../pages/CollectionGlobalProvider.js';
|
|
5
|
+
|
|
6
|
+
const Body = ({ pageType, isThemeSectionEditor })=>{
|
|
7
|
+
const interactionData = usePageStore((s)=>s.interactionData);
|
|
8
|
+
const isInteractionSelectModeClass = useMemo(()=>interactionData?.isSelectOnPage ? 'interaction-select-mode' : '', [
|
|
9
|
+
interactionData?.isSelectOnPage
|
|
10
|
+
]);
|
|
11
|
+
return /*#__PURE__*/ jsx("div", {
|
|
12
|
+
id: "storefront",
|
|
13
|
+
className: `${isThemeSectionEditor ? 'theme-section-editor' : ''} ${pageType === 'POST_PURCHASE' ? 'post-purchase-page' : ''} ${isInteractionSelectModeClass}`,
|
|
14
|
+
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsx(CollectionGlobalProvider, {
|
|
15
|
+
children: /*#__PURE__*/ jsx(RenderPreview, {
|
|
16
|
+
uid: "ROOT"
|
|
17
|
+
})
|
|
18
|
+
}) : /*#__PURE__*/ jsx(RenderPreview, {
|
|
19
|
+
uid: "ROOT"
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { Body as default };
|
|
@@ -21,7 +21,6 @@ const Header = (props)=>{
|
|
|
21
21
|
const isSelectOnPage = usePageStore((s)=>s.interactionData?.isSelectOnPage);
|
|
22
22
|
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
23
23
|
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
24
|
-
console.log('isSelectOnPage', isSelectOnPage);
|
|
25
24
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
26
25
|
children: [
|
|
27
26
|
/*#__PURE__*/ jsx(Devices, {}),
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { usePageStore, useInteraction } from '@gem-sdk/core';
|
|
3
|
+
import { useSelectModeInteraction } from '../../libs/hooks/useSelectModeInteraction.js';
|
|
3
4
|
|
|
4
5
|
const InteractionSelectOnPageHeader = ()=>{
|
|
5
6
|
const selectType = usePageStore((s)=>s.interactionData?.selectType);
|
|
6
7
|
const setInteractionSelectType = usePageStore((s)=>s.setInteractionSelectType);
|
|
7
8
|
const { closeSelectOnPage } = useInteraction();
|
|
9
|
+
const { changeSelectMode } = useSelectModeInteraction();
|
|
10
|
+
const handleSetInteraction = (type)=>{
|
|
11
|
+
setInteractionSelectType(type);
|
|
12
|
+
changeSelectMode(type);
|
|
13
|
+
};
|
|
8
14
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
9
15
|
children: [
|
|
10
16
|
/*#__PURE__*/ jsxs("header", {
|
|
@@ -18,21 +24,13 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
18
24
|
className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-1",
|
|
19
25
|
children: [
|
|
20
26
|
/*#__PURE__*/ jsx("button", {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'element' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
24
|
-
style: {
|
|
25
|
-
cursor: "url('https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-45eb24ff-a9ee-48ac-af8b-eac35e11918d.png?v=1724038301'), auto"
|
|
26
|
-
},
|
|
27
|
+
onClick: ()=>handleSetInteraction('ELEMENT'),
|
|
28
|
+
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'ELEMENT' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
27
29
|
children: "Choose an element on page"
|
|
28
30
|
}),
|
|
29
31
|
/*#__PURE__*/ jsx("button", {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'page' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
33
|
-
style: {
|
|
34
|
-
cursor: "url('https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-45eb24ff-a9ee-48ac-af8b-eac35e11918d.png?v=1724038301'), auto"
|
|
35
|
-
},
|
|
32
|
+
onClick: ()=>handleSetInteraction('PAGE'),
|
|
33
|
+
className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'PAGE' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
|
|
36
34
|
children: "Use entire page"
|
|
37
35
|
})
|
|
38
36
|
]
|
|
@@ -55,7 +53,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
55
53
|
]
|
|
56
54
|
}),
|
|
57
55
|
/*#__PURE__*/ jsx("div", {
|
|
58
|
-
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-border-[#3C67FF]
|
|
56
|
+
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-border-[#3C67FF] gp-mt-[40px] gp-z-[999] ${selectType === 'PAGE' ? 'gp-z-[999] gp-border-[4px] gp-bg-[#3c67ff]/[0.25]' : 'gp-border-[2px] gp-pointer-events-none'}`,
|
|
59
57
|
style: {
|
|
60
58
|
height: 'calc(100% - 40px)'
|
|
61
59
|
}
|
|
@@ -29,7 +29,7 @@ const PopupManager = ()=>{
|
|
|
29
29
|
onSetActiveModal
|
|
30
30
|
]);
|
|
31
31
|
return /*#__PURE__*/ jsx("div", {
|
|
32
|
-
className: "gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",
|
|
32
|
+
className: "gp-popup-trigger-button gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",
|
|
33
33
|
children: popups?.map((item)=>{
|
|
34
34
|
const display = item?.advanced?.d;
|
|
35
35
|
return /*#__PURE__*/ jsx("div", {
|
|
@@ -6,6 +6,7 @@ import { createFontUrl } from '../../libs/google-fonts.js';
|
|
|
6
6
|
import { genCSS } from '../../libs/helpers/gen-css.js';
|
|
7
7
|
import { getFontsFromDataBuilder } from '../../libs/helpers/gen-fonts.js';
|
|
8
8
|
import { shopifyCdnWithGoogleFonts } from '../../libs/shopify-cdn-with-google-fonts.js';
|
|
9
|
+
import { libsStore } from '../../store/libs-store.js';
|
|
9
10
|
|
|
10
11
|
const globalStyleId = 'global-style';
|
|
11
12
|
const Toolbox = ()=>{
|
|
@@ -31,10 +32,13 @@ const Toolbox = ()=>{
|
|
|
31
32
|
const changeLayoutSettings = useShopStore((s)=>s.changeLayoutSettings);
|
|
32
33
|
const changeCreateThemeSectionCount = useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
33
34
|
const changeShopPlan = useShopStore((s)=>s.changeShopPlan);
|
|
35
|
+
const changeFontType = libsStore((s)=>s.changeFontType);
|
|
36
|
+
const fontType = libsStore((s)=>s.fontType);
|
|
34
37
|
const clearModal = useModalStore((s)=>s.clearModal);
|
|
35
38
|
const setInteractionIsSelectOnPage = usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
36
39
|
const setInteractionItem = usePageStore((s)=>s.setInteractionItem);
|
|
37
40
|
const setInteractionSelectType = usePageStore((s)=>s.setInteractionSelectType);
|
|
41
|
+
const setInteractionSettingType = usePageStore((s)=>s.setInteractionSettingType);
|
|
38
42
|
const fonts = useMemo(()=>getFontsFromDataBuilder(state), [
|
|
39
43
|
state
|
|
40
44
|
]);
|
|
@@ -74,7 +78,7 @@ const Toolbox = ()=>{
|
|
|
74
78
|
const variantName = variant;
|
|
75
79
|
const url = createFontUrl([
|
|
76
80
|
cloneFont
|
|
77
|
-
]);
|
|
81
|
+
], undefined, fontType);
|
|
78
82
|
if (url) {
|
|
79
83
|
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
80
84
|
if (googleFont) {
|
|
@@ -277,6 +281,13 @@ const Toolbox = ()=>{
|
|
|
277
281
|
}, [
|
|
278
282
|
changeShopPlan
|
|
279
283
|
]);
|
|
284
|
+
const onUpdateFontType = useCallback((e)=>{
|
|
285
|
+
const fontType = e.detail;
|
|
286
|
+
if (!fontType) return;
|
|
287
|
+
changeFontType(fontType);
|
|
288
|
+
}, [
|
|
289
|
+
changeFontType
|
|
290
|
+
]);
|
|
280
291
|
const onUpdateDynamicProduct = useCallback((e)=>{
|
|
281
292
|
const product = e.detail;
|
|
282
293
|
if (!product) return;
|
|
@@ -331,11 +342,20 @@ const Toolbox = ()=>{
|
|
|
331
342
|
const onUpdateInteractionIsSelectOnPage = useCallback((e)=>{
|
|
332
343
|
const isSelectOnPage = e.detail.value;
|
|
333
344
|
const mode = e.detail.mode;
|
|
345
|
+
const settingType = e.detail.settingType;
|
|
334
346
|
setInteractionIsSelectOnPage(isSelectOnPage);
|
|
335
347
|
setInteractionSelectType(mode);
|
|
348
|
+
setInteractionSettingType(settingType);
|
|
336
349
|
}, [
|
|
337
350
|
setInteractionIsSelectOnPage,
|
|
338
|
-
setInteractionSelectType
|
|
351
|
+
setInteractionSelectType,
|
|
352
|
+
setInteractionSettingType
|
|
353
|
+
]);
|
|
354
|
+
const onUpdateInteractionSettingType = useCallback((e)=>{
|
|
355
|
+
const settingType = e.detail.settingType;
|
|
356
|
+
setInteractionSettingType(settingType);
|
|
357
|
+
}, [
|
|
358
|
+
setInteractionSettingType
|
|
339
359
|
]);
|
|
340
360
|
const onUpdateInteractionItem = useCallback((e)=>{
|
|
341
361
|
const interactionItem = e.detail;
|
|
@@ -372,6 +392,8 @@ const Toolbox = ()=>{
|
|
|
372
392
|
window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
373
393
|
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
374
394
|
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
395
|
+
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
396
|
+
window.addEventListener('update-font-type', onUpdateFontType);
|
|
375
397
|
return ()=>{
|
|
376
398
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
377
399
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -393,6 +415,8 @@ const Toolbox = ()=>{
|
|
|
393
415
|
window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
394
416
|
window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
395
417
|
window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
418
|
+
window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
419
|
+
window.removeEventListener('update-font-type', onUpdateFontType);
|
|
396
420
|
};
|
|
397
421
|
}, [
|
|
398
422
|
onAddEntity,
|
|
@@ -415,7 +439,9 @@ const Toolbox = ()=>{
|
|
|
415
439
|
onUpdateProductOffers,
|
|
416
440
|
onUpdateSalePageProductId,
|
|
417
441
|
onUpdateInteractionItem,
|
|
418
|
-
onUpdateInteractionIsSelectOnPage
|
|
442
|
+
onUpdateInteractionIsSelectOnPage,
|
|
443
|
+
onUpdateInteractionSettingType,
|
|
444
|
+
onUpdateFontType
|
|
419
445
|
]);
|
|
420
446
|
return /*#__PURE__*/ jsx("div", {
|
|
421
447
|
className: "toolbox"
|
|
@@ -33,12 +33,12 @@ const composeFonts = (fonts)=>{
|
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
|
-
const createFontUrl = (fonts, option)=>{
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
36
|
+
const createFontUrl = (fonts, option, fontType)=>{
|
|
37
|
+
const mainFonts = fonts.filter((font)=>font.type === 'google' || !font.type || font.type === 'bunny');
|
|
38
|
+
if (!mainFonts.length) return;
|
|
39
39
|
const params = new URLSearchParams();
|
|
40
40
|
const display = option?.display || 'swap';
|
|
41
|
-
const uniqFonts =
|
|
41
|
+
const uniqFonts = mainFonts.filter((font, index, arr)=>{
|
|
42
42
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
43
43
|
});
|
|
44
44
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
@@ -52,13 +52,16 @@ const createFontUrl = (fonts, option)=>{
|
|
|
52
52
|
if (option?.effect) {
|
|
53
53
|
params.append('effect', option.effect);
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
|
|
56
|
+
const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
57
|
+
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
56
58
|
};
|
|
57
|
-
|
|
59
|
+
// eslint-disable-next-line max-params
|
|
60
|
+
async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
58
61
|
/**
|
|
59
62
|
* The order of IE -> Chrome is important, other wise chrome starts loading woff1.
|
|
60
63
|
* CSS cascading 🤷♂️.
|
|
61
|
-
*/ const url = createFontUrl(fonts, option);
|
|
64
|
+
*/ const url = createFontUrl(fonts, option, fontType);
|
|
62
65
|
if (!url) return '';
|
|
63
66
|
try {
|
|
64
67
|
if (isImportFontByUrl) return `@import url('${url}');`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const useSelectModeInteraction = ()=>{
|
|
2
|
+
const changeSelectMode = (mode)=>{
|
|
3
|
+
const event = new CustomEvent('editor:interaction:change-select-mode', {
|
|
4
|
+
bubbles: true,
|
|
5
|
+
detail: mode
|
|
6
|
+
});
|
|
7
|
+
window.dispatchEvent(event);
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
changeSelectMode
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { useSelectModeInteraction };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { PageProvider, BuilderComponentProvider, SectionProvider, BuilderPreviewProvider
|
|
2
|
+
import { PageProvider, BuilderComponentProvider, SectionProvider, BuilderPreviewProvider } from '@gem-sdk/core';
|
|
3
3
|
import { NextSeo } from 'next-seo';
|
|
4
4
|
import Head from 'next/head';
|
|
5
5
|
import { useState, useMemo, useEffect } from 'react';
|
|
6
6
|
import Toolbox from '../components/builder/Toolbox.js';
|
|
7
7
|
import Header from '../components/builder/Header.js';
|
|
8
8
|
import Footer from '../components/builder/Footer.js';
|
|
9
|
-
import CollectionGlobalProvider from './CollectionGlobalProvider.js';
|
|
10
9
|
import PopupManager from '../components/builder/PopupManager.js';
|
|
11
10
|
import ImageToLayout from '../components/image-to-layout/ImageToLayout.js';
|
|
12
11
|
import AddSectionImageToLayout from '../components/image-to-layout/AddSectionImageToLayout.js';
|
|
13
12
|
import Toolbar from '../components/builder/Toolbar.js';
|
|
14
13
|
import Devices from '../components/builder/SwitchView.js';
|
|
14
|
+
import Body from '../components/builder/Body.js';
|
|
15
15
|
|
|
16
16
|
const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, pageType, editorImageToLayout, isThemeSectionEditor, hiddenToolbar, pageName, isOriginTemplate })=>{
|
|
17
17
|
const [loadSuccess, setLoadSuccess] = useState(false);
|
|
@@ -75,16 +75,9 @@ const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, page
|
|
|
75
75
|
pageType: pageType,
|
|
76
76
|
isOriginTemplate: isOriginTemplate
|
|
77
77
|
})),
|
|
78
|
-
/*#__PURE__*/ jsx(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsx(CollectionGlobalProvider, {
|
|
82
|
-
children: /*#__PURE__*/ jsx(RenderPreview, {
|
|
83
|
-
uid: "ROOT"
|
|
84
|
-
})
|
|
85
|
-
}) : /*#__PURE__*/ jsx(RenderPreview, {
|
|
86
|
-
uid: "ROOT"
|
|
87
|
-
})
|
|
78
|
+
/*#__PURE__*/ jsx(Body, {
|
|
79
|
+
pageType: pageType,
|
|
80
|
+
isThemeSectionEditor: isThemeSectionEditor
|
|
88
81
|
}),
|
|
89
82
|
/*#__PURE__*/ jsx(ImageToLayout, {
|
|
90
83
|
editorImageToLayout: editorImageToLayout || false
|
package/dist/types/index.d.ts
CHANGED
|
@@ -189,7 +189,7 @@ declare const BuilderPage: React.FC<BuilderPageProps>;
|
|
|
189
189
|
|
|
190
190
|
declare const getStaticPaths: GetStaticPaths;
|
|
191
191
|
|
|
192
|
-
type TypographyV2FontFamilyType = 'google' | 'custom' | 'theme';
|
|
192
|
+
type TypographyV2FontFamilyType = 'google' | 'custom' | 'theme' | 'bunny';
|
|
193
193
|
|
|
194
194
|
type FontItem = {
|
|
195
195
|
type: TypographyV2FontFamilyType;
|
|
@@ -202,7 +202,7 @@ type FontOption = {
|
|
|
202
202
|
subset?: string;
|
|
203
203
|
effect?: string;
|
|
204
204
|
};
|
|
205
|
-
declare function getFonts(fonts: FontItem[], option?: FontOption, isImportFontByUrl?: boolean): Promise<string>;
|
|
205
|
+
declare function getFonts(fonts: FontItem[], option?: FontOption, isImportFontByUrl?: boolean, fontType?: string): Promise<string>;
|
|
206
206
|
declare const getFontFromGlobalStyle: (data?: string) => "" | Promise<string>;
|
|
207
207
|
|
|
208
208
|
declare const getFontsFromDataBuilder: (dataBuilder: Record<string, any>) => FontItem[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "1.53.0-dev.
|
|
3
|
+
"version": "1.53.0-dev.89",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"next": "latest"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "1.53.0-dev.
|
|
29
|
+
"@gem-sdk/core": "1.53.0-dev.79",
|
|
30
30
|
"@gem-sdk/plugin-cookie-bar": "1.53.0-dev.4",
|
|
31
31
|
"@gem-sdk/plugin-quick-view": "1.53.0-dev.4",
|
|
32
32
|
"@gem-sdk/plugin-sticky-add-to-cart": "1.53.0-dev.4"
|