zz-shopify-components 0.36.1-beta.5 → 0.36.1-beta.7
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.
|
@@ -170,7 +170,11 @@
|
|
|
170
170
|
</svg>
|
|
171
171
|
</button>
|
|
172
172
|
|
|
173
|
-
<div
|
|
173
|
+
<div
|
|
174
|
+
{% if block.settings.modal_id != blank %}
|
|
175
|
+
data-track-zz-scroll="{{ block.settings.modal_id }}"
|
|
176
|
+
{% endif %}
|
|
177
|
+
class="zz-bottom-popup__body zz-overflow-scrollbar-hidden">
|
|
174
178
|
<div class="zz-bottom-popup__inner" id="{{ modal_id }}-title">
|
|
175
179
|
{% content_for 'blocks' %}
|
|
176
180
|
</div>
|
package/package.json
CHANGED
package/sections/zz-FAQ.liquid
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
{% if section.settings.is_exposure != false %}
|
|
47
47
|
data-track-zz-exposure="true"
|
|
48
48
|
{% endif %}
|
|
49
|
-
data-zz-module-name="faq"
|
|
49
|
+
data-zz-module-name="faq-id"
|
|
50
50
|
class="faq-custom max-lg:tw-px-[20px] lg:tw-mx-auto lg:tw-w-[95.3125vw] xl:tw-w-[1220px] fade-in-box">
|
|
51
51
|
{% render 'content-h2',
|
|
52
52
|
title_color: section.settings.title_color,
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
{% schema %}
|
|
2
|
+
{
|
|
3
|
+
"name": "页面内容导航",
|
|
4
|
+
"tag": "section",
|
|
5
|
+
"class": "zz-content-navigation",
|
|
6
|
+
"settings": [
|
|
7
|
+
{
|
|
8
|
+
"type": "image_picker",
|
|
9
|
+
"id": "logo",
|
|
10
|
+
"label": "Logo"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "text",
|
|
14
|
+
"id": "aftershow",
|
|
15
|
+
"label": "在某个模块后显示",
|
|
16
|
+
"default": "product-buy"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "color",
|
|
20
|
+
"id": "bg",
|
|
21
|
+
"label": "背景颜色",
|
|
22
|
+
"default": "#000000"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "select",
|
|
26
|
+
"id": "text_color",
|
|
27
|
+
"options": [
|
|
28
|
+
{
|
|
29
|
+
"value": "dark",
|
|
30
|
+
"label": "深色模式"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"value": "white",
|
|
34
|
+
"label": "白色模式"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"default": "white",
|
|
38
|
+
"label": "文案颜色模式"
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
"blocks": [
|
|
42
|
+
{
|
|
43
|
+
"type": "item",
|
|
44
|
+
"name": "内容导航项",
|
|
45
|
+
"settings": [
|
|
46
|
+
{
|
|
47
|
+
"type": "text",
|
|
48
|
+
"id": "title",
|
|
49
|
+
"label": "标题"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "text",
|
|
53
|
+
"id": "module_id",
|
|
54
|
+
"label": "模块id"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"presets": [
|
|
60
|
+
{
|
|
61
|
+
"name": "page content navigation"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
{% endschema %}
|
|
66
|
+
<style>
|
|
67
|
+
#shopify-section-{{ section.id }} {
|
|
68
|
+
position: sticky;
|
|
69
|
+
height: 50px;
|
|
70
|
+
top: 0;
|
|
71
|
+
z-index: 501;
|
|
72
|
+
opacity: 0;
|
|
73
|
+
pointer-events: none;
|
|
74
|
+
transform: translateY(-100%);
|
|
75
|
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#shopify-section-{{ section.id }}.content-navigation--visible {
|
|
79
|
+
opacity: 1;
|
|
80
|
+
pointer-events: auto;
|
|
81
|
+
transform: translateY(0);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#shopify-section-{{ section.id }} .content-navigation-item--active {
|
|
85
|
+
opacity: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#shopify-section-{{ section.id }} .nav-swiper-shadow {
|
|
89
|
+
position: relative;
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* 移动端导航箭头位置 */
|
|
94
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-prev,
|
|
95
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-next {
|
|
96
|
+
position: absolute;
|
|
97
|
+
top: 0;
|
|
98
|
+
bottom: 0;
|
|
99
|
+
width: 24px;
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
z-index: 40;
|
|
104
|
+
pointer-events: auto;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* 阴影加在左右箭头的伪元素上 */
|
|
108
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-prev::before,
|
|
109
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-next::before {
|
|
110
|
+
content: '';
|
|
111
|
+
position: absolute;
|
|
112
|
+
top: 0;
|
|
113
|
+
bottom: 0;
|
|
114
|
+
width: 40px;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
z-index: -1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* 左侧渐变阴影,从左箭头往内容方向淡出 */
|
|
120
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-prev::before {
|
|
121
|
+
left: -4px;
|
|
122
|
+
background: linear-gradient(
|
|
123
|
+
to right,
|
|
124
|
+
{{ section.settings.bg }} 0%,
|
|
125
|
+
rgba(0, 0, 0, 0) 70%
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* 右侧渐变阴影,从右箭头往内容方向淡出 */
|
|
130
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-next::before {
|
|
131
|
+
right: -4px;
|
|
132
|
+
background: linear-gradient(
|
|
133
|
+
to left,
|
|
134
|
+
{{ section.settings.bg }} 0%,
|
|
135
|
+
rgba(0, 0, 0, 0) 70%
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-prev {
|
|
141
|
+
left: -4px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
#shopify-section-{{ section.id }} .nav-swiper-button-next {
|
|
145
|
+
right: -4px;
|
|
146
|
+
}
|
|
147
|
+
{% comment %}
|
|
148
|
+
#shopify-section-{{ section.id }} {
|
|
149
|
+
scroll-behavior: auto ;
|
|
150
|
+
} {% endcomment %}
|
|
151
|
+
</style>
|
|
152
|
+
|
|
153
|
+
<!-- PC端 -->
|
|
154
|
+
<div
|
|
155
|
+
data-track-zz-section="page_content_nav"
|
|
156
|
+
class='content-navigation content-navigation-pc tw-h-[50px] max-lg:tw-hidden'
|
|
157
|
+
style='background-color: {{ section.settings.bg }};'
|
|
158
|
+
>
|
|
159
|
+
<div class=' tw-max-w-[1660px] lg:tw-px-[20px] tw-w-full tw-mx-auto tw-h-full tw-flex tw-items-center tw-justify-between'>
|
|
160
|
+
<div class='content-navigation-logo'>
|
|
161
|
+
{% if section.settings.logo != blank %}
|
|
162
|
+
{{
|
|
163
|
+
section.settings.logo
|
|
164
|
+
| image_url: width: 200
|
|
165
|
+
| image_tag: class: 'tw-w-auto tw-h-[12px]'
|
|
166
|
+
}}
|
|
167
|
+
{% endif %}
|
|
168
|
+
</div>
|
|
169
|
+
<div class='content-navigation-items tw-flex tw-items-center tw-space-x-[20px]'>
|
|
170
|
+
{% for block in section.blocks %}
|
|
171
|
+
<button
|
|
172
|
+
data-module-id='{{ block.settings.module_id }}'
|
|
173
|
+
data-track-zz-element='quick_nav_{{ block.settings.module_id | downcase}}'
|
|
174
|
+
class='content-navigation-item tw-opacity-[0.6] {% if section.settings.text_color == 'white' %} tw-text-white {% else %} tw-text-black {% endif %} tw-text-[14px] tw-font-medium'
|
|
175
|
+
>
|
|
176
|
+
{{ block.settings.title }}
|
|
177
|
+
</button>
|
|
178
|
+
{%- if forloop.last == false -%}
|
|
179
|
+
<div class='tw-w-[1px] tw-h-[16px] tw-bg-[#9E9E9E]'> </div>
|
|
180
|
+
{%- endif -%}
|
|
181
|
+
{% endfor %}
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<!-- 移动端 -->
|
|
187
|
+
<div
|
|
188
|
+
data-track-zz-section="page_content_nav"
|
|
189
|
+
class='content-navigation content-navigation-mobile lg:tw-hidden tw-px-[20px]'
|
|
190
|
+
style='background-color: {{ section.settings.bg }};'
|
|
191
|
+
>
|
|
192
|
+
<div class='tw-py-[12px]'>
|
|
193
|
+
{% if section.settings.logo != blank %}
|
|
194
|
+
{{
|
|
195
|
+
section.settings.logo
|
|
196
|
+
| image_url: width: 200
|
|
197
|
+
| image_tag: class: 'tw-h-[10px] tw-object-contain tw-w-auto'
|
|
198
|
+
}}
|
|
199
|
+
{% endif %}
|
|
200
|
+
</div>
|
|
201
|
+
<div class='nav-swiper-shadow'>
|
|
202
|
+
<div class=' swiper'>
|
|
203
|
+
<div class='swiper-wrapper tw-px-[20px]'>
|
|
204
|
+
{% for block in section.blocks %}
|
|
205
|
+
<div class='swiper-slide tw-py-[12px] tw-max-w-[30vw]'>
|
|
206
|
+
<button
|
|
207
|
+
data-module-id='{{ block.settings.module_id }}'
|
|
208
|
+
data-track-zz-element='quick_nav_{{ block.settings.module_id | downcase }}'
|
|
209
|
+
class='content-navigation-item tw-opacity-[0.6] tw-w-full tw-text-center {% if section.settings.text_color == 'white' %} tw-text-white {% else %} tw-text-black {% endif %} tw-text-[13px] tw-font-medium'
|
|
210
|
+
>
|
|
211
|
+
{{ block.settings.title }}
|
|
212
|
+
</button>
|
|
213
|
+
</div>
|
|
214
|
+
{% endfor %}
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<div class="nav-swiper-button-prev">
|
|
218
|
+
<svg
|
|
219
|
+
width='24'
|
|
220
|
+
height='24'
|
|
221
|
+
viewBox='0 0 24 24'
|
|
222
|
+
fill='none'
|
|
223
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
224
|
+
>
|
|
225
|
+
{% if section.settings.text_color == 'white' %}
|
|
226
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 12L14.0711 4.92893L14.0608 7.11487L9.17571 12L14.0711 16.8718L14.0711 19.0711L7 12Z" fill="white"/>
|
|
227
|
+
{% else %}
|
|
228
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 12L14.0711 4.92893L14.0608 7.11487L9.17571 12L14.0711 16.8718L14.0711 19.0711L7 12Z" fill="black"/>
|
|
229
|
+
{% endif %}
|
|
230
|
+
|
|
231
|
+
</svg>
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
<div class="nav-swiper-button-next">
|
|
235
|
+
<svg
|
|
236
|
+
width='24'
|
|
237
|
+
height='24'
|
|
238
|
+
viewBox='0 0 24 24'
|
|
239
|
+
fill='none'
|
|
240
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
241
|
+
>
|
|
242
|
+
{% if section.settings.text_color == 'white' %}
|
|
243
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M17 12L9.92893 4.92893L9.93916 7.11487L14.8243 12L9.92893 16.8718L9.92893 19.0711L17 12Z" fill="white"/>
|
|
244
|
+
{% else %}
|
|
245
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M17 12L9.92893 4.92893L9.93916 7.11487L14.8243 12L9.92893 16.8718L9.92893 19.0711L17 12Z" fill="black"/>
|
|
246
|
+
{% endif %}
|
|
247
|
+
</svg>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
<script>
|
|
254
|
+
document.addEventListener('DOMContentLoaded', (event) => {
|
|
255
|
+
const isDesktop = window.innerWidth > 1024;
|
|
256
|
+
const currentSection = document.getElementById(
|
|
257
|
+
'shopify-section-{{ section.id }}'
|
|
258
|
+
);
|
|
259
|
+
let exposure = false;
|
|
260
|
+
// 显示逻辑
|
|
261
|
+
const afterShowModuleName = '{{ section.settings.aftershow | strip | escape }}';
|
|
262
|
+
const isDesignMode =
|
|
263
|
+
typeof Shopify !== 'undefined' && Shopify.designMode === true;
|
|
264
|
+
|
|
265
|
+
if (currentSection) {
|
|
266
|
+
if (!afterShowModuleName || isDesignMode) {
|
|
267
|
+
currentSection.classList.add('content-navigation--visible');
|
|
268
|
+
} else {
|
|
269
|
+
const afterShowTarget = document.querySelector(
|
|
270
|
+
`[data-zz-module-name="${afterShowModuleName}"]`
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
if (afterShowTarget) {
|
|
274
|
+
const afterShowObserver = new IntersectionObserver(
|
|
275
|
+
(entries) => {
|
|
276
|
+
entries.forEach((entry) => {
|
|
277
|
+
const shouldShow = entry.boundingClientRect.bottom <= 0;
|
|
278
|
+
console.log('shouldShow', shouldShow);
|
|
279
|
+
const element = currentSection.querySelector('[data-track-zz-section="page_content_nav"]');
|
|
280
|
+
const hpm = window.zzGetElementHpm ? zzGetElementHpm(element, 'section') : null;
|
|
281
|
+
if (!exposure && shouldShow && hpm) {
|
|
282
|
+
exposure = true; // 只触发一次曝光
|
|
283
|
+
window.zzAnalytics && window.zzAnalytics.trackEvent('exposure', {
|
|
284
|
+
page_element: {
|
|
285
|
+
hpm,
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
currentSection.classList.toggle(
|
|
291
|
+
'content-navigation--visible',
|
|
292
|
+
shouldShow
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
root: null,
|
|
298
|
+
rootMargin: '0px 0px -200px 0px',
|
|
299
|
+
threshold: 0,
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
afterShowObserver.observe(afterShowTarget);
|
|
304
|
+
} else {
|
|
305
|
+
currentSection.classList.add('content-navigation--visible');
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
const navItems = currentSection.querySelectorAll('.content-navigation-item');
|
|
312
|
+
const sections = [];
|
|
313
|
+
let swiper = null;
|
|
314
|
+
const moduleIdToSlideIndex = {};
|
|
315
|
+
|
|
316
|
+
navItems.forEach((item) => {
|
|
317
|
+
const id = item.getAttribute('data-module-id');
|
|
318
|
+
if (!id) return;
|
|
319
|
+
|
|
320
|
+
const target = document.querySelector(`[data-zz-module-name="${id}"]`);
|
|
321
|
+
if (!target) return;
|
|
322
|
+
|
|
323
|
+
sections.push(target);
|
|
324
|
+
|
|
325
|
+
item.addEventListener('click', (e) => {
|
|
326
|
+
e.preventDefault();
|
|
327
|
+
const headerHeight = isDesktop ? 64 : 82;
|
|
328
|
+
const rect = target.getBoundingClientRect();
|
|
329
|
+
const offsetTop = rect.top + window.pageYOffset - headerHeight;
|
|
330
|
+
|
|
331
|
+
window.scrollTo({ top: offsetTop, behavior: 'smooth' })
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
if (sections.length) {
|
|
336
|
+
const observerOptions = {
|
|
337
|
+
root: null,
|
|
338
|
+
rootMargin: '0px 0px -200px 0px',
|
|
339
|
+
threshold: 0.1,
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const observer = new IntersectionObserver((entries) => {
|
|
343
|
+
entries.forEach((entry) => {
|
|
344
|
+
if (!entry.isIntersecting) return;
|
|
345
|
+
|
|
346
|
+
const id = entry.target.dataset.zzModuleName;
|
|
347
|
+
navItems.forEach((item) => {
|
|
348
|
+
const isActive = item.getAttribute('data-module-id') === id;
|
|
349
|
+
item.classList.toggle('content-navigation-item--active', isActive);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
if (swiper && moduleIdToSlideIndex[id] != null) {
|
|
353
|
+
const targetIndex = moduleIdToSlideIndex[id];
|
|
354
|
+
if (swiper.activeIndex !== targetIndex) {
|
|
355
|
+
swiper.slideTo(targetIndex);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}, observerOptions);
|
|
360
|
+
|
|
361
|
+
sections.forEach((sec) => observer.observe(sec));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/* 移动端 */
|
|
365
|
+
const swiperEl = currentSection.querySelector('.swiper');
|
|
366
|
+
const nextBtn = currentSection.querySelector('.nav-swiper-button-next');
|
|
367
|
+
const prevBtn = currentSection.querySelector('.nav-swiper-button-prev');
|
|
368
|
+
|
|
369
|
+
if (swiperEl) {
|
|
370
|
+
swiper = new Swiper(swiperEl, {
|
|
371
|
+
slidesPerView: 3.2,
|
|
372
|
+
spaceBetween: 12,
|
|
373
|
+
centeredSlides: false,
|
|
374
|
+
slidesOffsetAfter: 20,
|
|
375
|
+
navigation: {
|
|
376
|
+
nextEl: nextBtn,
|
|
377
|
+
prevEl: prevBtn,
|
|
378
|
+
},
|
|
379
|
+
clickable: true,
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const slides = swiperEl.querySelectorAll('.swiper-slide');
|
|
383
|
+
slides.forEach((slide, index) => {
|
|
384
|
+
const btn = slide.querySelector('[data-module-id]');
|
|
385
|
+
if (!btn) return;
|
|
386
|
+
const id = btn.getAttribute('data-module-id');
|
|
387
|
+
if (!id) return;
|
|
388
|
+
moduleIdToSlideIndex[id] = index;
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const updateNavState = () => {
|
|
392
|
+
const atBeginning = swiper.isBeginning;
|
|
393
|
+
const atEnd = swiper.isEnd;
|
|
394
|
+
|
|
395
|
+
if (prevBtn) {
|
|
396
|
+
prevBtn.style.display = atBeginning ? 'none' : 'flex';
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (nextBtn) {
|
|
400
|
+
nextBtn.style.display = atEnd ? 'none' : 'flex';
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
updateNavState();
|
|
405
|
+
swiper.on('slideChange', updateNavState);
|
|
406
|
+
swiper.on('resize', updateNavState);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
</script>
|