@gem-sdk/pages 1.53.0-dev.0 → 1.53.0-dev.139
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 +167 -46
- package/dist/cjs/components/builder/PopupManager.js +1 -1
- package/dist/cjs/components/builder/Toolbox.js +36 -3
- package/dist/cjs/libs/api/get-static-page-props-v2.js +13 -3
- package/dist/cjs/libs/google-fonts.js +20 -11
- package/dist/cjs/libs/helpers/check-option-font.js +65 -0
- 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 +167 -46
- package/dist/esm/components/builder/PopupManager.js +1 -1
- package/dist/esm/components/builder/Toolbox.js +36 -3
- package/dist/esm/libs/api/get-static-page-props-v2.js +14 -4
- package/dist/esm/libs/google-fonts.js +20 -11
- package/dist/esm/libs/helpers/check-option-font.js +63 -0
- 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 +5 -3
- package/package.json +5 -5
|
@@ -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,61 +1,182 @@
|
|
|
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';
|
|
4
|
+
import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
3
5
|
|
|
4
6
|
const InteractionSelectOnPageHeader = ()=>{
|
|
5
7
|
const selectType = usePageStore((s)=>s.interactionData?.selectType);
|
|
8
|
+
const settingType = usePageStore((s)=>s.interactionData?.settingType);
|
|
6
9
|
const setInteractionSelectType = usePageStore((s)=>s.setInteractionSelectType);
|
|
7
10
|
const { closeSelectOnPage } = useInteraction();
|
|
11
|
+
const { changeSelectMode } = useSelectModeInteraction();
|
|
12
|
+
const [hoverOption, setHoverOption] = useState(null);
|
|
13
|
+
const [openDropdown, setOpenDropdown] = useState(false);
|
|
14
|
+
const popupRef = useRef(null);
|
|
15
|
+
const handleSetInteraction = (type)=>{
|
|
16
|
+
setOpenDropdown(false);
|
|
17
|
+
setInteractionSelectType(type);
|
|
18
|
+
changeSelectMode(type);
|
|
19
|
+
if (type == 'PAGE') closeSelectOnPage();
|
|
20
|
+
};
|
|
21
|
+
const handleClickOutside = useCallback((event)=>{
|
|
22
|
+
if (!openDropdown) return;
|
|
23
|
+
if (popupRef.current && !popupRef.current.contains(event.target)) {
|
|
24
|
+
setOpenDropdown(false);
|
|
25
|
+
}
|
|
26
|
+
}, [
|
|
27
|
+
openDropdown
|
|
28
|
+
]);
|
|
29
|
+
useEffect(()=>{
|
|
30
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
31
|
+
return ()=>{
|
|
32
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
33
|
+
};
|
|
34
|
+
}, [
|
|
35
|
+
handleClickOutside
|
|
36
|
+
]);
|
|
37
|
+
const isShowOverlay = useMemo(()=>{
|
|
38
|
+
return hoverOption !== 'ELEMENT' && (selectType === 'PAGE' || selectType === 'ELEMENT' && hoverOption === 'PAGE');
|
|
39
|
+
}, [
|
|
40
|
+
hoverOption,
|
|
41
|
+
selectType
|
|
42
|
+
]);
|
|
43
|
+
const title = useMemo(()=>{
|
|
44
|
+
const type = selectType === 'ELEMENT' ? 'an element' : 'entire page';
|
|
45
|
+
if (settingType === 'TRIGGER') return `Start with triggering ${type}`;
|
|
46
|
+
return `Set ${selectType === 'ELEMENT' ? 'an element' : 'entire page'} as target`;
|
|
47
|
+
}, [
|
|
48
|
+
selectType,
|
|
49
|
+
settingType
|
|
50
|
+
]);
|
|
51
|
+
const renderIconCheckSvg = ()=>{
|
|
52
|
+
return /*#__PURE__*/ jsx("div", {
|
|
53
|
+
className: "gp-w-[21px]",
|
|
54
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
55
|
+
width: "21",
|
|
56
|
+
height: "20",
|
|
57
|
+
viewBox: "0 0 21 20",
|
|
58
|
+
fill: "none",
|
|
59
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
60
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
61
|
+
"fill-rule": "evenodd",
|
|
62
|
+
"clip-rule": "evenodd",
|
|
63
|
+
d: "M16.3415 5.1766C16.5528 5.41207 16.5528 5.79383 16.3415 6.0293L8.45016 14.8234C8.34869 14.9365 8.21107 15 8.06757 15C7.92408 15 7.78645 14.9365 7.68499 14.8234L4.65846 11.4505C4.44717 11.215 4.44718 10.8333 4.65848 10.5978C4.86978 10.3623 5.21236 10.3623 5.42365 10.5978L8.06759 13.5443L15.5764 5.1766C15.7877 4.94113 16.1302 4.94113 16.3415 5.1766Z",
|
|
64
|
+
fill: "#00C853"
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
};
|
|
8
69
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
9
70
|
children: [
|
|
10
|
-
/*#__PURE__*/
|
|
11
|
-
className: "gp-flex gp-justify-
|
|
12
|
-
children:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
/*#__PURE__*/ jsx("header", {
|
|
72
|
+
className: "gp-flex gp-text-[12px] gp-justify-center gp-items-center gp-h-10 gp-fixed gp-top-0 gp-left-0 gp-w-full gp-z-[1000] gp-bg-[#151515] gp-text-white interaction-select-mode-header",
|
|
73
|
+
children: /*#__PURE__*/ jsxs("section", {
|
|
74
|
+
className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-2",
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ jsxs("div", {
|
|
77
|
+
className: "gp-relative",
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ jsxs("button", {
|
|
80
|
+
className: `gp-h-full gp-w-[280px] gp-gap-2 gp-py-2 gp-px-4 gp-items-center gp-justify-center gp-leading-5 gp-font-medium gp-flex gp-rounded-b-[8px] gp-bg-[#3C67FF] gp-text-[#F9F9F9]`,
|
|
81
|
+
onClick: ()=>setOpenDropdown((prev)=>!prev),
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ jsx("p", {
|
|
84
|
+
className: "gp-grow",
|
|
85
|
+
children: title
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsx("div", {
|
|
88
|
+
className: "gp-w-[21px]",
|
|
89
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
90
|
+
width: "16",
|
|
91
|
+
height: "16",
|
|
92
|
+
viewBox: "0 0 16 16",
|
|
93
|
+
fill: "currentColor",
|
|
94
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
95
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
96
|
+
"fill-rule": "evenodd",
|
|
97
|
+
"clip-rule": "evenodd",
|
|
98
|
+
d: "M4.13017 6.11716C4.30374 5.96095 4.58515 5.96095 4.75871 6.11716L8 9.03431L11.2413 6.11716C11.4149 5.96095 11.6963 5.96095 11.8698 6.11716C12.0434 6.27337 12.0434 6.52663 11.8698 6.68284L8.31427 9.88284C8.1407 10.0391 7.8593 10.0391 7.68573 9.88284L4.13017 6.68284C3.95661 6.52663 3.95661 6.27337 4.13017 6.11716Z",
|
|
99
|
+
fill: "currentColor"
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
openDropdown && /*#__PURE__*/ jsxs("div", {
|
|
106
|
+
ref: popupRef,
|
|
107
|
+
className: "gp-p-2 gp-flex gp-flex-col gp-absolute gp-top-[calc(100%_+_4px)] gp-w-[280px] gp-bg-[#151515] gp-rounded-xl gp-text-white",
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsxs("div", {
|
|
110
|
+
className: "gp-p-2 gp-flex gp-gap-2 gp-cursor-pointer hover:gp-bg-[#3b3b3b] gp-rounded-lg",
|
|
111
|
+
"aria-hidden": true,
|
|
112
|
+
onClick: ()=>handleSetInteraction('ELEMENT'),
|
|
113
|
+
onMouseOver: ()=>setHoverOption('ELEMENT'),
|
|
114
|
+
onFocus: ()=>setHoverOption('ELEMENT'),
|
|
115
|
+
onMouseLeave: ()=>setHoverOption(null),
|
|
116
|
+
children: [
|
|
117
|
+
selectType === 'ELEMENT' ? renderIconCheckSvg() : /*#__PURE__*/ jsx("div", {
|
|
118
|
+
className: "gp-w-[21px]",
|
|
119
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
120
|
+
width: "18",
|
|
121
|
+
height: "18",
|
|
122
|
+
viewBox: "0 0 18 18",
|
|
123
|
+
fill: "none",
|
|
124
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
125
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
126
|
+
"fill-rule": "evenodd",
|
|
127
|
+
"clip-rule": "evenodd",
|
|
128
|
+
d: "M8.99983 0.351562C9.34501 0.351562 9.62483 0.631385 9.62483 0.976562V2.15278C12.923 2.45 15.5496 5.07654 15.8468 8.37476H17.0233C17.3684 8.37476 17.6483 8.65458 17.6483 8.99976C17.6483 9.34493 17.3684 9.62476 17.0233 9.62476H15.8468C15.5496 12.923 12.923 15.5495 9.62483 15.8467V17.0232C9.62483 17.3683 9.34501 17.6482 8.99983 17.6482C8.65465 17.6482 8.37483 17.3683 8.37483 17.0232V15.8467C5.07662 15.5495 2.45007 12.923 2.15286 9.62476H0.976562C0.631385 9.62476 0.351562 9.34493 0.351562 8.99976C0.351562 8.65458 0.631385 8.37476 0.976562 8.37476H2.15286C2.45007 5.07654 5.07662 2.45 8.37483 2.15278V0.976562C8.37483 0.631385 8.65465 0.351562 8.99983 0.351562ZM3.40916 9.62476H5.97656C6.32174 9.62476 6.60156 9.34493 6.60156 8.99976C6.60156 8.65458 6.32174 8.37476 5.97656 8.37476H3.40916C3.69738 5.7675 5.76757 3.6973 8.37483 3.40909V5.97656C8.37483 6.32174 8.65465 6.60156 8.99983 6.60156C9.34501 6.60156 9.62483 6.32174 9.62483 5.97656V3.40909C12.2321 3.6973 14.3023 5.7675 14.5905 8.37476H12.0233C11.6781 8.37476 11.3983 8.65458 11.3983 8.99976C11.3983 9.34493 11.6781 9.62476 12.0233 9.62476H14.5905C14.3023 12.232 12.2321 14.3022 9.62483 14.5904V12.0232C9.62483 11.678 9.34501 11.3982 8.99983 11.3982C8.65465 11.3982 8.37483 11.678 8.37483 12.0232V14.5904C5.76757 14.3022 3.69738 12.232 3.40916 9.62476Z",
|
|
129
|
+
fill: "#AAAAAA"
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
}),
|
|
133
|
+
/*#__PURE__*/ jsx("p", {
|
|
134
|
+
className: "gp-h-[21px]",
|
|
135
|
+
children: "An element"
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsxs("div", {
|
|
140
|
+
className: "gp-p-2 gp-flex gp-gap-2 gp-cursor-pointer hover:gp-bg-[#3b3b3b] gp-rounded-lg",
|
|
141
|
+
onClick: ()=>handleSetInteraction('PAGE'),
|
|
142
|
+
onMouseOver: ()=>setHoverOption('PAGE'),
|
|
143
|
+
onFocus: ()=>setHoverOption('PAGE'),
|
|
144
|
+
onMouseLeave: ()=>setHoverOption(null),
|
|
145
|
+
"aria-hidden": true,
|
|
146
|
+
children: [
|
|
147
|
+
selectType === 'PAGE' ? renderIconCheckSvg() : /*#__PURE__*/ jsx("svg", {
|
|
148
|
+
width: "21",
|
|
149
|
+
height: "20",
|
|
150
|
+
viewBox: "0 0 21 20",
|
|
151
|
+
fill: "none",
|
|
152
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
153
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
154
|
+
"fill-rule": "evenodd",
|
|
155
|
+
"clip-rule": "evenodd",
|
|
156
|
+
d: "M7.25 4.5C6.55964 4.5 6 5.05964 6 5.75V14.25C6 14.9404 6.55964 15.5 7.25 15.5H13.75C14.4404 15.5 15 14.9404 15 14.25V9.5H11.75C10.7835 9.5 10 8.7165 10 7.75V4.5H7.25ZM11.5 5.56066L13.9393 8H11.75C11.6119 8 11.5 7.88807 11.5 7.75V5.56066ZM4.5 5.75C4.5 4.23122 5.73122 3 7.25 3H10.75C10.9489 3 11.1397 3.07902 11.2803 3.21967L16.2803 8.21967C16.421 8.36032 16.5 8.55109 16.5 8.75V14.25C16.5 15.7688 15.2688 17 13.75 17H7.25C5.73122 17 4.5 15.7688 4.5 14.25V5.75Z",
|
|
157
|
+
fill: "#AAAAAA"
|
|
158
|
+
})
|
|
159
|
+
}),
|
|
160
|
+
/*#__PURE__*/ jsx("p", {
|
|
161
|
+
className: "gp-h-[21px]",
|
|
162
|
+
children: "Entire page"
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
}),
|
|
170
|
+
/*#__PURE__*/ jsx("button", {
|
|
171
|
+
className: "",
|
|
172
|
+
onClick: closeSelectOnPage,
|
|
173
|
+
children: "Cancel"
|
|
53
174
|
})
|
|
54
|
-
|
|
55
|
-
|
|
175
|
+
]
|
|
176
|
+
})
|
|
56
177
|
}),
|
|
57
178
|
/*#__PURE__*/ jsx("div", {
|
|
58
|
-
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-
|
|
179
|
+
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-mt-[40px] gp-z-[999] ${isShowOverlay ? 'gp-z-[999] gp-bg-[#3c67ff]/[0.25]' : 'gp-pointer-events-none'}`,
|
|
59
180
|
style: {
|
|
60
181
|
height: 'calc(100% - 40px)'
|
|
61
182
|
}
|
|
@@ -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,8 @@ 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';
|
|
10
|
+
import { checkNotInOptionFont } from '../../libs/helpers/check-option-font.js';
|
|
9
11
|
|
|
10
12
|
const globalStyleId = 'global-style';
|
|
11
13
|
const Toolbox = ()=>{
|
|
@@ -31,10 +33,13 @@ const Toolbox = ()=>{
|
|
|
31
33
|
const changeLayoutSettings = useShopStore((s)=>s.changeLayoutSettings);
|
|
32
34
|
const changeCreateThemeSectionCount = useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
33
35
|
const changeShopPlan = useShopStore((s)=>s.changeShopPlan);
|
|
36
|
+
const changeFontType = libsStore((s)=>s.changeFontType);
|
|
37
|
+
const fontType = libsStore((s)=>s.fontType);
|
|
34
38
|
const clearModal = useModalStore((s)=>s.clearModal);
|
|
35
39
|
const setInteractionIsSelectOnPage = usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
36
40
|
const setInteractionItem = usePageStore((s)=>s.setInteractionItem);
|
|
37
41
|
const setInteractionSelectType = usePageStore((s)=>s.setInteractionSelectType);
|
|
42
|
+
const setInteractionSettingType = usePageStore((s)=>s.setInteractionSettingType);
|
|
38
43
|
const fonts = useMemo(()=>getFontsFromDataBuilder(state), [
|
|
39
44
|
state
|
|
40
45
|
]);
|
|
@@ -63,6 +68,12 @@ const Toolbox = ()=>{
|
|
|
63
68
|
});
|
|
64
69
|
// append new fonts
|
|
65
70
|
for (const font of fonts){
|
|
71
|
+
if ([
|
|
72
|
+
'bunny',
|
|
73
|
+
'google'
|
|
74
|
+
].includes(font.type) && checkNotInOptionFont(font.family, fontType)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
66
77
|
if (font.type !== 'custom') {
|
|
67
78
|
if (font.variants?.length) {
|
|
68
79
|
for (const variant of font.variants){
|
|
@@ -74,7 +85,7 @@ const Toolbox = ()=>{
|
|
|
74
85
|
const variantName = variant;
|
|
75
86
|
const url = createFontUrl([
|
|
76
87
|
cloneFont
|
|
77
|
-
]);
|
|
88
|
+
], undefined, fontType);
|
|
78
89
|
if (url) {
|
|
79
90
|
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
80
91
|
if (googleFont) {
|
|
@@ -277,6 +288,13 @@ const Toolbox = ()=>{
|
|
|
277
288
|
}, [
|
|
278
289
|
changeShopPlan
|
|
279
290
|
]);
|
|
291
|
+
const onUpdateFontType = useCallback((e)=>{
|
|
292
|
+
const fontType = e.detail;
|
|
293
|
+
if (!fontType) return;
|
|
294
|
+
changeFontType(fontType);
|
|
295
|
+
}, [
|
|
296
|
+
changeFontType
|
|
297
|
+
]);
|
|
280
298
|
const onUpdateDynamicProduct = useCallback((e)=>{
|
|
281
299
|
const product = e.detail;
|
|
282
300
|
if (!product) return;
|
|
@@ -331,11 +349,20 @@ const Toolbox = ()=>{
|
|
|
331
349
|
const onUpdateInteractionIsSelectOnPage = useCallback((e)=>{
|
|
332
350
|
const isSelectOnPage = e.detail.value;
|
|
333
351
|
const mode = e.detail.mode;
|
|
352
|
+
const settingType = e.detail.settingType;
|
|
334
353
|
setInteractionIsSelectOnPage(isSelectOnPage);
|
|
335
354
|
setInteractionSelectType(mode);
|
|
355
|
+
setInteractionSettingType(settingType);
|
|
336
356
|
}, [
|
|
337
357
|
setInteractionIsSelectOnPage,
|
|
338
|
-
setInteractionSelectType
|
|
358
|
+
setInteractionSelectType,
|
|
359
|
+
setInteractionSettingType
|
|
360
|
+
]);
|
|
361
|
+
const onUpdateInteractionSettingType = useCallback((e)=>{
|
|
362
|
+
const settingType = e.detail.settingType;
|
|
363
|
+
setInteractionSettingType(settingType);
|
|
364
|
+
}, [
|
|
365
|
+
setInteractionSettingType
|
|
339
366
|
]);
|
|
340
367
|
const onUpdateInteractionItem = useCallback((e)=>{
|
|
341
368
|
const interactionItem = e.detail;
|
|
@@ -372,6 +399,8 @@ const Toolbox = ()=>{
|
|
|
372
399
|
window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
373
400
|
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
374
401
|
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
402
|
+
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
403
|
+
window.addEventListener('update-font-type', onUpdateFontType);
|
|
375
404
|
return ()=>{
|
|
376
405
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
377
406
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -393,6 +422,8 @@ const Toolbox = ()=>{
|
|
|
393
422
|
window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
394
423
|
window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
395
424
|
window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
425
|
+
window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
426
|
+
window.removeEventListener('update-font-type', onUpdateFontType);
|
|
396
427
|
};
|
|
397
428
|
}, [
|
|
398
429
|
onAddEntity,
|
|
@@ -415,7 +446,9 @@ const Toolbox = ()=>{
|
|
|
415
446
|
onUpdateProductOffers,
|
|
416
447
|
onUpdateSalePageProductId,
|
|
417
448
|
onUpdateInteractionItem,
|
|
418
|
-
onUpdateInteractionIsSelectOnPage
|
|
449
|
+
onUpdateInteractionIsSelectOnPage,
|
|
450
|
+
onUpdateInteractionSettingType,
|
|
451
|
+
onUpdateFontType
|
|
419
452
|
]);
|
|
420
453
|
return /*#__PURE__*/ jsx("div", {
|
|
421
454
|
className: "toolbox"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublishedThemePagesDocument, StorePropertyDocument } from '@gem-sdk/core';
|
|
1
|
+
import { PublishedThemePagesDocument, StorePropertyDocument, PublishedShopMetasDocument } from '@gem-sdk/core';
|
|
2
2
|
import { ShopMetaDocument } from '@gem-sdk/adapter-shopify';
|
|
3
3
|
import { getFontStyleFromPageTemplate, getFontFromGlobalStyle } from '../google-fonts.js';
|
|
4
4
|
import { genCSS } from '../helpers/gen-css.js';
|
|
@@ -16,7 +16,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
16
16
|
slug,
|
|
17
17
|
slugType: pageType
|
|
18
18
|
};
|
|
19
|
-
const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
|
|
19
|
+
const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
|
|
20
20
|
fetcher([
|
|
21
21
|
PublishedThemePagesDocument,
|
|
22
22
|
variables
|
|
@@ -26,11 +26,21 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
26
26
|
]),
|
|
27
27
|
shopifyFetcher([
|
|
28
28
|
ShopMetaDocument
|
|
29
|
+
]),
|
|
30
|
+
fetcher([
|
|
31
|
+
PublishedShopMetasDocument,
|
|
32
|
+
{
|
|
33
|
+
keys: [
|
|
34
|
+
'source_font'
|
|
35
|
+
]
|
|
36
|
+
}
|
|
29
37
|
])
|
|
30
38
|
]);
|
|
31
39
|
if (theme.status === 'rejected') {
|
|
32
40
|
throw new Error(theme.reason?.[0]);
|
|
33
41
|
}
|
|
42
|
+
const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
|
|
43
|
+
const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
|
|
34
44
|
const dataBuilder = theme.value.publishedThemePages?.[0];
|
|
35
45
|
const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
|
|
36
46
|
if (!dataBuilder) {
|
|
@@ -38,8 +48,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
38
48
|
}
|
|
39
49
|
const pageTemplate = parseBuilderTemplateV2(dataBuilder);
|
|
40
50
|
const [elementFontStyle, fontStyle, fallback, customFonts] = await Promise.all([
|
|
41
|
-
getFontStyleFromPageTemplate(pageTemplate),
|
|
42
|
-
getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
51
|
+
getFontStyleFromPageTemplate(pageTemplate, sourceFont?.value),
|
|
52
|
+
getFontFromGlobalStyle(dataBuilder?.pageStyle?.data, sourceFont?.value),
|
|
43
53
|
getFallbackV2(fetcher, pageTemplate),
|
|
44
54
|
getCustomFonts(themePageCustomFonts)
|
|
45
55
|
]);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { checkNotInOptionFont } from './helpers/check-option-font.js';
|
|
1
2
|
import { getFontsFromDataBuilder } from './helpers/gen-fonts.js';
|
|
2
3
|
|
|
3
4
|
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';
|
|
@@ -33,12 +34,17 @@ const composeFonts = (fonts)=>{
|
|
|
33
34
|
};
|
|
34
35
|
});
|
|
35
36
|
};
|
|
36
|
-
const createFontUrl = (fonts, option)=>{
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const createFontUrl = (fonts, option, fontType)=>{
|
|
38
|
+
const mainFonts = fonts.filter((font)=>{
|
|
39
|
+
return !([
|
|
40
|
+
'bunny',
|
|
41
|
+
'google'
|
|
42
|
+
].includes(font.type) && checkNotInOptionFont(font.family, fontType || 'google')) && (font.type === 'google' || font.type === 'bunny' || !font.type);
|
|
43
|
+
});
|
|
44
|
+
if (!mainFonts.length) return;
|
|
39
45
|
const params = new URLSearchParams();
|
|
40
46
|
const display = option?.display || 'swap';
|
|
41
|
-
const uniqFonts =
|
|
47
|
+
const uniqFonts = mainFonts.filter((font, index, arr)=>{
|
|
42
48
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
43
49
|
});
|
|
44
50
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
@@ -52,13 +58,16 @@ const createFontUrl = (fonts, option)=>{
|
|
|
52
58
|
if (option?.effect) {
|
|
53
59
|
params.append('effect', option.effect);
|
|
54
60
|
}
|
|
55
|
-
|
|
61
|
+
const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
|
|
62
|
+
const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
63
|
+
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
56
64
|
};
|
|
57
|
-
|
|
65
|
+
// eslint-disable-next-line max-params
|
|
66
|
+
async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
58
67
|
/**
|
|
59
68
|
* The order of IE -> Chrome is important, other wise chrome starts loading woff1.
|
|
60
69
|
* CSS cascading 🤷♂️.
|
|
61
|
-
*/ const url = createFontUrl(fonts, option);
|
|
70
|
+
*/ const url = createFontUrl(fonts, option, fontType);
|
|
62
71
|
if (!url) return '';
|
|
63
72
|
try {
|
|
64
73
|
if (isImportFontByUrl) return `@import url('${url}');`;
|
|
@@ -80,7 +89,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true) {
|
|
|
80
89
|
return '';
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
|
-
const getFontFromGlobalStyle = (data)=>{
|
|
92
|
+
const getFontFromGlobalStyle = (data, sourceFont)=>{
|
|
84
93
|
if (!data) return '';
|
|
85
94
|
try {
|
|
86
95
|
const globalStyle = JSON.parse(data);
|
|
@@ -88,14 +97,14 @@ const getFontFromGlobalStyle = (data)=>{
|
|
|
88
97
|
const fonts = Object.entries(fontData).map(([, value])=>{
|
|
89
98
|
return value;
|
|
90
99
|
});
|
|
91
|
-
return getFonts(fonts);
|
|
100
|
+
return getFonts(fonts, undefined, undefined, sourceFont);
|
|
92
101
|
} catch {
|
|
93
102
|
return '';
|
|
94
103
|
}
|
|
95
104
|
};
|
|
96
|
-
async function getFontStyleFromPageTemplate(pageTemplate) {
|
|
105
|
+
async function getFontStyleFromPageTemplate(pageTemplate, sourceFont) {
|
|
97
106
|
const fontStyle = pageTemplate.map((sectionData)=>{
|
|
98
|
-
return getFonts(getFontsFromDataBuilder(sectionData.data));
|
|
107
|
+
return getFonts(getFontsFromDataBuilder(sectionData.data), undefined, undefined, sourceFont);
|
|
99
108
|
});
|
|
100
109
|
return await Promise.all(fontStyle);
|
|
101
110
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const listFontsNotInBunny = [
|
|
2
|
+
'Anton SC',
|
|
3
|
+
'Arsenal SC',
|
|
4
|
+
'Baskervville SC',
|
|
5
|
+
'Beiruti',
|
|
6
|
+
'Bodoni Moda SC',
|
|
7
|
+
'Bona Nova SC',
|
|
8
|
+
'Bungee Tint',
|
|
9
|
+
'Edu AU VIC WA NT Hand',
|
|
10
|
+
'Fustat',
|
|
11
|
+
'Ga Maamli',
|
|
12
|
+
'Kalnia Glaze',
|
|
13
|
+
'Maname',
|
|
14
|
+
'Matemasie',
|
|
15
|
+
'Material Icons',
|
|
16
|
+
'Material Icons Outlined',
|
|
17
|
+
'Material Icons Round',
|
|
18
|
+
'Material Icons Sharp',
|
|
19
|
+
'Material Icons Two Tone',
|
|
20
|
+
'Material Symbols Outlined',
|
|
21
|
+
'Material Symbols Rounded',
|
|
22
|
+
'Material Symbols Sharp',
|
|
23
|
+
'Moderustic',
|
|
24
|
+
'New Amsterdam',
|
|
25
|
+
'Playwrite AR',
|
|
26
|
+
'Playwrite AT',
|
|
27
|
+
'Playwrite BE VLG',
|
|
28
|
+
'Playwrite BE WAL',
|
|
29
|
+
'Playwrite CL',
|
|
30
|
+
'Playwrite CU',
|
|
31
|
+
'Playwrite CZ',
|
|
32
|
+
'Playwrite DK Loopet',
|
|
33
|
+
'Playwrite DK Uloopet',
|
|
34
|
+
'Playwrite HR',
|
|
35
|
+
'Playwrite HR Lijeva',
|
|
36
|
+
'Playwrite HU',
|
|
37
|
+
'Playwrite PE',
|
|
38
|
+
'SUSE',
|
|
39
|
+
'Sankofa Display',
|
|
40
|
+
'Wittgenstein',
|
|
41
|
+
'Zain'
|
|
42
|
+
];
|
|
43
|
+
const listFontsNotInGoogle = [
|
|
44
|
+
'Arima Madurai',
|
|
45
|
+
'Coda Caption',
|
|
46
|
+
'Fredoka One',
|
|
47
|
+
'Gentium Book Basic',
|
|
48
|
+
'Kantumruy',
|
|
49
|
+
'Merienda One',
|
|
50
|
+
'Source Sans Pro',
|
|
51
|
+
'Source Serif Pro',
|
|
52
|
+
'Briem Hand',
|
|
53
|
+
'Pushster'
|
|
54
|
+
];
|
|
55
|
+
const objectFont = {
|
|
56
|
+
bunny: listFontsNotInBunny,
|
|
57
|
+
google: listFontsNotInGoogle
|
|
58
|
+
};
|
|
59
|
+
const checkNotInOptionFont = (currentfont, type)=>{
|
|
60
|
+
return objectFont?.[type]?.includes(currentfont);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { checkNotInOptionFont };
|
|
@@ -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
|