@gem-sdk/components 2.0.0-dev.260 → 2.0.0-dev.265

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 (112) hide show
  1. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +3 -2
  2. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +3 -2
  3. package/dist/cjs/grid/row/setting/configs/settings.js +9 -83
  4. package/dist/cjs/grid/section/setting/configs/settings.js +13 -75
  5. package/dist/cjs/icon/setting/configs/uiV2.js +1 -1
  6. package/dist/cjs/icon-list-hoz/setting/configs/settings.js +4 -17
  7. package/dist/cjs/line/setting/configs/settings.js +4 -4
  8. package/dist/cjs/post-purchase/advanced-list/setting/configs/uiV2.js +3 -15
  9. package/dist/cjs/post-purchase/line/setting/configs/settings.js +3 -1
  10. package/dist/cjs/post-purchase/line/setting/configs/uiV2.js +2 -1
  11. package/dist/cjs/post-purchase/link/components/PostPurchaseLink.js +23 -14
  12. package/dist/cjs/post-purchase/link/components/common/getClasses.js +7 -1
  13. package/dist/cjs/post-purchase/link/setting/configs/settings.js +21 -14
  14. package/dist/cjs/post-purchase/product/common/getClasses.js +45 -0
  15. package/dist/cjs/post-purchase/product/common/getStyles.js +43 -0
  16. package/dist/cjs/post-purchase/product/components/product-image/FeatureImage.js +32 -42
  17. package/dist/cjs/post-purchase/product/components/product-image/ImageListCarousel.js +6 -65
  18. package/dist/cjs/post-purchase/product/components/product-image/ImageListGrid.js +24 -68
  19. package/dist/cjs/post-purchase/product/components/product-image/ItemCarouselPostPurchase.js +42 -0
  20. package/dist/cjs/post-purchase/product/components/product-image/ItemGridPostPurchase.js +42 -0
  21. package/dist/cjs/post-purchase/product/components/product-image/carousel-post-purchase/Arrow.js +29 -0
  22. package/dist/cjs/post-purchase/product/components/product-image/carousel-post-purchase/CarouselPostPurchase.js +35 -0
  23. package/dist/cjs/post-purchase/product/components/product-image/carousel-post-purchase/CarouselPostPurchaseContext.js +22 -0
  24. package/dist/cjs/post-purchase/product/components/product-image/carousel-post-purchase/CarouselWrapperPostPurchase.js +75 -0
  25. package/dist/cjs/post-purchase/product/components/product-image/index.js +41 -43
  26. package/dist/cjs/post-purchase/product/components/product-image/layouts/FeatureImageWithGalleryImage.js +22 -58
  27. package/dist/cjs/post-purchase/product/components/product-image/layouts/OnlyGalleryImage.js +19 -12
  28. package/dist/cjs/post-purchase/product/constants/index.js +36 -0
  29. package/dist/cjs/post-purchase/product/hooks/product-image/useCarousel.js +14 -0
  30. package/dist/cjs/post-purchase/product/hooks/product-image/useFeatureImagePostPurchase.js +32 -0
  31. package/dist/cjs/post-purchase/product/hooks/product-image/useListCarousel.js +43 -0
  32. package/dist/cjs/post-purchase/product/hooks/product-image/useNavigationCarouselPostPurchase.js +32 -0
  33. package/dist/cjs/post-purchase/product/hooks/product-image/useProductImagePostPurchase.js +60 -0
  34. package/dist/cjs/post-purchase/product/hooks/product-image/useSlideCarousel.js +35 -0
  35. package/dist/cjs/post-purchase/product/settings/product-description/settingV2.js +6 -9
  36. package/dist/cjs/post-purchase/product/settings/product-image/ProductFeatureImage.js +41 -0
  37. package/dist/cjs/post-purchase/product/settings/product-image/ProductGalleryImage.js +0 -118
  38. package/dist/cjs/post-purchase/product/settings/product-image/ProductImages.js +8 -79
  39. package/dist/cjs/post-purchase/product/settings/product-image/setting-v1.js +163 -0
  40. package/dist/cjs/post-purchase/product/settings/product-image/setting-v2.js +375 -0
  41. package/dist/cjs/post-purchase/product/settings/product-image/uiV1.js +42 -0
  42. package/dist/cjs/post-purchase/product/settings/product-image/uiV2.js +235 -0
  43. package/dist/cjs/post-purchase/product/settings/product-price/uiV2.js +0 -3
  44. package/dist/cjs/post-purchase/product/settings/product-price-breakdown/configs/settings.js +10 -6
  45. package/dist/cjs/post-purchase/product/settings/product-price-breakdown/configs/uiV2.js +2 -2
  46. package/dist/cjs/post-purchase/product/settings/product-quantity/configs/settings.js +3 -1
  47. package/dist/cjs/post-purchase/product/settings/product-title/settingV2.js +6 -9
  48. package/dist/cjs/post-purchase/text/settings/text/settingV2.js +0 -7
  49. package/dist/cjs/product/components/FileUpload/components/common/index.js +3 -2
  50. package/dist/cjs/product/setting/product/configs/presets.js +1 -1
  51. package/dist/cjs/product/setting/product/configs/settings.js +10 -75
  52. package/dist/cjs/setting.js +2 -1
  53. package/dist/cjs/text/setting/configs/settings.js +1 -1
  54. package/dist/esm/banner/components/HeroBannerItem.liquid.js +3 -2
  55. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +3 -2
  56. package/dist/esm/grid/row/setting/configs/settings.js +9 -83
  57. package/dist/esm/grid/section/setting/configs/settings.js +13 -75
  58. package/dist/esm/icon/setting/configs/uiV2.js +1 -1
  59. package/dist/esm/icon-list-hoz/setting/configs/settings.js +4 -17
  60. package/dist/esm/line/setting/configs/settings.js +4 -4
  61. package/dist/esm/post-purchase/advanced-list/setting/configs/uiV2.js +3 -15
  62. package/dist/esm/post-purchase/line/setting/configs/settings.js +3 -1
  63. package/dist/esm/post-purchase/line/setting/configs/uiV2.js +2 -1
  64. package/dist/esm/post-purchase/link/components/PostPurchaseLink.js +25 -16
  65. package/dist/esm/post-purchase/link/components/common/getClasses.js +7 -2
  66. package/dist/esm/post-purchase/link/setting/configs/settings.js +21 -14
  67. package/dist/esm/post-purchase/product/common/getClasses.js +37 -1
  68. package/dist/esm/post-purchase/product/common/getStyles.js +39 -1
  69. package/dist/esm/post-purchase/product/components/product-image/FeatureImage.js +32 -42
  70. package/dist/esm/post-purchase/product/components/product-image/ImageListCarousel.js +7 -66
  71. package/dist/esm/post-purchase/product/components/product-image/ImageListGrid.js +24 -68
  72. package/dist/esm/post-purchase/product/components/product-image/ItemCarouselPostPurchase.js +40 -0
  73. package/dist/esm/post-purchase/product/components/product-image/ItemGridPostPurchase.js +40 -0
  74. package/dist/esm/post-purchase/product/components/product-image/carousel-post-purchase/Arrow.js +27 -0
  75. package/dist/esm/post-purchase/product/components/product-image/carousel-post-purchase/CarouselPostPurchase.js +33 -0
  76. package/dist/esm/post-purchase/product/components/product-image/carousel-post-purchase/CarouselPostPurchaseContext.js +19 -0
  77. package/dist/esm/post-purchase/product/components/product-image/carousel-post-purchase/CarouselWrapperPostPurchase.js +73 -0
  78. package/dist/esm/post-purchase/product/components/product-image/index.js +42 -44
  79. package/dist/esm/post-purchase/product/components/product-image/layouts/FeatureImageWithGalleryImage.js +22 -58
  80. package/dist/esm/post-purchase/product/components/product-image/layouts/OnlyGalleryImage.js +19 -12
  81. package/dist/esm/post-purchase/product/constants/index.js +34 -0
  82. package/dist/esm/post-purchase/product/hooks/product-image/useCarousel.js +12 -0
  83. package/dist/esm/post-purchase/product/hooks/product-image/useFeatureImagePostPurchase.js +30 -0
  84. package/dist/esm/post-purchase/product/hooks/product-image/useListCarousel.js +41 -0
  85. package/dist/esm/post-purchase/product/hooks/product-image/useNavigationCarouselPostPurchase.js +30 -0
  86. package/dist/esm/post-purchase/product/hooks/product-image/useProductImagePostPurchase.js +58 -0
  87. package/dist/esm/post-purchase/product/hooks/product-image/useSlideCarousel.js +33 -0
  88. package/dist/esm/post-purchase/product/settings/product-description/settingV2.js +6 -9
  89. package/dist/esm/post-purchase/product/settings/product-image/ProductFeatureImage.js +41 -0
  90. package/dist/esm/post-purchase/product/settings/product-image/ProductGalleryImage.js +1 -118
  91. package/dist/esm/post-purchase/product/settings/product-image/ProductImages.js +8 -79
  92. package/dist/esm/post-purchase/product/settings/product-image/setting-v1.js +161 -0
  93. package/dist/esm/post-purchase/product/settings/product-image/setting-v2.js +373 -0
  94. package/dist/esm/post-purchase/product/settings/product-image/uiV1.js +40 -0
  95. package/dist/esm/post-purchase/product/settings/product-image/uiV2.js +233 -0
  96. package/dist/esm/post-purchase/product/settings/product-price/uiV2.js +0 -3
  97. package/dist/esm/post-purchase/product/settings/product-price-breakdown/configs/settings.js +10 -6
  98. package/dist/esm/post-purchase/product/settings/product-price-breakdown/configs/uiV2.js +2 -2
  99. package/dist/esm/post-purchase/product/settings/product-quantity/configs/settings.js +3 -1
  100. package/dist/esm/post-purchase/product/settings/product-title/settingV2.js +6 -9
  101. package/dist/esm/post-purchase/text/settings/text/settingV2.js +0 -7
  102. package/dist/esm/product/components/FileUpload/components/common/index.js +3 -2
  103. package/dist/esm/product/setting/product/configs/presets.js +1 -1
  104. package/dist/esm/product/setting/product/configs/settings.js +10 -75
  105. package/dist/esm/setting.js +2 -1
  106. package/dist/esm/text/setting/configs/settings.js +1 -1
  107. package/dist/types/index.d.ts +12 -5
  108. package/package.json +4 -4
  109. package/dist/cjs/post-purchase/product/components/product-image/Arrow.js +0 -60
  110. package/dist/cjs/post-purchase/product/components/product-image/CarouselPostPurchase.js +0 -78
  111. package/dist/esm/post-purchase/product/components/product-image/Arrow.js +0 -58
  112. package/dist/esm/post-purchase/product/components/product-image/CarouselPostPurchase.js +0 -76
@@ -1,75 +1,39 @@
1
1
  'use client';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useMemo } from 'react';
4
- import { cls, makeStyle } from '@gem-sdk/core';
5
- import { postPurchaseSpacing } from '../../../../utils/helper.js';
6
3
  import FeatureImage from '../FeatureImage.js';
7
4
  import OnlyGalleryImage from './OnlyGalleryImage.js';
5
+ import { createStyle, createClass } from '@gem-sdk/system';
6
+ import { getFeatureImageClass, getProductImageLayoutClass } from '../../../common/getClasses.js';
7
+ import { getProductImageLayoutStyle, getAlignStyle } from '../../../common/getStyles.js';
8
+ import { useProductImagePostPurchase } from '../../../hooks/product-image/useProductImagePostPurchase.js';
8
9
 
9
10
  const FeatureImageWithGalleryImage = (productImageProps)=>{
10
- const { setting, styles, builderProps, gallery } = productImageProps;
11
+ const { setting, styles, gallery } = productImageProps;
11
12
  const settings = {
12
13
  ...setting,
13
14
  ...styles
14
15
  };
15
- const { layoutType } = settings;
16
- const isShowGalleryImages = useMemo(()=>{
17
- return gallery.length > 1;
18
- }, [
19
- gallery.length
20
- ]);
21
- const gridLayout = useMemo(()=>{
22
- let result = {
23
- '--gtc': 'minmax(0, 12fr)'
24
- };
25
- if (isShowGalleryImages) {
26
- const ratioLayout = layoutType === 'left' ? settings.ratioLayoutLeft : settings.ratioLayoutRight;
27
- const isHorizontalLayout = [
28
- 'left',
29
- 'right'
30
- ].includes(layoutType || '');
31
- if (isHorizontalLayout && ratioLayout) {
32
- result = {
33
- ...result,
34
- '--gtc': `minmax(0, ${ratioLayout[0]}fr) minmax(0, ${ratioLayout[1]}fr)`
35
- };
36
- Object.assign(result, {
37
- '--gtr': 'fit-content(0)'
38
- });
39
- }
40
- }
41
- return result;
42
- }, [
43
- isShowGalleryImages,
44
- layoutType,
45
- settings.ratioLayoutLeft,
46
- settings.ratioLayoutRight
47
- ]);
48
- const itemGap = useMemo(()=>{
49
- if (layoutType === 'bottom-center') {
50
- return postPurchaseSpacing[settings?.spacingVertical || 'none'];
51
- }
52
- return settings?.spacingHoz;
53
- }, [
16
+ const { layoutType = 'bottom-center' } = settings;
17
+ const { itemGap, gridLayout, isShowGalleryImages } = useProductImagePostPurchase({
18
+ imageList: gallery,
19
+ setting
20
+ });
21
+ const containerStyle = createStyle(getProductImageLayoutStyle({
22
+ gap: itemGap
23
+ }, gridLayout));
24
+ const style = createStyle(getAlignStyle({
54
25
  layoutType,
55
- settings?.spacingHoz,
56
- settings?.spacingVertical
57
- ]);
26
+ align: settings?.align
27
+ }));
28
+ const classes = createClass(getFeatureImageClass());
29
+ const containerClasses = createClass(getProductImageLayoutClass());
58
30
  return /*#__PURE__*/ jsxs("div", {
59
- className: cls('gp-grid gp-w-full'),
60
- style: {
61
- ...gridLayout,
62
- ...makeStyle({
63
- gg: itemGap
64
- })
65
- },
31
+ className: containerClasses,
32
+ style: containerStyle,
66
33
  children: [
67
34
  /*#__PURE__*/ jsx("div", {
68
- className: cls(`gp-flex gp-justify-center gp-h-fit gp-w-full gp-product-images-feature-${builderProps?.uid}`),
69
- style: {
70
- '--o': layoutType === 'left' ? `1` : '0',
71
- '--jc': styles?.align === 'left' ? 'flex-start' : styles?.align === 'right' ? 'flex-end' : 'center'
72
- },
35
+ className: classes,
36
+ style: style,
73
37
  children: /*#__PURE__*/ jsx(FeatureImage, {
74
38
  ...productImageProps
75
39
  })
@@ -1,28 +1,35 @@
1
1
  'use client';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useMemo } from 'react';
4
3
  import ImageListGrid from '../ImageListGrid.js';
5
4
  import ImageListCarousel from '../ImageListCarousel.js';
6
- import { cls } from '@gem-sdk/core';
5
+ import { createClass } from '@gem-sdk/system';
6
+ import { useProductImagePostPurchase } from '../../../hooks/product-image/useProductImagePostPurchase.js';
7
+ import { getOnlyFeatureLayoutClass } from '../../../common/getClasses.js';
8
+ import '@gem-sdk/core';
7
9
 
8
10
  const OnlyGalleryImage = (productImageProps)=>{
9
- const { setting, styles, gallery, builderProps } = productImageProps;
11
+ const { setting, styles, gallery } = productImageProps;
10
12
  const settings = {
11
13
  ...setting,
12
14
  ...styles
13
15
  };
14
- const { layoutType } = settings;
15
- const isImageListCarousel = useMemo(()=>{
16
- return layoutType !== 'two-col' && (layoutType === 'left' || layoutType === 'right' || settings.displayType === 'slider');
17
- }, [
18
- layoutType,
19
- settings.displayType
20
- ]);
16
+ const { isImageListCarousel } = useProductImagePostPurchase({
17
+ imageList: gallery,
18
+ setting
19
+ });
20
+ const classes = createClass(getOnlyFeatureLayoutClass());
21
21
  return /*#__PURE__*/ jsx("div", {
22
- className: cls(`gp-product-images-gallery-${builderProps?.uid} gp-flex gp-h-fit gp-max-w-full`, settings?.ilNavigation === 'none' || layoutType !== 'bottom-center' ? '' : ''),
22
+ className: classes,
23
23
  children: isImageListCarousel ? /*#__PURE__*/ jsx(ImageListCarousel, {
24
24
  ...productImageProps,
25
- productImages: gallery
25
+ productImages: gallery,
26
+ aspectRatio: settings?.ilAspectRatio,
27
+ objectFit: settings.ilObjectFit,
28
+ spacing: settings.ilSpacing,
29
+ navigation: settings?.ilNavigation,
30
+ vertical: settings?.layoutType === 'bottom-center' ? false : true,
31
+ border: settings?.ilBorder,
32
+ itemPerSlide: settings?.ilItemPerSlide
26
33
  }) : /*#__PURE__*/ jsx(ImageListGrid, {
27
34
  ...productImageProps,
28
35
  productImages: gallery
@@ -0,0 +1,34 @@
1
+ const NEXT_AND_PREV_URLS = {
2
+ PREVIOUS: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-a2eb5093-0203-4973-8ade-183d5bdefdce.svg',
3
+ NEXT: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-a5ac0286-5941-4bd7-a21d-72a6c017aeea.svg',
4
+ NEXT_DISABLED: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-a3d1f159-001d-4301-bead-214606caf995.svg',
5
+ PREVIOUS_DISABLED: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-33e3810b-a94c-40a1-a48b-4eba39013f15.svg',
6
+ VERTICAL_PREVIOUS: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-4e4e886a-5aa1-4bb3-ab48-aa7752fd5eba.svg',
7
+ VERTICAL_NEXT: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-a3c3d74c-2cde-49e5-9854-8079f5239013.svg',
8
+ VERTICAL_NEXT_DISABLED: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-6c7f10a8-a205-43bd-b39c-aab044bb3771.svg',
9
+ VERTICAL_PREVIOUS_DISABLED: 'https://cdn.shopify.com/s/files/1/0789/8018/6418/files/472169286689883168-010c3c2a-fcc3-4b09-84a2-734d924ad49b.svg'
10
+ };
11
+ const BUTTON_URL_MAP_POST_PURCHASE = {
12
+ next: {
13
+ vertical: {
14
+ disabled: NEXT_AND_PREV_URLS.VERTICAL_NEXT_DISABLED,
15
+ enabled: NEXT_AND_PREV_URLS.VERTICAL_NEXT
16
+ },
17
+ horizontal: {
18
+ disabled: NEXT_AND_PREV_URLS.NEXT_DISABLED,
19
+ enabled: NEXT_AND_PREV_URLS.NEXT
20
+ }
21
+ },
22
+ prev: {
23
+ vertical: {
24
+ disabled: NEXT_AND_PREV_URLS.VERTICAL_PREVIOUS_DISABLED,
25
+ enabled: NEXT_AND_PREV_URLS.VERTICAL_PREVIOUS
26
+ },
27
+ horizontal: {
28
+ disabled: NEXT_AND_PREV_URLS.PREVIOUS_DISABLED,
29
+ enabled: NEXT_AND_PREV_URLS.PREVIOUS
30
+ }
31
+ }
32
+ };
33
+
34
+ export { BUTTON_URL_MAP_POST_PURCHASE };
@@ -0,0 +1,12 @@
1
+ import { CarouselPostPurchaseContext } from '../../components/product-image/carousel-post-purchase/CarouselPostPurchaseContext.js';
2
+ import { useContext } from 'react';
3
+
4
+ const useCarousel = ()=>{
5
+ const context = useContext(CarouselPostPurchaseContext);
6
+ if (context === undefined) {
7
+ throw new Error('useCarousel must be used within a CarouselProvider');
8
+ }
9
+ return context;
10
+ };
11
+
12
+ export { useCarousel };
@@ -0,0 +1,30 @@
1
+ import { useCurrentVariant, useFeaturedImageGlobal, useProductStore } from '@gem-sdk/core';
2
+ import { useMemo, useEffect } from 'react';
3
+
4
+ const useFeatureImagePostPurchase = (props)=>{
5
+ const { gallery } = props;
6
+ const currentVariant = useCurrentVariant();
7
+ const featuredImageGlobal = useFeaturedImageGlobal();
8
+ const setProductFeaturedImage = useProductStore((store)=>store.setProductFeaturedImage);
9
+ const idxActive = useMemo(()=>{
10
+ if (!featuredImageGlobal) return 0;
11
+ const index = gallery.findIndex((el)=>el.id === featuredImageGlobal.id);
12
+ return index !== -1 ? index : 0;
13
+ }, [
14
+ featuredImageGlobal,
15
+ gallery
16
+ ]);
17
+ useEffect(()=>{
18
+ if (currentVariant?.media && currentVariant.media.contentType === 'IMAGE') {
19
+ setProductFeaturedImage(currentVariant.media);
20
+ }
21
+ }, [
22
+ currentVariant,
23
+ setProductFeaturedImage
24
+ ]);
25
+ return {
26
+ idxActive
27
+ };
28
+ };
29
+
30
+ export { useFeatureImagePostPurchase };
@@ -0,0 +1,41 @@
1
+ import { useCallback, useMemo } from 'react';
2
+ import { useCarousel } from './useCarousel.js';
3
+
4
+ const useListCarousel = (props)=>{
5
+ const { productImages, itemPerRow } = props;
6
+ const { moveToIdx } = useCarousel();
7
+ const list = useCallback(()=>{
8
+ const temp = [
9
+ ...productImages
10
+ ];
11
+ return temp?.splice(moveToIdx, itemPerRow);
12
+ }, [
13
+ productImages,
14
+ itemPerRow,
15
+ moveToIdx
16
+ ]);
17
+ const listRender = useMemo(()=>{
18
+ const listItem = list();
19
+ if (listItem.length < itemPerRow) {
20
+ const temp = [
21
+ ...productImages
22
+ ];
23
+ Array.from({
24
+ length: itemPerRow - listItem.length
25
+ }).forEach(()=>{
26
+ temp.push({});
27
+ });
28
+ return temp;
29
+ }
30
+ return listItem;
31
+ }, [
32
+ list,
33
+ itemPerRow,
34
+ productImages
35
+ ]);
36
+ return {
37
+ listRender
38
+ };
39
+ };
40
+
41
+ export { useListCarousel };
@@ -0,0 +1,30 @@
1
+ import { useMemo } from 'react';
2
+ import { BUTTON_URL_MAP_POST_PURCHASE } from '../../constants/index.js';
3
+ import { useCarousel } from './useCarousel.js';
4
+
5
+ const useNavigationCarouselPostPurchase = (props)=>{
6
+ const { moveToIdx, maxIdx, setMoveToIdx } = useCarousel();
7
+ const { type, vertical } = props;
8
+ const disabled = type == 'next' ? moveToIdx >= maxIdx : moveToIdx === 0;
9
+ const imgSrc = useMemo(()=>{
10
+ return BUTTON_URL_MAP_POST_PURCHASE[type][vertical ? 'vertical' : 'horizontal'][disabled ? 'disabled' : 'enabled'];
11
+ }, [
12
+ type,
13
+ vertical,
14
+ disabled
15
+ ]);
16
+ const handleClick = ()=>{
17
+ if (type === 'next') {
18
+ setMoveToIdx(moveToIdx + 1);
19
+ return;
20
+ }
21
+ setMoveToIdx(moveToIdx - 1);
22
+ };
23
+ return {
24
+ imgSrc,
25
+ handleClick,
26
+ disabled
27
+ };
28
+ };
29
+
30
+ export { useNavigationCarouselPostPurchase };
@@ -0,0 +1,58 @@
1
+ import { useMemo } from 'react';
2
+ import { postPurchaseSpacing } from '../../../utils/helper.js';
3
+
4
+ const useProductImagePostPurchase = (props)=>{
5
+ const { imageList, setting } = props;
6
+ const { layoutType = 'bottom-center', spacingVertical, spacingHoz, ratioLayoutLeft, ratioLayoutRight, displayType } = setting || {};
7
+ const isShowGalleryImages = useMemo(()=>{
8
+ return imageList.length > 1;
9
+ }, [
10
+ imageList.length
11
+ ]);
12
+ const itemGap = useMemo(()=>{
13
+ if (layoutType === 'bottom-center') return postPurchaseSpacing[spacingVertical || 'none'];
14
+ return spacingHoz;
15
+ }, [
16
+ layoutType,
17
+ spacingHoz,
18
+ spacingVertical
19
+ ]);
20
+ const gridLayout = useMemo(()=>{
21
+ const DEFAULT_RESULT = {
22
+ '--gtc': 'minmax(0, 12fr)'
23
+ };
24
+ if (!isShowGalleryImages) return DEFAULT_RESULT;
25
+ const ratioLayout = layoutType === 'left' ? ratioLayoutLeft : ratioLayoutRight;
26
+ const isHorizontalLayout = [
27
+ 'left',
28
+ 'right'
29
+ ].includes(layoutType);
30
+ if (!isHorizontalLayout || !ratioLayout) return DEFAULT_RESULT;
31
+ return {
32
+ '--gtc': `minmax(0, ${ratioLayout[0]}fr) minmax(0, ${ratioLayout[1]}fr)`,
33
+ '--gtr': 'fit-content(0)'
34
+ };
35
+ }, [
36
+ isShowGalleryImages,
37
+ layoutType,
38
+ ratioLayoutLeft,
39
+ ratioLayoutRight
40
+ ]);
41
+ const isImageListCarousel = useMemo(()=>{
42
+ return layoutType !== 'two-col' && ([
43
+ 'left',
44
+ 'right'
45
+ ].includes(layoutType) || displayType === 'slider');
46
+ }, [
47
+ layoutType,
48
+ displayType
49
+ ]);
50
+ return {
51
+ itemGap,
52
+ gridLayout,
53
+ isShowGalleryImages,
54
+ isImageListCarousel
55
+ };
56
+ };
57
+
58
+ export { useProductImagePostPurchase };
@@ -0,0 +1,33 @@
1
+ import { useMemo } from 'react';
2
+
3
+ const useSlideCarousel = (props)=>{
4
+ const { layoutType, ilNumberPerRow, ftDisplayType, ftItemPerSlide } = props;
5
+ const itemSlideGrid = useMemo(()=>{
6
+ const itemPerRowDefault = 5;
7
+ let itemPerRow = itemPerRowDefault;
8
+ switch(layoutType){
9
+ case 'bottom-center':
10
+ itemPerRow = ilNumberPerRow || itemPerRowDefault;
11
+ break;
12
+ case 'two-col':
13
+ itemPerRow = 2;
14
+ break;
15
+ case 'one-col':
16
+ itemPerRow = 1;
17
+ break;
18
+ default:
19
+ itemPerRow = itemPerRowDefault;
20
+ }
21
+ return itemPerRow;
22
+ }, [
23
+ ilNumberPerRow,
24
+ layoutType
25
+ ]);
26
+ const itemSlideList = ftDisplayType === 'slider' && layoutType !== 'only-feature' ? ftItemPerSlide : 1;
27
+ return {
28
+ itemSlideGrid,
29
+ itemSlideList
30
+ };
31
+ };
32
+
33
+ export { useSlideCarousel };
@@ -40,25 +40,22 @@ const settingV2 = [
40
40
  label: 'Left',
41
41
  value: 'left',
42
42
  type: 'text',
43
- tooltip: 'Align left'
43
+ tooltip: 'Align left',
44
+ iconName: 'polaris-text-align-left'
44
45
  },
45
46
  {
46
47
  label: 'Center',
47
48
  value: 'center',
48
49
  type: 'text',
49
- tooltip: 'Align center'
50
+ tooltip: 'Align center',
51
+ iconName: 'polaris-text-align-center'
50
52
  },
51
53
  {
52
54
  label: 'Right',
53
55
  value: 'right',
54
56
  type: 'text',
55
- tooltip: 'Align right'
56
- },
57
- {
58
- label: 'Justify',
59
- value: 'justify',
60
- type: 'text',
61
- tooltip: 'Align justify'
57
+ tooltip: 'Align right',
58
+ iconName: 'polaris-text-align-right'
62
59
  }
63
60
  ],
64
61
  default: 'left'
@@ -1,4 +1,45 @@
1
+ import { postPurchaseSpacing } from '../../../utils/constants.js';
2
+
1
3
  const productFeatureImageStyle = [
4
+ {
5
+ type: 'select',
6
+ label: 'Spacing',
7
+ id: 'ftSpacing',
8
+ options: postPurchaseSpacing,
9
+ default: 'xtight'
10
+ },
11
+ {
12
+ id: 'ftNavigation',
13
+ label: 'Border',
14
+ type: 'segment',
15
+ options: [
16
+ {
17
+ label: 'Yes',
18
+ value: 'display'
19
+ },
20
+ {
21
+ label: 'No',
22
+ value: 'none'
23
+ }
24
+ ],
25
+ default: 'none'
26
+ },
27
+ {
28
+ id: 'ftBorder',
29
+ label: 'Border',
30
+ type: 'segment',
31
+ options: [
32
+ {
33
+ label: 'Yes',
34
+ value: 'display'
35
+ },
36
+ {
37
+ label: 'No',
38
+ value: 'none'
39
+ }
40
+ ],
41
+ default: 'none'
42
+ },
2
43
  {
3
44
  id: 'ftAspectRatio',
4
45
  type: 'select',
@@ -1,5 +1,3 @@
1
- import { postPurchaseSpacing } from '../../../utils/constants.js';
2
-
3
1
  const productGalleryImageSetting = [
4
2
  {
5
3
  id: 'displayType',
@@ -19,121 +17,6 @@ const productGalleryImageSetting = [
19
17
  default: 'slider'
20
18
  }
21
19
  ];
22
- const productGalleryImageStyle = [
23
- {
24
- id: 'ilAspectRatio',
25
- type: 'select',
26
- default: '1',
27
- options: [
28
- {
29
- label: 'Original',
30
- value: 'auto'
31
- },
32
- {
33
- label: 'Square',
34
- value: '1'
35
- },
36
- {
37
- label: 'Vertical',
38
- value: '3/4'
39
- },
40
- {
41
- label: 'Horizontal',
42
- value: '4/3'
43
- }
44
- ]
45
- },
46
- {
47
- id: 'ilObjectFit',
48
- type: 'layout-segment',
49
- iconViewBox: '0 0 66 48',
50
- enableItemBackground: true,
51
- enableTooltip: true,
52
- label: 'Image scale',
53
- options: [
54
- {
55
- label: 'Fill image',
56
- value: 'cover',
57
- type: 'image'
58
- },
59
- {
60
- label: 'Fit image',
61
- value: 'contain',
62
- type: 'image'
63
- }
64
- ],
65
- default: 'cover'
66
- },
67
- {
68
- id: 'ilBorder',
69
- label: 'Active border',
70
- type: 'segment',
71
- default: 'display',
72
- options: [
73
- {
74
- label: 'none',
75
- value: 'none',
76
- icon: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
77
- <path fill-rule="evenodd" clip-rule="evenodd" d="M4.34315 4.34315C7.46734 1.21895 12.5327 1.21895 15.6569 4.34315C18.781 7.46734 18.781 12.5327 15.6569 15.6569C12.5327 18.781 7.46734 18.781 4.34315 15.6569C1.21895 12.5327 1.21895 7.46734 4.34315 4.34315ZM14.4281 4.7638C11.7339 2.4803 7.69308 2.60946 5.15127 5.15127C2.60946 7.69308 2.4803 11.7339 4.7638 14.4281L14.4281 4.7638ZM5.57193 15.2362C8.26608 17.5197 12.3069 17.3905 14.8487 14.8487C17.3905 12.3069 17.5197 8.26608 15.2362 5.57193L5.57193 15.2362Z" fill="currentColor"/>
78
- </svg>
79
-
80
- `
81
- },
82
- {
83
- label: 'display',
84
- value: 'display',
85
- icon: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
86
- <path d="M1.10547 9C1.10547 8.72386 1.32933 8.5 1.60547 8.5H18.1064C18.3826 8.5 18.6064 8.72386 18.6064 9V11C18.6064 11.2761 18.3826 11.5 18.1064 11.5H1.60547C1.32933 11.5 1.10547 11.2761 1.10547 11V9Z" fill="currentColor"/>
87
- </svg>
88
-
89
- `
90
- }
91
- ]
92
- },
93
- {
94
- id: 'ilNavigation',
95
- label: 'Navigation',
96
- type: 'layout-segment',
97
- iconViewBox: '0 0 78 48',
98
- enableItemBackground: true,
99
- enableTooltip: true,
100
- default: 'display',
101
- options: [
102
- {
103
- label: 'No navigation',
104
- value: 'none',
105
- type: 'slide-control',
106
- isTextIcon: true
107
- },
108
- {
109
- label: 'Display inside navigation',
110
- value: 'display',
111
- type: 'slide-control'
112
- }
113
- ]
114
- },
115
- {
116
- type: 'select',
117
- label: 'Spacing',
118
- id: 'ilSpacing',
119
- options: postPurchaseSpacing,
120
- default: 'xtight'
121
- },
122
- {
123
- id: 'ilItemPerSlide',
124
- type: 'input:number',
125
- min: 1,
126
- hide: true,
127
- default: 5
128
- },
129
- {
130
- id: 'ilNumberPerRow',
131
- type: 'input:number',
132
- label: 'Item per row',
133
- hide: true,
134
- default: 5
135
- }
136
- ];
137
20
  const productGalleryImageUI = [
138
21
  {
139
22
  type: 'control',
@@ -216,4 +99,4 @@ const productGalleryImageUI = [
216
99
  }
217
100
  ];
218
101
 
219
- export { productGalleryImageSetting, productGalleryImageStyle, productGalleryImageUI };
102
+ export { productGalleryImageSetting, productGalleryImageUI };