zz-shopify-components 0.0.1-beta.1

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.
Files changed (61) hide show
  1. package/README.md +12 -0
  2. package/assets/fade-in-content.js +169 -0
  3. package/assets/gsap.min.js +11 -0
  4. package/assets/http-request.js +73 -0
  5. package/assets/jquery.js +2 -0
  6. package/assets/lozad.js +10 -0
  7. package/assets/site-jump.js +52 -0
  8. package/assets/site-jumpV2.js +35 -0
  9. package/assets/swiper-bundle.min.css +13 -0
  10. package/assets/swiper-bundle.min.js +14 -0
  11. package/assets/swiper.css +331 -0
  12. package/assets/zz-components.css +323 -0
  13. package/assets/zz-components.js +166 -0
  14. package/blocks/zz-accessories-item.liquid +183 -0
  15. package/blocks/zz-accessories-swiper.liquid +223 -0
  16. package/blocks/zz-button.liquid +189 -0
  17. package/blocks/zz-content-description-html.liquid +199 -0
  18. package/blocks/zz-content-description.liquid +200 -0
  19. package/blocks/zz-flex-layout-bg-block.liquid +520 -0
  20. package/blocks/zz-flex-layout-block.liquid +545 -0
  21. package/blocks/zz-flex-layout-widget.liquid +318 -0
  22. package/blocks/zz-full-screen-swiper.liquid +444 -0
  23. package/blocks/zz-icon.liquid +46 -0
  24. package/blocks/zz-mail.liquid +135 -0
  25. package/blocks/zz-mb-swiper-pc-flex.liquid +270 -0
  26. package/blocks/zz-ratio-image.liquid +177 -0
  27. package/blocks/zz-ratio-video.liquid +112 -0
  28. package/blocks/zz-responsive-width-image.liquid +219 -0
  29. package/blocks/zz-responsive-width-video.liquid +163 -0
  30. package/blocks/zz-scroll-animate-bg-text.liquid +265 -0
  31. package/blocks/zz-scroll-cover.liquid +64 -0
  32. package/blocks/zz-tag.liquid +48 -0
  33. package/blocks/zz-text.liquid +225 -0
  34. package/blocks/zz-title.liquid +284 -0
  35. package/blocks/zz-video-button.liquid +81 -0
  36. package/blocks/zz-video-swiper-perview-item.liquid +216 -0
  37. package/blocks/zz-video-swiper-perview.liquid +582 -0
  38. package/component.config.json +4 -0
  39. package/package.json +23 -0
  40. package/scripts/postinstall-v2.js +47 -0
  41. package/scripts/postinstall.js +39 -0
  42. package/sections/zz-flex-layout-section.liquid +266 -0
  43. package/sections/zz-navigation-tab-v3.liquid +403 -0
  44. package/sections/zz-navigation-tab.liquid +410 -0
  45. package/sections/zz-video-collapse-swiper.liquid +522 -0
  46. package/sections/zz-video-tab-swiper.liquid +745 -0
  47. package/snippets/zz-button.liquid +70 -0
  48. package/snippets/zz-content-text.liquid +56 -0
  49. package/snippets/zz-h2.liquid +31 -0
  50. package/snippets/zz-h3.liquid +31 -0
  51. package/snippets/zz-h4.liquid +30 -0
  52. package/snippets/zz-h5.liquid +39 -0
  53. package/snippets/zz-h6.liquid +39 -0
  54. package/snippets/zz-icon.liquid +74 -0
  55. package/snippets/zz-img.liquid +44 -0
  56. package/snippets/zz-prev-next-btn.liquid +62 -0
  57. package/snippets/zz-spoke.liquid +142 -0
  58. package/snippets/zz-tag.liquid +22 -0
  59. package/snippets/zz-video-button.liquid +55 -0
  60. package/snippets/zz-video-md.liquid +117 -0
  61. package/snippets/zz-video.liquid +117 -0
@@ -0,0 +1,166 @@
1
+ class ZZRadioTabsItem extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ }
5
+
6
+ connectedCallback() {
7
+ // 创建radio input
8
+ const groupName =
9
+ this.closest('zz-radio-tabs')?.getAttribute('name') || 'option';
10
+ const type =
11
+ this.closest('zz-radio-tabs')?.getAttribute('type') || 'default';
12
+ const value = this.getAttribute('value') || '';
13
+ const slot = this.innerHTML;
14
+ this.innerHTML = `
15
+ <label class="zz-radio-tabs-wrapper">
16
+ <input type="radio" name=${groupName} value=${value}>
17
+ <div class="zz-radio-tabs-label">
18
+ ${slot}
19
+ </div>
20
+ </label>
21
+ `;
22
+ }
23
+ }
24
+
25
+ /**
26
+ * type: default, black 两种风格模式
27
+ */
28
+ class ZZRadioTabs extends HTMLElement {
29
+ constructor() {
30
+ super();
31
+ }
32
+ connectedCallback() {
33
+ // 获取组件的type属性
34
+ const type = this.getAttribute('type') || 'default';
35
+ // 给自己加class
36
+ this.classList.add('zz-radio-tabs');
37
+ this.classList.add(`zz-radio-tabs-${type}`);
38
+ }
39
+
40
+ get value() {
41
+ const selectedRadio = this.querySelector('input[type="radio"]:checked');
42
+ return selectedRadio?.value;
43
+ }
44
+
45
+ set value(val) {
46
+ const radio = this.querySelector(`input[type="radio"][value="${val}"]`);
47
+ if (radio) {
48
+ radio.checked = true;
49
+ }
50
+ }
51
+ }
52
+
53
+ // 注册自定义元素
54
+ customElements.define('zz-radio-tabs-item', ZZRadioTabsItem);
55
+ customElements.define('zz-radio-tabs', ZZRadioTabs);
56
+
57
+ // 页面加载完成后执行
58
+ document.addEventListener('DOMContentLoaded', function () {
59
+ // 点击视频播放/暂停
60
+ // 在 video 标签上添加 class='click-video-play-pause' 即可
61
+ (function () {
62
+ const videoPlayAndPause = document.querySelectorAll(
63
+ '.click-video-play-pause'
64
+ );
65
+ videoPlayAndPause.forEach((video) => {
66
+ video.classList.remove('video-play-pause');
67
+ video.addEventListener('click', function () {
68
+ if (this.paused) {
69
+ this.play();
70
+ } else {
71
+ this.pause();
72
+ }
73
+ });
74
+ });
75
+ })();
76
+ });
77
+ /**
78
+ * 视频按钮+弹窗
79
+ */
80
+ class ZZVideoBtn extends HTMLElement {
81
+ constructor() {
82
+ super();
83
+ this.togglePopup = this.togglePopup.bind(this);
84
+ this.popup = null;
85
+ }
86
+
87
+ connectedCallback() {
88
+ this.querySelectorAll('.togglePopup').forEach((el) => {
89
+ el.addEventListener('click', (event) => {
90
+ console.log('click');
91
+ if (event.target.tagName !== 'VIDEO') {
92
+ this.togglePopup();
93
+ }
94
+ });
95
+ });
96
+ this.popup = this.querySelector('.popup');
97
+
98
+ if (this.popup) {
99
+ // 将 popup 移动到 body
100
+ document.body.appendChild(this.popup);
101
+ } else {
102
+ console.error('Popup element not found.');
103
+ }
104
+ }
105
+
106
+ disconnectedCallback() {
107
+ if (this.popup && document.body.contains(this.popup)) {
108
+ document.body.removeChild(this.popup); // 清理 popup 元素
109
+ }
110
+ }
111
+
112
+ togglePopup() {
113
+ if (!this.popup) return;
114
+
115
+ const isHidden = this.popup.classList.contains('!tw-hidden');
116
+
117
+ if (isHidden) {
118
+ this.showPopup();
119
+ } else {
120
+ this.hidePopup();
121
+ }
122
+ }
123
+
124
+ showPopup() {
125
+ if (!this.popup) return;
126
+
127
+ this.popup.classList.remove('!tw-hidden');
128
+ gsap.fromTo(
129
+ this.popup,
130
+ { opacity: 0 },
131
+ {
132
+ opacity: 1,
133
+ duration: 0.3,
134
+ ease: 'linear',
135
+ backdropFilter: 'blur(30px)',
136
+ onComplete: () => {
137
+ const video = this.popup.querySelector('video');
138
+ if (video) {
139
+ video.play();
140
+ }
141
+ },
142
+ }
143
+ );
144
+ }
145
+
146
+ hidePopup() {
147
+ if (!this.popup) return;
148
+
149
+ gsap.to(this.popup, {
150
+ opacity: 0,
151
+ duration: 0.3,
152
+ ease: 'linear',
153
+ onComplete: () => {
154
+ this.popup.classList.add('!tw-hidden');
155
+ const video = this.popup.querySelector('video');
156
+ if (video) {
157
+ video.pause();
158
+ }
159
+ },
160
+ });
161
+ }
162
+ }
163
+
164
+ if (!customElements.get('zz-video-button')) {
165
+ customElements.define('zz-video-button', ZZVideoBtn);
166
+ }
@@ -0,0 +1,183 @@
1
+
2
+
3
+ <style>
4
+
5
+ #shopify-block-{{ block.id }} {
6
+ width: 320px;
7
+ height: fit-content;
8
+ }
9
+ #shopify-block-{{ block.id }} .banner-item {
10
+ position: relative;
11
+ width: 320px;
12
+ height: 438px;
13
+ box-sizing: border-box;
14
+ background: {{ block.settings.banner_bg_color }};
15
+ }
16
+
17
+ @media screen and (max-width: 1023px) {
18
+
19
+ #shopify-block-{{ block.id }} {
20
+ width: 100%;
21
+ }
22
+ #shopify-block-{{ block.id }} .banner-item {
23
+ width: 100%;
24
+ height: auto;
25
+
26
+ }
27
+
28
+ }
29
+ </style>
30
+
31
+ {% assign btn_class = 'zz-accessories-item-btn' | append: block.id %}
32
+
33
+ <div class='banner-item tw-pb-[20px] tw-px-[20px] tw-rounded-[12px] lg:tw-rounded-[16px]'>
34
+ <div class='max-lg:tw-px-[15px]'>
35
+ {% render 'zz-img',
36
+ pc_image: block.settings.image_pc,
37
+ mb_image: block.settings.image,
38
+ image_alt: block.settings.slide_title,
39
+ pc_width: 915,
40
+ mb_width: 640,
41
+ %}
42
+ </div>
43
+ <div class="lg:tw-h-[110px]">
44
+ <p
45
+ class='slide-title tw-mt-[20px] lg:tw-mt-[30px] tw-mb-[8px] tw-text-[16px] lg:tw-text-[18px] tw-leading-[1.2] tw-text-center tw-font-bold tw-text-black'
46
+ style='color: {{ block.settings.slide_title_color }};'>
47
+ {{ block.settings.slide_title }}
48
+ </p>
49
+ {% render 'zz-content-text',
50
+ text: block.settings.slide_content,
51
+ mb_text: block.settings.slide_content,
52
+ text_color: block.settings.slide_content_color,
53
+ pc_font_size: 12,
54
+ mobile_font_size: 12,
55
+ pc_text_align: 'center',
56
+ mobile_text_align: 'center',
57
+ %}
58
+ </div>
59
+ <a
60
+ class='tw-block {{ btn_class }} tw-mx-auto tw-mt-[30px] tw-px-[28px] lg:tw-px-[12px] tw-w-fit tw-h-[42px] lg:tw-h-[28px] tw-rounded-[3px] tw-cursor-pointer tw-text-white tw-font-medium tw-text-[16px] lg:tw-text-[14px] tw-leading-[42px] lg:tw-leading-[28px] tw-bg-black tw-transition hover:tw-bg-black/80'
61
+ style='background: {{ block.settings.btn_bg_color }}; color: {{ block.settings.btn_text_color }};hover: color: {{ block.settings.btn_hover_color }};'
62
+ href='{{ block.settings.url }}'
63
+ >
64
+ {{ block.settings.btn_text }}
65
+ </a>
66
+ </div>
67
+
68
+ {% if block.settings.function_type == 'link_map' %}
69
+ <script>
70
+ document.addEventListener('DOMContentLoaded', (event) => {
71
+ const btns = document.querySelectorAll('.{{ btn_class }}')
72
+ if(btns && btns[0]) {
73
+ bindSiteJump(btns[0], {{ block.settings.links | json }})
74
+ }
75
+
76
+ })
77
+ </script>
78
+ {% endif %}
79
+
80
+ {% schema %}
81
+ {
82
+ "name": "Accessories Swiper Item",
83
+ "settings": [
84
+ {
85
+ "type": "color",
86
+ "id": "banner_bg_color",
87
+ "default": "#F5F5F6",
88
+ "label": "轮播卡片背景色"
89
+ },
90
+ {
91
+ "type": "image_picker",
92
+ "id": "image_pc",
93
+ "label": "Image"
94
+ },
95
+ {
96
+ "type": "image_picker",
97
+ "id": "image",
98
+ "label": "Image(mobile)"
99
+ },
100
+ {
101
+ "type": "text",
102
+ "id": "slide_title",
103
+ "label": "标题"
104
+ },
105
+ {
106
+ "type": "color",
107
+ "id": "slide_title_color",
108
+ "default": "#000000",
109
+ "label": "标题颜色"
110
+ },
111
+ {
112
+ "type": "richtext",
113
+ "id": "slide_content",
114
+ "label": "内容"
115
+ },
116
+ {
117
+ "type": "color",
118
+ "id": "slide_content_color",
119
+ "default": "#170B01",
120
+ "label": "内容颜色"
121
+ },
122
+ {
123
+ "type": "text",
124
+ "id": "btn_text",
125
+ "label": "按钮文字",
126
+ "default": "Buy Now"
127
+ },
128
+ {
129
+ "type": "color",
130
+ "id": "btn_bg_color",
131
+ "default": "#000000",
132
+ "label": "按钮背景颜色"
133
+ },
134
+ {
135
+ "type": "color",
136
+ "id": "btn_hover_color",
137
+ "default": "#000000",
138
+ "label": "按钮hover颜色"
139
+ },
140
+ {
141
+ "type": "color",
142
+ "id": "btn_text_color",
143
+ "default": "#FFFFFF",
144
+ "label": "按钮文字颜色"
145
+ },
146
+ {
147
+ "type": "select",
148
+ "id": "function_type",
149
+ "label": "功能类型",
150
+ "options": [
151
+ {
152
+ "value": "link",
153
+ "label": "链接"
154
+ },
155
+ {
156
+ "value": "link_map",
157
+ "label": "多国家映射"
158
+ },
159
+ ],
160
+ "default": "link"
161
+ },
162
+ {
163
+ "type": "url",
164
+ "id": "url",
165
+ "label": "按钮链接",
166
+ "visible_if": "{{ block.settings.function_type == 'link' }}"
167
+ },
168
+ {
169
+ "type": "textarea",
170
+ "id": "links",
171
+ "label": "Sites Link Map",
172
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
173
+ "visible_if": "{{ block.settings.function_type == 'link_map' }}"
174
+ },
175
+ ],
176
+
177
+ "presets": [
178
+ {
179
+ "name": "配件 Item"
180
+ }
181
+ ]
182
+ }
183
+ {% endschema %}
@@ -0,0 +1,223 @@
1
+ {% assign block_size = block.blocks.size %}
2
+ {% assign bullets_width_half = block_size
3
+ | minus: 1
4
+ | times: 14
5
+ | plus: 6
6
+ | divided_by: 2.0
7
+ | ceil
8
+ %}
9
+ {% assign btn_offset = bullets_width_half | plus: 14 | plus: 36 %}
10
+
11
+ {% assign btn_offset_pc = bullets_width_half | plus: 18 | plus: 48 %}
12
+
13
+ <style>
14
+ #shopify-block-{{ block.id }} {
15
+ width: 100%;
16
+ }
17
+ #shopify-block-{{ block.id }} .zz-accessories-swiper {
18
+ padding-top: 32px;
19
+ width: 100%;
20
+ height: fit-content;
21
+ background: {{ block.settings.bg_color }};
22
+ letter-spacing: 0;
23
+ }
24
+
25
+ #shopify-block-{{ block.id }} .zz-accessories-swiper .swiper-slide {
26
+ width: 320px;
27
+ height: fit-content;
28
+ }
29
+
30
+ #shopify-block-{{ block.id }} .swiper-button-next,
31
+ #shopify-block-{{ block.id }} .swiper-button-prev {
32
+ z-index: 99;
33
+ top: unset;
34
+ bottom: 0;
35
+ width: 48px;
36
+ height: 48px;
37
+ }
38
+ #shopify-block-{{ block.id }} .swiper-button-prev {
39
+ left: 50%;
40
+ transform: translate(-{{ btn_offset_pc }}px, 0px);
41
+ }
42
+ #shopify-block-{{ block.id }} .swiper-button-next {
43
+ right: 50%;
44
+ transform: translate({{ btn_offset_pc }}px, 0px);
45
+ }
46
+ #shopify-block-{{ block.id }} .swiper-button-next:after,
47
+ #shopify-block-{{ block.id }} .swiper-button-prev:after {
48
+ display: none;
49
+ }
50
+ #shopify-block-{{ block.id }} .swiper-button-next.swiper-button-disabled, #shopify-block-{{ block.id }} .swiper-button-prev.swiper-button-disabled {
51
+ opacity: 0.5;
52
+ }
53
+ #shopify-block-{{ block.id }} .zz-accessories-swiper .swiper-pagination-bullets {
54
+ bottom: 11px;
55
+ }
56
+ #shopify-block-{{ block.id }} .zz-accessories-swiper .swiper-pagination-bullets .swiper-pagination-bullet {
57
+ margin: 0 6px;
58
+ width: 6px;
59
+ height: 6px;
60
+ background-color: {{ block.settings.pagination_color }};
61
+ opacity: 0.5;
62
+ }
63
+ #shopify-block-{{ block.id }} .zz-accessories-swiper .swiper-pagination-bullets .swiper-pagination-bullet-active {
64
+ opacity: 1;
65
+ }
66
+
67
+ @media screen and (min-width: 1024px) {
68
+ #shopify-block-{{ block.id }} .zz-accessories-swiper {
69
+ padding-top: 64px;
70
+ padding-bottom: 108px;
71
+ }
72
+ }
73
+
74
+ @media screen and (max-width: 1023px) {
75
+ #shopify-block-{{ block.id }} .zz-accessories-swiper {
76
+ padding: 0px 20px 60px 20px;
77
+ box-sizing: border-box;
78
+ }
79
+ #shopify-block-{{ block.id }} .zz-accessories-swiper .swiper-slide {
80
+ width: 100%;
81
+ }
82
+
83
+ #shopify-block-{{ block.id }} .swiper-button-next,
84
+ #shopify-block-{{ block.id }} .swiper-button-prev {
85
+ width: 36px;
86
+ height: 36px;
87
+ }
88
+ #shopify-block-{{ block.id }} .swiper-button-prev {
89
+ left: 50%;
90
+ transform: translate(-{{ btn_offset }}px, 0px);
91
+ }
92
+ #shopify-block-{{ block.id }} .swiper-button-next {
93
+ right: 50%;
94
+ transform: translate({{ btn_offset }}px, 0px);
95
+ }
96
+ #shopify-block-{{ block.id }} .zz-accessories-swiper .swiper-pagination-bullets {
97
+ bottom: 9px;
98
+ }
99
+
100
+ #shopify-block-{{ block.id }} .zz-accessories-swiper .swiper-pagination-bullets .swiper-pagination-bullet {
101
+ margin: 0 4px;
102
+ width: 6px;
103
+ height: 6px;
104
+ }
105
+ }
106
+ </style>
107
+
108
+ <div
109
+ class='swiper zz-accessories-swiper'
110
+ data-id='{{ block.id }}'
111
+ >
112
+ <div class='swiper-wrapper'>
113
+ {% content_for 'blocks' %}
114
+ </div>
115
+ <!-- If we need navigation buttons -->
116
+ <div class='swiper-button-prev {% if block_size <= 1 %} tw-hidden {% endif %}'>
117
+ {% if block.settings.prev_icon != blank %}
118
+ {{
119
+ block.settings.prev_icon
120
+ | image_url: width: 48
121
+ | image_tag:
122
+ alt: 'prev',
123
+ class: 'tw-w-full tw-h-full tw-object-contain'
124
+ }}
125
+ {% else %}
126
+ {% render 'icon-prev' %}
127
+ {% endif %}
128
+ </div>
129
+ <div class='swiper-button-next {% if block_size <= 1 %} tw-hidden {% endif %}'>
130
+ {% if block.settings.next_icon != blank %}
131
+ {{
132
+ block.settings.next_icon
133
+ | image_url: width: 48
134
+ | image_tag:
135
+ alt: 'prev',
136
+ class: 'tw-w-full tw-h-full tw-object-contain'
137
+ }}
138
+ {% else %}
139
+ {% render 'icon-next' %}
140
+ {% endif %}
141
+ </div>
142
+
143
+ <!-- Pagination indicator -->
144
+ <div class='swiper-pagination'></div>
145
+ </div>
146
+
147
+
148
+ <script>
149
+ const blockId = '{{ block.id }}';
150
+ document.addEventListener('DOMContentLoaded', function () {
151
+ // 轮播图每个 wrapper 之间的间距
152
+ let isDesktop = window.innerWidth > 1023;
153
+
154
+ // 获取 class zz-accessories-swiper 的元素 且data-id 为 block.id 的元素
155
+ const zzAccessoriesSwiper = document.querySelector(`.zz-accessories-swiper[data-id='${blockId}']`);
156
+ const swiperWrapper = zzAccessoriesSwiper.querySelector('.swiper-wrapper');
157
+ // 获取当前 swiper-wrapper 下面 所有 第一层 div
158
+ const swiperSlides = swiperWrapper.querySelectorAll(':scope > div');
159
+ // 给每个 swiper-slide 添加 class swiper-slide
160
+ swiperSlides.forEach(slide => {
161
+ slide.classList.add('swiper-slide');
162
+ });
163
+ setTimeout(() => {
164
+ const bannerAccessoriesSwiper = new Swiper('.zz-accessories-swiper', {
165
+ initialSlide: isDesktop ? 1 : 0,
166
+ slidesPerView: 'auto',
167
+ centeredSlides: true,
168
+ spaceBetween: isDesktop ? 24 : 8,
169
+ navigation: {
170
+ nextEl: '.swiper-button-next',
171
+ prevEl: '.swiper-button-prev',
172
+ },
173
+ pagination: {
174
+ el: '.swiper-pagination',
175
+ clickable: true,
176
+ },
177
+ effect: 'slide',
178
+ });
179
+ }, 200)
180
+ });
181
+ </script>
182
+
183
+ {% schema %}
184
+ {
185
+ "name": "Accessories Swiper Block",
186
+ "settings": [
187
+ {
188
+ "type": "color",
189
+ "id": "bg_color",
190
+ "default": "#FFFFFF",
191
+ "label": "背景色"
192
+ },
193
+
194
+ {
195
+ "type": "color",
196
+ "id": "pagination_color",
197
+ "default": "#000000",
198
+ "label": "轮播导航圆圈颜色"
199
+ },
200
+
201
+ {
202
+ "type": "image_picker",
203
+ "id": "prev_icon",
204
+ "label": "轮播上一张图标"
205
+ },
206
+ {
207
+ "type": "image_picker",
208
+ "id": "next_icon",
209
+ "label": "轮播下一张图标"
210
+ }
211
+ ],
212
+ "blocks": [
213
+ {
214
+ "type": "zz-accessories-item"
215
+ }
216
+ ],
217
+ "presets": [
218
+ {
219
+ "name": "配件轮播"
220
+ }
221
+ ]
222
+ }
223
+ {% endschema %}