zz-shopify-components 0.35.1-beta.9 → 0.36.0

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.
@@ -521,4 +521,7 @@ body.zz-dialog-open {
521
521
  height: 0;
522
522
  display: none;
523
523
  /* Chrome/Safari/Edge */
524
- }
524
+ }
525
+ .zz-hidden {
526
+ display: none !important;
527
+ }
@@ -680,3 +680,54 @@ if (!customElements.get('zz-normal-modal')) {
680
680
 
681
681
  customElements.define('zz-normal-modal', ZZNormalModal);
682
682
  }
683
+
684
+ function updateCountryVisibility(currentCountry, marketWordList) {
685
+ console.log('updateCountryVisibility', currentCountry);
686
+ if (!currentCountry) return;
687
+
688
+ // currentCountry 当前国家记录的是PHcountry
689
+ // 查找currentCountry对应的showCountry
690
+ const selectCountry = marketWordList.find(
691
+ (item) => item.PHcountry === currentCountry
692
+ );
693
+ if (!selectCountry) return;
694
+ currentCountry = selectCountry.showCountry;
695
+ const isEuropeCountry = selectCountry.formState === 'Europe';
696
+
697
+ // visibleCountries 使用的是marketWordList中country字段
698
+ currentCountry = currentCountry.toUpperCase();
699
+
700
+ document.querySelectorAll('[data-visibility-rule]').forEach((element) => {
701
+ if (!element.dataset.visibilityCountries) return;
702
+
703
+ const rule = element.dataset.visibilityRule;
704
+ const countries = (element.dataset.visibilityCountries || '')
705
+ .split(',')
706
+ .map((item) => item.trim().toUpperCase())
707
+ .filter(Boolean);
708
+ const isMatchedCountry =
709
+ countries.includes(currentCountry) ||
710
+ (countries.includes('EU') && isEuropeCountry);
711
+
712
+ let visible = true;
713
+
714
+ switch (rule) {
715
+ case 'country_only':
716
+ visible = isMatchedCountry;
717
+ break;
718
+
719
+ case 'country_exclude':
720
+ visible = !isMatchedCountry;
721
+ break;
722
+
723
+ default:
724
+ visible = true;
725
+ }
726
+
727
+ if (visible) {
728
+ element.classList.remove('zz-hidden');
729
+ } else {
730
+ element.classList.add('zz-hidden');
731
+ }
732
+ });
733
+ }
@@ -143,27 +143,27 @@ document.addEventListener('DOMContentLoaded', () => {
143
143
  ease: 'power1.out',
144
144
  });
145
145
  });
146
- });
147
146
 
148
- // 跟随滚动缓慢显示
149
- const slowReveal = document.querySelectorAll('.slow-reveal');
150
- slowReveal.forEach((element) => {
151
- // 过滤出不包含 no-fade-in 类名的子元素
152
- const children = Array.from(element.children).filter(
153
- (child) => !child.classList.contains('no-fade-in')
154
- );
155
- gsap.from(children, {
156
- scrollTrigger: {
157
- trigger: element,
158
- start: 'top 80%',
159
- end: 'top 60%',
160
- scrub: 1, // 平滑跟随滚动
161
- toggleActions: 'play none none reverse',
162
- },
163
- opacity: 1,
164
- y: 100,
165
- duration: 0.4,
166
- stagger: 0.1,
167
- ease: 'power1.out',
147
+ // 跟随滚动缓慢显示
148
+ const slowReveal = document.querySelectorAll('.slow-reveal');
149
+ slowReveal.forEach((element) => {
150
+ // 过滤出不包含 no-fade-in 类名的子元素
151
+ const children = Array.from(element.children).filter(
152
+ (child) => !child.classList.contains('no-fade-in')
153
+ );
154
+ gsap.from(children, {
155
+ scrollTrigger: {
156
+ trigger: element,
157
+ start: 'top 80%',
158
+ end: 'top 60%',
159
+ scrub: 1, // 平滑跟随滚动
160
+ toggleActions: 'play none none reverse',
161
+ },
162
+ opacity: 1,
163
+ y: 100,
164
+ duration: 0.4,
165
+ stagger: 0.1,
166
+ ease: 'power1.out',
167
+ });
168
168
  });
169
169
  });
@@ -299,9 +299,26 @@
299
299
  "default": false,
300
300
  "info": "勾选后会对Block模块进行曝光统计埋点, 必须填写唯一业务id"
301
301
  },
302
-
303
-
304
-
302
+ {
303
+ "type": "select",
304
+ "id": "visibility_rule",
305
+ "label": "国家显示规则",
306
+ "options": [
307
+ { "value": "all", "label": "All" },
308
+ { "value": "market_only", "label": "Market Only" },
309
+ { "value": "market_exclude", "label": "Market Exclude" },
310
+ { "value": "country_only", "label": "Country Only" },
311
+ { "value": "country_exclude", "label": "Country Exclude" }
312
+ ],
313
+ "default": "all",
314
+ "info": "Market Only仅显示在xx国家或市场/Market Exclude排除xx国家或市场显示"
315
+ },
316
+ {
317
+ "type": "text",
318
+ "id": "visibility_countries",
319
+ "label": "国家/Market 列表",
320
+ "info": "支持国家ISO码与国家选择器中国家配置"
321
+ }
305
322
  ],
306
323
  "blocks": [
307
324
  {
@@ -683,17 +700,50 @@
683
700
  }
684
701
  }
685
702
  </style>
703
+ {% liquid
704
+ assign current_iso_code = localization.country.iso_code
705
+ assign visible = true
706
+
707
+ if block.settings.visibility_rule == 'market_only'
708
+ unless block.settings.visibility_countries contains current_iso_code
709
+ assign visible = false
710
+ endunless
711
+ elsif block.settings.visibility_rule == 'market_exclude'
712
+ if block.settings.visibility_countries contains current_iso_code
713
+ assign visible = false
714
+ endif
715
+ endif
686
716
 
717
+ if block.settings.visibility_rule == 'country_exclude'
718
+ if block.settings.visibility_countries contains 'EU'
719
+ assign eu_countries = "FR,ES,IT,DE"
720
+ assign eu_countries_array = eu_countries | split: ","
721
+ if eu_countries_array contains current_iso_code
722
+ assign visible = false
723
+ endif
724
+ endif
725
+ endif
726
+ %}
727
+ {% if visible %}
687
728
  <div
688
729
  {% if block.settings.module_name != blank %}
689
730
  data-zz-module-name="{{ block.settings.module_name }}"
690
731
  {% endif %}
691
732
  {% if block.settings.module_id != blank %}
692
- data-track-zz-block="{{ block.settings.module_id }}"
693
- {% endif %}
694
- {% if block.settings.is_exposure != false %}
695
- data-track-zz-exposure="true"
696
- {% endif %}
733
+ id="{{ block.settings.module_id }}"
734
+ data-track-zz-block="{{ block.settings.module_id }}"
735
+ {% endif %}
736
+
737
+ {% if block.settings.is_exposure != false %}
738
+ data-track-zz-exposure="true"
739
+ {% endif %}
740
+ {% if block.settings.visibility_rule == 'country_only' or block.settings.visibility_rule == 'country_exclude' %}
741
+ data-visibility-rule="{{ block.settings.visibility_rule }}"
742
+ {% endif %}
743
+ {% if block.settings.visibility_countries != blank %}
744
+ data-visibility-countries="{{ block.settings.visibility_countries | escape }}"
745
+ {% endif %}
697
746
  class="flex-layout-block-container {{ block.settings.self_animation }} {{ block.settings.child_animation }} {{ block.settings.custom_class }} flex-layout-block-container-{{ block.id }}">
698
747
  {% content_for 'blocks' %}
699
748
  </div>
749
+ {% endif %}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zz-shopify-components",
3
- "version": "0.35.1-beta.9",
3
+ "version": "0.36.0",
4
4
  "description": "Reusable Shopify components for theme projects",
5
5
  "keywords": [
6
6
  "shopify",
@@ -197,6 +197,26 @@
197
197
  "label": "模块名称",
198
198
  "info": "用于定位到本模块,可多个section使用同一名称"
199
199
  },
200
+ {
201
+ "type": "select",
202
+ "id": "visibility_rule",
203
+ "label": "国家显示规则",
204
+ "options": [
205
+ { "value": "all", "label": "All" },
206
+ { "value": "market_only", "label": "Market Only" },
207
+ { "value": "market_exclude", "label": "Market Exclude" },
208
+ { "value": "country_only", "label": "Country Only" },
209
+ { "value": "country_exclude", "label": "Country Exclude" }
210
+ ],
211
+ "default": "all",
212
+ "info": "Market Only仅显示在xx国家或市场/Market Exclude排除xx国家或市场显示"
213
+ },
214
+ {
215
+ "type": "text",
216
+ "id": "visibility_countries",
217
+ "label": "国家/Market 列表",
218
+ "info": "支持国家ISO码与国家选择器中国家配置"
219
+ }
200
220
  ],
201
221
  "blocks": [
202
222
  {
@@ -274,12 +294,43 @@
274
294
  }
275
295
  }
276
296
  </style>
297
+ {% liquid
298
+ assign current_iso_code = localization.country.iso_code
299
+ assign visible = true
300
+
301
+ if section.settings.visibility_rule == 'market_only'
302
+ unless section.settings.visibility_countries contains current_iso_code
303
+ assign visible = false
304
+ endunless
305
+ elsif section.settings.visibility_rule == 'market_exclude'
306
+ if section.settings.visibility_countries contains current_iso_code
307
+ assign visible = false
308
+ endif
309
+ endif
310
+
277
311
 
312
+ if section.settings.visibility_rule == 'country_exclude'
313
+ if section.settings.visibility_countries contains 'EU'
314
+ assign eu_countries = "FR,ES,IT,DE"
315
+ assign eu_countries_array = eu_countries | split: ","
316
+ if eu_countries_array contains current_iso_code
317
+ assign visible = false
318
+ endif
319
+ endif
320
+ endif
321
+ %}
322
+ {% if visible %}
278
323
  <div
279
324
  {% if section.settings.module_id != blank %}
280
325
  id="{{ section.settings.module_id }}"
281
326
  data-track-zz-section="{{ section.settings.module_id }}"
282
327
  {% endif %}
328
+ {% if section.settings.visibility_rule == 'country_only' or section.settings.visibility_rule == 'country_exclude' %}
329
+ data-visibility-rule="{{ section.settings.visibility_rule }}"
330
+ {% endif %}
331
+ {% if section.settings.visibility_countries != blank %}
332
+ data-visibility-countries="{{ section.settings.visibility_countries | escape }}"
333
+ {% endif %}
283
334
  {% if section.settings.is_exposure != false%}
284
335
  data-track-zz-exposure="true"
285
336
  {% endif %}
@@ -287,3 +338,4 @@
287
338
  {% if section.settings.module_name != blank %}data-zz-module-name="{{ section.settings.module_name }}"{% endif %}>
288
339
  {% content_for 'blocks' %}
289
340
  </div>
341
+ {% endif %}