@gem-sdk/pages 1.41.9 → 1.42.0-dev.60
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/Footer.js +153 -0
- package/dist/cjs/components/builder/Header.js +185 -0
- package/dist/cjs/components/builder/SwitchView.js +183 -0
- package/dist/cjs/components/builder/Toolbar.js +34 -31
- package/dist/cjs/components/builder/const.js +56 -0
- package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +16 -27
- package/dist/cjs/pages/builder.js +10 -6
- package/dist/cjs/pages/static-v2.js +1 -1
- package/dist/esm/components/builder/Footer.js +149 -0
- package/dist/esm/components/builder/Header.js +181 -0
- package/dist/esm/components/builder/SwitchView.js +179 -0
- package/dist/esm/components/builder/Toolbar.js +34 -31
- package/dist/esm/components/builder/const.js +54 -0
- package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +16 -27
- package/dist/esm/pages/builder.js +10 -6
- package/dist/esm/pages/static-v2.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +5 -5
- package/dist/cjs/components/Footer.js +0 -147
- package/dist/cjs/components/Header.js +0 -171
- package/dist/esm/components/Footer.js +0 -143
- package/dist/esm/components/Header.js +0 -167
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useShopStore, cls, makeStyleResponsive } from '@gem-sdk/core';
|
|
3
|
+
import Devices from './SwitchView.js';
|
|
4
|
+
|
|
5
|
+
const defaultMargin = {
|
|
6
|
+
desktop: '16px',
|
|
7
|
+
tablet: '16px',
|
|
8
|
+
mobile: '16px'
|
|
9
|
+
};
|
|
10
|
+
const HEADER_ON_COLOR = '#E2E2E2';
|
|
11
|
+
const HEADER_OFF_COLOR = '#F4F4F4';
|
|
12
|
+
const sizeCheck = {
|
|
13
|
+
desktop: '24px',
|
|
14
|
+
tablet: '36px',
|
|
15
|
+
mobile: '36px'
|
|
16
|
+
};
|
|
17
|
+
const Header = (props)=>{
|
|
18
|
+
const { pageType, isOriginTemplate } = props;
|
|
19
|
+
const layoutSetting = useShopStore((s)=>s.layoutSettings);
|
|
20
|
+
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
21
|
+
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
22
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ jsx(Devices, {}),
|
|
25
|
+
/*#__PURE__*/ jsx("div", {
|
|
26
|
+
className: cls('gp-header-container gp-border-1 gp-group gp-relative gp-flex gp-justify-center gp-border-b gp-border-[#EEEEEE] gp-font-sans'),
|
|
27
|
+
children: pageType === 'POST_PURCHASE' ? /*#__PURE__*/ jsx("div", {
|
|
28
|
+
className: "gp-flex gp-flex-1 gp-items-center gp-justify-between",
|
|
29
|
+
style: {
|
|
30
|
+
maxWidth: `var(--g-ct-w, 1200px)`,
|
|
31
|
+
...makeStyleResponsive('ml', defaultMargin),
|
|
32
|
+
...makeStyleResponsive('mr', defaultMargin)
|
|
33
|
+
},
|
|
34
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
35
|
+
className: "tablet:gp-items-center gp-flex gp-py-3",
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsxs("svg", {
|
|
38
|
+
style: {
|
|
39
|
+
...makeStyleResponsive('w', sizeCheck),
|
|
40
|
+
...makeStyleResponsive('h', sizeCheck)
|
|
41
|
+
},
|
|
42
|
+
viewBox: "0 0 24 24",
|
|
43
|
+
fill: "none",
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ jsx("path", {
|
|
47
|
+
d: "M15.7244 10.6242C15.9587 10.3899 15.9587 10.01 15.7244 9.77571C15.49 9.5414 15.1101 9.5414 14.8758 9.77571L11.1001 13.5514L9.42436 11.8757C9.19005 11.6414 8.81015 11.6414 8.57583 11.8757C8.34152 12.11 8.34152 12.4899 8.57583 12.7242L10.6758 14.8242C10.9101 15.0586 11.29 15.0586 11.5244 14.8242L15.7244 10.6242Z",
|
|
48
|
+
fill: "#197BBD"
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsx("path", {
|
|
51
|
+
fillRule: "evenodd",
|
|
52
|
+
clipRule: "evenodd",
|
|
53
|
+
d: "M20.4001 12C20.4001 16.6392 16.6393 20.4 12.0001 20.4C7.36091 20.4 3.6001 16.6392 3.6001 12C3.6001 7.36078 7.36091 3.59998 12.0001 3.59998C16.6393 3.59998 20.4001 7.36078 20.4001 12ZM19.2001 12C19.2001 15.9764 15.9765 19.2 12.0001 19.2C8.02365 19.2 4.8001 15.9764 4.8001 12C4.8001 8.02352 8.02365 4.79998 12.0001 4.79998C15.9765 4.79998 19.2001 8.02352 19.2001 12Z",
|
|
54
|
+
fill: "#197BBD"
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ jsxs("div", {
|
|
59
|
+
className: "gp-ml-4",
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ jsx("p", {
|
|
62
|
+
className: "gp-text-sm",
|
|
63
|
+
children: "Order #1001"
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx("p", {
|
|
66
|
+
children: "You’ve paid for your order."
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ jsxs("div", {
|
|
69
|
+
className: "gp-mt-1 gp-flex gp-items-center gp-text-[#197BBD]",
|
|
70
|
+
children: [
|
|
71
|
+
/*#__PURE__*/ jsx("div", {
|
|
72
|
+
className: "gp-text-sm",
|
|
73
|
+
children: "View order confirmation"
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ jsx("svg", {
|
|
76
|
+
width: "12",
|
|
77
|
+
height: "13",
|
|
78
|
+
viewBox: "0 0 12 13",
|
|
79
|
+
fill: "none",
|
|
80
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
81
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
82
|
+
fillRule: "evenodd",
|
|
83
|
+
clipRule: "evenodd",
|
|
84
|
+
d: "M4.6318 9.21817C4.45607 9.04244 4.45607 8.75751 4.6318 8.58178L6.7136 6.49998L4.6318 4.41817C4.45607 4.24244 4.45607 3.95751 4.6318 3.78178C4.80754 3.60604 5.09246 3.60604 5.2682 3.78178L7.6682 6.18178C7.84393 6.35751 7.84393 6.64244 7.6682 6.81817L5.2682 9.21817C5.09246 9.39391 4.80754 9.39391 4.6318 9.21817Z",
|
|
85
|
+
fill: "#197BBD"
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
95
|
+
className: "gp-flex gp-h-[40px] gp-flex-1 gp-items-center gp-justify-between",
|
|
96
|
+
style: {
|
|
97
|
+
maxWidth: `var(--g-ct-w)`,
|
|
98
|
+
...makeStyleResponsive('ml', defaultMargin),
|
|
99
|
+
...makeStyleResponsive('mr', defaultMargin)
|
|
100
|
+
},
|
|
101
|
+
children: [
|
|
102
|
+
/*#__PURE__*/ jsxs("svg", {
|
|
103
|
+
width: "60",
|
|
104
|
+
height: "8",
|
|
105
|
+
viewBox: "0 0 60 8",
|
|
106
|
+
fill: "none",
|
|
107
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsx("path", {
|
|
110
|
+
d: "M0 4C0 1.79086 1.79086 0 4 0H20C22.2091 0 24 1.79086 24 4C24 6.20914 22.2091 8 20 8H4C1.79086 8 0 6.20914 0 4Z",
|
|
111
|
+
fill: "#9E9E9E"
|
|
112
|
+
}),
|
|
113
|
+
/*#__PURE__*/ jsx("path", {
|
|
114
|
+
d: "M28 4C28 1.79086 29.7909 0 32 0H56C58.2091 0 60 1.79086 60 4C60 6.20914 58.2091 8 56 8H32C29.7909 8 28 6.20914 28 4Z",
|
|
115
|
+
fill: headerColor
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
}),
|
|
119
|
+
!isOriginTemplate && /*#__PURE__*/ jsx("div", {
|
|
120
|
+
className: "gp-header gp-invisible gp-absolute gp-left-[8px] gp-flex gp-h-[24px] gp-cursor-pointer gp-items-center gp-justify-center gp-rounded gp-bg-[#EEEEEE] gp-p-[4px] hover:gp-bg-[#f4f4f4] group-hover:gp-visible",
|
|
121
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
122
|
+
className: "gp-gap-2 gp-flex gp-px-1 gp-h-[24px] gp-items-center gp-justify-center gp-leading-5 gp-text-xs gp-font-medium gp-text-[#212121]",
|
|
123
|
+
children: [
|
|
124
|
+
/*#__PURE__*/ jsx("span", {
|
|
125
|
+
children: /*#__PURE__*/ jsxs("svg", {
|
|
126
|
+
width: "14",
|
|
127
|
+
height: "14",
|
|
128
|
+
viewBox: "0 0 14 14",
|
|
129
|
+
fill: "none",
|
|
130
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ jsx("path", {
|
|
133
|
+
fillRule: "evenodd",
|
|
134
|
+
clipRule: "evenodd",
|
|
135
|
+
d: "M6.99985 4.08501C5.38983 4.08501 4.08465 5.39019 4.08465 7.00021C4.08465 8.61023 5.38983 9.9154 6.99985 9.9154C8.60987 9.9154 9.91504 8.61023 9.91504 7.00021C9.91504 5.39019 8.60987 4.08501 6.99985 4.08501ZM5.08465 7.00021C5.08465 5.94247 5.94211 5.08501 6.99985 5.08501C8.05758 5.08501 8.91504 5.94247 8.91504 7.00021C8.91504 8.05794 8.05758 8.9154 6.99985 8.9154C5.94211 8.9154 5.08465 8.05794 5.08465 7.00021Z",
|
|
136
|
+
fill: "#212121"
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ jsx("path", {
|
|
139
|
+
fillRule: "evenodd",
|
|
140
|
+
clipRule: "evenodd",
|
|
141
|
+
d: "M5.52351 0.00390625C5.28138 0.00390625 5.07405 0.177388 5.03135 0.415715L4.7415 2.03321C4.40346 2.18248 4.08346 2.36419 3.78558 2.57432L2.18557 2.00147C1.95684 1.91958 1.70235 2.01395 1.58232 2.22517L0.122204 4.79451C0.00217064 5.00572 0.0513362 5.27266 0.238747 5.42725L1.50086 6.46836C1.48358 6.64355 1.47474 6.82106 1.47474 7.00047C1.47474 7.17981 1.48357 7.35726 1.50084 7.53238L0.238747 8.57347C0.0513362 8.72806 0.00217064 8.995 0.122203 9.20622L1.58232 11.7756C1.70235 11.9868 1.95684 12.0811 2.18557 11.9993L3.78537 11.4265C4.08332 11.6367 4.40341 11.8185 4.74155 11.9678L5.03135 13.585C5.07405 13.8233 5.28138 13.9968 5.52351 13.9968H8.47647C8.7186 13.9968 8.92593 13.8233 8.96863 13.585L9.25846 11.9676C9.5965 11.8183 9.91649 11.6365 10.2144 11.4264L11.8144 11.9993C12.0431 12.0811 12.2976 11.9868 12.4177 11.7756L13.8778 9.20622C13.9978 8.995 13.9486 8.72806 13.7612 8.57347L12.4988 7.5321C12.516 7.35706 12.5249 7.17971 12.5249 7.00047C12.5249 6.82116 12.516 6.64375 12.4988 6.46864L13.7612 5.42725C13.9486 5.27266 13.9978 5.00572 13.8778 4.79451L12.4177 2.22517C12.2976 2.01395 12.0431 1.91958 11.8144 2.00147L10.2141 2.57441C9.91636 2.36433 9.59645 2.18264 9.25851 2.0334L8.96863 0.415715C8.92593 0.177389 8.7186 0.00390625 8.47647 0.00390625H5.52351ZM5.67747 2.47943L5.94187 1.00391H8.0581L8.32253 2.47958C8.35348 2.6523 8.47271 2.79616 8.63668 2.85863C9.06768 3.02283 9.46674 3.25007 9.82215 3.5288C9.95734 3.63483 10.1375 3.66402 10.2993 3.6061L11.7559 3.08459L12.8007 4.92323L11.6503 5.8722C11.5145 5.98427 11.4476 6.15956 11.4743 6.33366C11.5076 6.55089 11.5249 6.77354 11.5249 7.00047C11.5249 7.22735 11.5076 7.44993 11.4743 7.66711C11.4476 7.8412 11.5145 8.01648 11.6504 8.12855L12.8007 9.07749L11.7559 10.9161L10.2994 10.3947C10.1377 10.3368 9.95752 10.366 9.82233 10.472C9.46686 10.7508 9.06773 10.9781 8.63664 11.1423C8.47267 11.2048 8.35344 11.3487 8.32249 11.5214L8.0581 12.9968H5.94187L5.67752 11.5215C5.64656 11.3488 5.52732 11.2049 5.36333 11.1425C4.93215 10.9782 4.53292 10.7509 4.17738 10.4721C4.04219 10.3661 3.86203 10.3369 3.70027 10.3948L2.24412 10.9161L1.19924 9.07749L2.34929 8.12883C2.48516 8.01675 2.55204 7.84146 2.52535 7.66736C2.49205 7.4501 2.47474 7.22743 2.47474 7.00047C2.47474 6.77345 2.49206 6.55072 2.52538 6.33341C2.55207 6.15931 2.48519 5.984 2.34932 5.87192L1.19924 4.92323L2.24412 3.08459L3.70047 3.60601C3.86221 3.66392 4.04236 3.63474 4.17755 3.52872C4.53304 3.24994 4.93219 3.02269 5.36329 2.85849C5.52728 2.79603 5.64652 2.65216 5.67747 2.47943Z",
|
|
142
|
+
fill: "#212121"
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ jsx("span", {
|
|
148
|
+
children: "Header"
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ jsxs("svg", {
|
|
154
|
+
width: "80",
|
|
155
|
+
height: "8",
|
|
156
|
+
viewBox: "0 0 80 8",
|
|
157
|
+
fill: "none",
|
|
158
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
159
|
+
children: [
|
|
160
|
+
/*#__PURE__*/ jsx("path", {
|
|
161
|
+
d: "M0 4C0 1.79086 1.79086 0 4 0H20C22.2091 0 24 1.79086 24 4C24 6.20914 22.2091 8 20 8H4C1.79086 8 0 6.20914 0 4Z",
|
|
162
|
+
fill: headerColor
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ jsx("path", {
|
|
165
|
+
d: "M28 4C28 1.79086 29.7909 0 32 0H48C50.2091 0 52 1.79086 52 4C52 6.20914 50.2091 8 48 8H32C29.7909 8 28 6.20914 28 4Z",
|
|
166
|
+
fill: headerColor
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ jsx("path", {
|
|
169
|
+
d: "M56 4C56 1.79086 57.7909 0 60 0H76C78.2091 0 80 1.79086 80 4C80 6.20914 78.2091 8 76 8H60C57.7909 8 56 6.20914 56 4Z",
|
|
170
|
+
fill: headerColor
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
]
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export { Header as default };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
3
|
+
import { devices } from './const.js';
|
|
4
|
+
|
|
5
|
+
const Devices = ()=>{
|
|
6
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
7
|
+
const initialDeviceState = {
|
|
8
|
+
width: 0,
|
|
9
|
+
name: '',
|
|
10
|
+
activeId: null
|
|
11
|
+
};
|
|
12
|
+
const [deviceState, setDeviceState] = useState(initialDeviceState);
|
|
13
|
+
const [isShowSwitchView, setIsShowSwitchView] = useState(false);
|
|
14
|
+
const updateDeviceState = useCallback((updates)=>{
|
|
15
|
+
setDeviceState((prevState)=>({
|
|
16
|
+
...prevState,
|
|
17
|
+
...updates
|
|
18
|
+
}));
|
|
19
|
+
}, [
|
|
20
|
+
setDeviceState
|
|
21
|
+
]);
|
|
22
|
+
useEffect(()=>{
|
|
23
|
+
if (!deviceState) {
|
|
24
|
+
const activeDevice = devices[0];
|
|
25
|
+
if (activeDevice) {
|
|
26
|
+
updateDeviceState({
|
|
27
|
+
width: activeDevice.width,
|
|
28
|
+
name: activeDevice.name,
|
|
29
|
+
activeId: activeDevice.id
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
setIsShowSwitchView(false);
|
|
33
|
+
} else {
|
|
34
|
+
setIsShowSwitchView(deviceState.width > 0 && deviceState.width <= 1024);
|
|
35
|
+
}
|
|
36
|
+
}, [
|
|
37
|
+
deviceState,
|
|
38
|
+
updateDeviceState
|
|
39
|
+
]);
|
|
40
|
+
const onHandleClick = (id)=>{
|
|
41
|
+
const activeDevice = devices.find((v)=>v.id === id);
|
|
42
|
+
if (activeDevice) {
|
|
43
|
+
updateDeviceState({
|
|
44
|
+
width: activeDevice.width,
|
|
45
|
+
name: activeDevice.name,
|
|
46
|
+
activeId: activeDevice.id
|
|
47
|
+
});
|
|
48
|
+
emitChangeDevice(activeDevice.id);
|
|
49
|
+
}
|
|
50
|
+
setIsOpen(!isOpen);
|
|
51
|
+
};
|
|
52
|
+
const emitChangeDevice = (id)=>{
|
|
53
|
+
const event = new CustomEvent('editor:change-device', {
|
|
54
|
+
bubbles: true,
|
|
55
|
+
detail: {
|
|
56
|
+
id
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
window.dispatchEvent(event);
|
|
60
|
+
};
|
|
61
|
+
const switchViewRef = useRef(null);
|
|
62
|
+
const onClickOutside = (event)=>{
|
|
63
|
+
if (switchViewRef.current && !switchViewRef.current.contains(event.target)) {
|
|
64
|
+
setIsOpen(false);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const getDisplayName = (width)=>{
|
|
68
|
+
const activeDevice = devices.find((v)=>v.width === width);
|
|
69
|
+
if (activeDevice) return activeDevice.name;
|
|
70
|
+
let displayName = 'Desktop';
|
|
71
|
+
if (width <= 768) return displayName = 'Mobile';
|
|
72
|
+
if (width <= 1024) return displayName = 'Tablet';
|
|
73
|
+
return displayName;
|
|
74
|
+
};
|
|
75
|
+
const onResizePreviewScreen = useCallback((e)=>{
|
|
76
|
+
const detail = e.detail;
|
|
77
|
+
if (!detail) return;
|
|
78
|
+
updateDeviceState({
|
|
79
|
+
width: detail.width,
|
|
80
|
+
name: getDisplayName(detail.width),
|
|
81
|
+
activeId: null
|
|
82
|
+
});
|
|
83
|
+
}, [
|
|
84
|
+
updateDeviceState
|
|
85
|
+
]);
|
|
86
|
+
useEffect(()=>{
|
|
87
|
+
window.addEventListener('mousedown', onClickOutside);
|
|
88
|
+
window.addEventListener('editor:resize-preview-screen', onResizePreviewScreen);
|
|
89
|
+
return ()=>{
|
|
90
|
+
window.removeEventListener('mousedown', onClickOutside);
|
|
91
|
+
window.removeEventListener('editor:resize-preview-screen', onResizePreviewScreen);
|
|
92
|
+
};
|
|
93
|
+
}, [
|
|
94
|
+
onResizePreviewScreen
|
|
95
|
+
]);
|
|
96
|
+
const isActiveDevice = (device)=>{
|
|
97
|
+
return device.id === deviceState.activeId || deviceState.name === device.name;
|
|
98
|
+
};
|
|
99
|
+
const handleToggleDropdown = ()=>setIsOpen(!isOpen);
|
|
100
|
+
if (isShowSwitchView) return /*#__PURE__*/ jsx(Fragment, {
|
|
101
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
102
|
+
ref: switchViewRef,
|
|
103
|
+
className: `gp-switch-view gp-font-sans gp-flex gp-h-[40px] gp-absolute gp-top-[2px] gp-transform -gp-translate-x-1/2 gp-left-1/2 gp-gap-2 gp-items-center gp-justify-center gp-cursor-pointer ${isOpen ? 'gp-z-50' : 'gp-z-1'}`,
|
|
104
|
+
children: [
|
|
105
|
+
/*#__PURE__*/ jsxs("div", {
|
|
106
|
+
className: `gp-flex gp-gap-1 gp-py-1 gp-px-2 gp-transform -gp-translate-y-[2px] gp-border-[1px] gp-justify-between gp-items-center gp-min-w-[194px] gp-bg-[#F4F4F4] hover:gp-bg-[#E2E2E2] gp-rounded-md gp-leading-5 gp-text-xs gp-font-medium gp-text-[#212121] ${isOpen ? 'gp-border-[#3C67FF]' : 'gp-border-transparent'}`,
|
|
107
|
+
onClick: (e)=>{
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
handleToggleDropdown();
|
|
110
|
+
},
|
|
111
|
+
role: "presentation",
|
|
112
|
+
children: [
|
|
113
|
+
/*#__PURE__*/ jsxs("span", {
|
|
114
|
+
children: [
|
|
115
|
+
deviceState.name,
|
|
116
|
+
" (",
|
|
117
|
+
deviceState.width,
|
|
118
|
+
"px)"
|
|
119
|
+
]
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ jsx("span", {
|
|
122
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
123
|
+
width: "9",
|
|
124
|
+
height: "5",
|
|
125
|
+
viewBox: "0 0 9 5",
|
|
126
|
+
fill: "none",
|
|
127
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
128
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
129
|
+
fillRule: "evenodd",
|
|
130
|
+
clipRule: "evenodd",
|
|
131
|
+
d: "M1.07564 0.775834C1.30995 0.541519 1.68985 0.541519 1.92417 0.775834L4.6999 3.55157L7.47564 0.775834C7.70995 0.541519 8.08985 0.541519 8.32417 0.775834C8.55848 1.01015 8.55848 1.39005 8.32417 1.62436L5.12417 4.82436C4.88985 5.05868 4.50995 5.05868 4.27564 4.82436L1.07564 1.62436C0.841324 1.39005 0.841324 1.01015 1.07564 0.775834Z",
|
|
132
|
+
fill: "#212121"
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ jsx("div", {
|
|
139
|
+
className: `gp-absolute gp-top-9 gp-transform -gp-translate-x-1/2 gp-left-1/2 gp-bg-[#212121] gp-rounded-xl gp-p-2 gp-text-[#F9F9F9] gp-w-[176px] gp-z-50 ${!isOpen ? 'gp-hidden' : ''}`,
|
|
140
|
+
children: devices.map((device)=>/*#__PURE__*/ jsx("div", {
|
|
141
|
+
className: "gp-p-2 hover:gp-bg-[#3E3E3E] gp-rounded-md",
|
|
142
|
+
onClick: (e)=>{
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
e.stopPropagation();
|
|
145
|
+
onHandleClick(device.id);
|
|
146
|
+
},
|
|
147
|
+
role: "presentation",
|
|
148
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
149
|
+
className: 'gp-flex gp-gap-2 gp-w-full gp-text-left gp-justify-space-between gp-cursor-pointer gp-leading-5 gp-text-xs gp-font-regular gp-text-[#212121]"',
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ jsx("span", {
|
|
152
|
+
className: "gp-min-w-[16px]",
|
|
153
|
+
children: isActiveDevice(device) && /*#__PURE__*/ jsx("svg", {
|
|
154
|
+
width: "16",
|
|
155
|
+
height: "17",
|
|
156
|
+
viewBox: "0 0 16 17",
|
|
157
|
+
fill: "none",
|
|
158
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
159
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
160
|
+
fillRule: "evenodd",
|
|
161
|
+
clipRule: "evenodd",
|
|
162
|
+
d: "M12.6348 4.89265C12.792 5.07861 12.7878 5.37537 12.6255 5.55547L6.71176 12.118C6.55312 12.294 6.30118 12.294 6.14255 12.118L3.87448 9.60098C3.71219 9.42088 3.70805 9.12412 3.86523 8.93815C4.02241 8.75219 4.2814 8.74744 4.4437 8.92755L6.42716 11.1287L12.0563 4.88203C12.2186 4.70192 12.4776 4.70668 12.6348 4.89265Z",
|
|
163
|
+
fill: "#00C853"
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ jsx("span", {
|
|
168
|
+
children: device.name
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
})
|
|
172
|
+
}, device.id))
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
})
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export { Devices as default };
|
|
@@ -81,7 +81,7 @@ const Toolbar = ()=>{
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
const setHoverComponent = useCallback(({ $component, componentUid, focus,
|
|
84
|
+
const setHoverComponent = useCallback(({ $component, componentUid, focus, isPreventSection, isParent })=>{
|
|
85
85
|
if (!$component && !componentUid) return;
|
|
86
86
|
if (!$component) {
|
|
87
87
|
const $c = document.querySelector(`[data-uid="${componentUid}"]`);
|
|
@@ -98,7 +98,7 @@ const Toolbar = ()=>{
|
|
|
98
98
|
const $btnAddTop = getChildrenByAttrSelector($component, 'data-toolbar-add-top');
|
|
99
99
|
const $btnAddBottom = getChildrenByAttrSelector($component, 'data-toolbar-add-bottom');
|
|
100
100
|
const $themeSectionStatus = getChildrenByAttrSelector($component, 'data-theme-section-status');
|
|
101
|
-
if (
|
|
101
|
+
if (isPreventSection && $themeSectionStatus) {
|
|
102
102
|
$themeSectionStatus.setAttribute('data-theme-section-status-active', 'true');
|
|
103
103
|
}
|
|
104
104
|
if ($toolbar) {
|
|
@@ -120,7 +120,7 @@ const Toolbar = ()=>{
|
|
|
120
120
|
if (isParent) {
|
|
121
121
|
$outline.setAttribute('data-outline-parent-hover', 'true');
|
|
122
122
|
}
|
|
123
|
-
if (
|
|
123
|
+
if (isPreventSection) {
|
|
124
124
|
$outline.setAttribute('data-outline-overlay-theme-section', 'true');
|
|
125
125
|
}
|
|
126
126
|
if (focus) {
|
|
@@ -375,25 +375,25 @@ const Toolbar = ()=>{
|
|
|
375
375
|
countShowOnboarding,
|
|
376
376
|
onCloseOnboarding
|
|
377
377
|
]);
|
|
378
|
-
const
|
|
379
|
-
if (
|
|
380
|
-
|
|
381
|
-
// check element fetch data: product, product list
|
|
382
|
-
if (!$component) {
|
|
383
|
-
const isLoading = document.querySelector(`.gp-loading-placeholder`);
|
|
384
|
-
if (!isLoading) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
if (isLoading) {
|
|
388
|
-
// await element onload
|
|
389
|
-
$component = await waitForElementToExist(`${productId ? `[data-product-id="${productId}"] ` : ''}[data-uid="${componentUid}"]`, 15000);
|
|
390
|
-
}
|
|
378
|
+
const getSelectorComponent = ({ componentUid, productId, marqueeKey })=>{
|
|
379
|
+
if (marqueeKey) {
|
|
380
|
+
return `[marquee-item-key="${marqueeKey}"] [data-uid="${componentUid}"]`;
|
|
391
381
|
}
|
|
392
|
-
|
|
393
|
-
|
|
382
|
+
return `${productId ? `[data-product-id="${productId}"][data-uid="${componentUid}"], [data-product-id="${productId}"] [data-uid="${componentUid}"]` : `[data-uid="${componentUid}"]`}`;
|
|
383
|
+
};
|
|
384
|
+
const setActiveComponent = useCallback(async ({ componentUid, productId, timeAwait = 600, forceReActive, marqueeKey })=>{
|
|
385
|
+
if (!componentUid) return;
|
|
386
|
+
const selector = getSelectorComponent({
|
|
387
|
+
componentUid,
|
|
388
|
+
productId,
|
|
389
|
+
marqueeKey
|
|
390
|
+
});
|
|
391
|
+
const $component = await waitForElementToExist(selector, timeAwait);
|
|
392
|
+
if (!$component) return;
|
|
393
|
+
if (!forceReActive && componentUid == currentComponentActive.current?.componentUid && productId == currentComponentActive.current?.productId && marqueeKey == currentComponentActive.current?.marqueeKey) return;
|
|
394
|
+
if (!forceReActive && componentUid !== currentComponentActive.current?.componentUid || productId !== currentComponentActive.current?.productId || marqueeKey !== currentComponentActive.current?.marqueeKey) {
|
|
395
|
+
removeActiveComponent();
|
|
394
396
|
}
|
|
395
|
-
if (!forceReActive && componentUid == currentComponentActive.current?.componentUid && productId == currentComponentActive.current?.productId) return;
|
|
396
|
-
if (componentUid !== currentComponentActive.current?.componentUid || productId !== currentComponentActive.current?.productId || forceReActive) removeActiveComponent();
|
|
397
397
|
const $toolbar = getChildrenByAttrSelector($component, 'data-toolbar');
|
|
398
398
|
const $outline = getChildrenByAttrSelector($component, 'data-outline');
|
|
399
399
|
const $btnAddTop = getChildrenByAttrSelector($component, 'data-toolbar-add-top');
|
|
@@ -401,7 +401,8 @@ const Toolbar = ()=>{
|
|
|
401
401
|
if ($toolbar) {
|
|
402
402
|
currentComponentActive.current = {
|
|
403
403
|
componentUid,
|
|
404
|
-
productId
|
|
404
|
+
productId,
|
|
405
|
+
marqueeKey
|
|
405
406
|
};
|
|
406
407
|
$toolbar.removeAttribute('style');
|
|
407
408
|
$toolbar.setAttribute('data-toolbar-active', 'true');
|
|
@@ -420,8 +421,9 @@ const Toolbar = ()=>{
|
|
|
420
421
|
if ($btnAddBottom) {
|
|
421
422
|
$btnAddBottom.setAttribute('data-toolbar-add-active', 'true');
|
|
422
423
|
}
|
|
424
|
+
const isChildOfMarquee = !!$component.closest('[data-component-tag="Marquee"]');
|
|
423
425
|
// Active same element in product list
|
|
424
|
-
if (productId) {
|
|
426
|
+
if (productId || isChildOfMarquee) {
|
|
425
427
|
const $relatedElements = document.querySelectorAll(`[data-uid="${componentUid}"]`);
|
|
426
428
|
if ($relatedElements?.length) {
|
|
427
429
|
$relatedElements.forEach(($relatedElement)=>{
|
|
@@ -628,23 +630,23 @@ const Toolbar = ()=>{
|
|
|
628
630
|
}
|
|
629
631
|
}
|
|
630
632
|
}
|
|
631
|
-
const $
|
|
632
|
-
if ($
|
|
633
|
+
const $preventSection = $target.closest('[data-theme-section]') || $target.closest('[data-shopify-section]');
|
|
634
|
+
if ($preventSection) {
|
|
633
635
|
setHoverComponent({
|
|
634
|
-
$component: $
|
|
636
|
+
$component: $preventSection,
|
|
635
637
|
focus: true,
|
|
636
|
-
|
|
638
|
+
isPreventSection: true
|
|
637
639
|
});
|
|
638
640
|
} else {
|
|
639
641
|
return;
|
|
640
642
|
}
|
|
641
643
|
}
|
|
642
|
-
const $
|
|
643
|
-
if ($
|
|
644
|
+
const $preventSection = $target.closest('[data-theme-section]') || $target.closest('[data-shopify-section]');
|
|
645
|
+
if ($preventSection) {
|
|
644
646
|
setHoverComponent({
|
|
645
|
-
$component: $
|
|
647
|
+
$component: $preventSection,
|
|
646
648
|
focus: true,
|
|
647
|
-
|
|
649
|
+
isPreventSection: true
|
|
648
650
|
});
|
|
649
651
|
} else {
|
|
650
652
|
setHoverComponent({
|
|
@@ -671,7 +673,8 @@ const Toolbar = ()=>{
|
|
|
671
673
|
if (detail?.componentUid) {
|
|
672
674
|
setActiveComponent({
|
|
673
675
|
componentUid: detail.componentUid,
|
|
674
|
-
productId: detail.productId
|
|
676
|
+
productId: detail.productId,
|
|
677
|
+
marqueeKey: detail.marqueeKey
|
|
675
678
|
});
|
|
676
679
|
} else {
|
|
677
680
|
removeActiveComponent();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const devices = [
|
|
2
|
+
{
|
|
3
|
+
id: 'iphone-13-mini',
|
|
4
|
+
name: 'iPhone 13 Mini',
|
|
5
|
+
width: 375
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: 'iphone-13-pro',
|
|
9
|
+
name: 'iPhone 13 Pro',
|
|
10
|
+
width: 390
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'iphone-11-pro-max',
|
|
14
|
+
name: 'iPhone 11 Pro Max',
|
|
15
|
+
width: 414
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'iphone-15-pro-max',
|
|
19
|
+
name: 'iPhone 15 Pro Max',
|
|
20
|
+
width: 430
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'pixel-7',
|
|
24
|
+
name: 'Pixel 7',
|
|
25
|
+
width: 412
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'galaxy-s8-plus',
|
|
29
|
+
name: 'Galaxy S8+',
|
|
30
|
+
width: 360
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'galaxy-s20-ultra',
|
|
34
|
+
name: 'Galaxy S20 Ultra',
|
|
35
|
+
width: 412
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'ipad-mini',
|
|
39
|
+
name: 'iPad Mini',
|
|
40
|
+
width: 768
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'ipad-air',
|
|
44
|
+
name: 'iPad Air',
|
|
45
|
+
width: 820
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'ipad-pro',
|
|
49
|
+
name: 'iPad Pro',
|
|
50
|
+
width: 1024
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
export { devices };
|