@fast-simon/shopify-hydrogen 1.0.4 → 1.0.6
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/README.md +186 -179
- package/dist/esnext/@types/Tab.d.ts +9 -9
- package/dist/esnext/@types/Tab.js +5 -5
- package/dist/esnext/@types/appServerProps.d.ts +12 -12
- package/dist/esnext/@types/appServerProps.js +1 -1
- package/dist/esnext/@types/articles.d.ts +12 -12
- package/dist/esnext/@types/articles.js +1 -1
- package/dist/esnext/@types/categories.d.ts +10 -10
- package/dist/esnext/@types/categories.js +1 -1
- package/dist/esnext/@types/currency.d.ts +1 -1
- package/dist/esnext/@types/currency.js +1 -1
- package/dist/esnext/@types/device.d.ts +1 -1
- package/dist/esnext/@types/device.js +1 -1
- package/dist/esnext/@types/editor.d.ts +418 -416
- package/dist/esnext/@types/editor.js +6 -6
- package/dist/esnext/@types/facets.d.ts +37 -37
- package/dist/esnext/@types/facets.js +16 -16
- package/dist/esnext/@types/ispOptions.d.ts +6 -6
- package/dist/esnext/@types/ispOptions.js +1 -1
- package/dist/esnext/@types/narrow.d.ts +7 -7
- package/dist/esnext/@types/narrow.js +1 -1
- package/dist/esnext/@types/product.d.ts +134 -134
- package/dist/esnext/@types/product.js +7 -7
- package/dist/esnext/@types/promoTile.d.ts +11 -11
- package/dist/esnext/@types/promoTile.js +1 -1
- package/dist/esnext/@types/results.d.ts +38 -36
- package/dist/esnext/@types/results.js +1 -1
- package/dist/esnext/@types/routing.d.ts +11 -11
- package/dist/esnext/@types/routing.js +1 -1
- package/dist/esnext/@types/siteSetup.d.ts +52 -52
- package/dist/esnext/@types/siteSetup.js +1 -1
- package/dist/esnext/@types/siteStatus.d.ts +5 -5
- package/dist/esnext/@types/siteStatus.js +1 -1
- package/dist/esnext/@types/sortBy.d.ts +12 -12
- package/dist/esnext/@types/sortBy.js +1 -1
- package/dist/esnext/@types/translations.d.ts +12 -12
- package/dist/esnext/@types/translations.js +6 -6
- package/dist/esnext/components/FastSimonApp.server.d.ts +9 -9
- package/dist/esnext/components/FastSimonApp.server.js +45 -45
- package/dist/esnext/components/FastSimonProvider.server.d.ts +10 -10
- package/dist/esnext/components/FastSimonProvider.server.js +9 -9
- package/dist/esnext/components/Filters/DesktopFilters/DesktopFilters.server.d.ts +8 -8
- package/dist/esnext/components/Filters/DesktopFilters/DesktopFilters.server.js +5 -5
- package/dist/esnext/components/Filters/FacetOption.client.d.ts +9 -9
- package/dist/esnext/components/Filters/FacetOption.client.js +39 -39
- package/dist/esnext/components/Filters/Filters.server.d.ts +12 -12
- package/dist/esnext/components/Filters/Filters.server.js +11 -11
- package/dist/esnext/components/Filters/FiltersList.server.d.ts +8 -8
- package/dist/esnext/components/Filters/FiltersList.server.js +11 -11
- package/dist/esnext/components/Filters/FiltersSkeleton.d.ts +3 -3
- package/dist/esnext/components/Filters/FiltersSkeleton.js +32 -32
- package/dist/esnext/components/Filters/MobileFilters/MobileFilters.client.d.ts +6 -6
- package/dist/esnext/components/Filters/MobileFilters/MobileFilters.client.js +20 -20
- package/dist/esnext/components/Filters/RemovableTags/RemovableTag.client.d.ts +8 -8
- package/dist/esnext/components/Filters/RemovableTags/RemovableTag.client.js +11 -11
- package/dist/esnext/components/Filters/RemovableTags/RemovableTags.client.d.ts +8 -8
- package/dist/esnext/components/Filters/RemovableTags/RemovableTags.client.js +51 -51
- package/dist/esnext/components/PageTitle/PageTitle.server.d.ts +7 -7
- package/dist/esnext/components/PageTitle/PageTitle.server.js +4 -4
- package/dist/esnext/components/Pagination/Pagination.client.d.ts +9 -9
- package/dist/esnext/components/Pagination/Pagination.client.js +43 -43
- package/dist/esnext/components/Pagination/utils.d.ts +1 -1
- package/dist/esnext/components/Pagination/utils.js +4 -4
- package/dist/esnext/components/ProductCard/ProductCard.d.ts +10 -10
- package/dist/esnext/components/ProductCard/ProductCard.js +31 -31
- package/dist/esnext/components/ProductCard/components/AddToCart/AddToCart.client.d.ts +10 -10
- package/dist/esnext/components/ProductCard/components/AddToCart/AddToCart.client.js +23 -23
- package/dist/esnext/components/ProductCard/components/Compare/Compare.d.ts +6 -6
- package/dist/esnext/components/ProductCard/components/Compare/Compare.js +6 -6
- package/dist/esnext/components/ProductCard/components/Info/ProductInfo.d.ts +9 -9
- package/dist/esnext/components/ProductCard/components/Info/ProductInfo.js +11 -11
- package/dist/esnext/components/ProductCard/components/Price/Price.d.ts +7 -7
- package/dist/esnext/components/ProductCard/components/Price/Price.js +6 -6
- package/dist/esnext/components/ProductCard/components/ProductImage/ProductImage.d.ts +8 -8
- package/dist/esnext/components/ProductCard/components/ProductImage/ProductImage.js +7 -7
- package/dist/esnext/components/ProductCard/components/Title/Title.d.ts +7 -7
- package/dist/esnext/components/ProductCard/components/Title/Title.js +4 -4
- package/dist/esnext/components/ProductGrid/ProductGrid.server.d.ts +10 -10
- package/dist/esnext/components/ProductGrid/ProductGrid.server.js +10 -10
- package/dist/esnext/components/ProductGrid/stylesUtil.d.ts +138 -138
- package/dist/esnext/components/ProductGrid/stylesUtil.js +122 -122
- package/dist/esnext/components/ResultsSummary/ResultsSummary.server.d.ts +7 -7
- package/dist/esnext/components/ResultsSummary/ResultsSummary.server.js +8 -8
- package/dist/esnext/components/SortBy/SortBy.client.d.ts +10 -10
- package/dist/esnext/components/SortBy/SortBy.client.js +8 -8
- package/dist/esnext/components/SortBy/components/DesktopSortBy.client.d.ts +8 -8
- package/dist/esnext/components/SortBy/components/DesktopSortBy.client.js +30 -30
- package/dist/esnext/components/SortBy/utils.d.ts +8 -8
- package/dist/esnext/components/SortBy/utils.js +28 -28
- package/dist/esnext/components/index.d.ts +2 -2
- package/dist/esnext/components/index.js +2 -2
- package/dist/esnext/context/setRoutingContext.d.ts +2 -2
- package/dist/esnext/context/setRoutingContext.js +14 -14
- package/dist/esnext/context/setSiteContext.d.ts +6 -6
- package/dist/esnext/context/setSiteContext.js +18 -18
- package/dist/esnext/hooks/ResizeDetect.client.d.ts +2 -2
- package/dist/esnext/hooks/ResizeDetect.client.js +6 -6
- package/dist/esnext/hooks/useClickOutside.d.ts +1 -1
- package/dist/esnext/hooks/useClickOutside.js +12 -12
- package/dist/esnext/hooks/useScreenSize.d.ts +1 -1
- package/dist/esnext/hooks/useScreenSize.js +19 -19
- package/dist/esnext/icons/DownArrowIcon.d.ts +9 -9
- package/dist/esnext/icons/DownArrowIcon.js +5 -5
- package/dist/esnext/icons/LeftArrowIcon.d.ts +8 -8
- package/dist/esnext/icons/LeftArrowIcon.js +5 -5
- package/dist/esnext/icons/RejectIcon.d.ts +8 -8
- package/dist/esnext/icons/RejectIcon.js +5 -5
- package/dist/esnext/icons/RightArrowIcon.d.ts +8 -8
- package/dist/esnext/icons/RightArrowIcon.js +5 -5
- package/dist/esnext/icons/Spinner.d.ts +11 -11
- package/dist/esnext/icons/Spinner.js +6 -6
- package/dist/esnext/index.d.ts +1 -1
- package/dist/esnext/index.js +1 -1
- package/dist/esnext/services/__tests__/categories_navigation.test.d.ts +1 -0
- package/dist/esnext/services/__tests__/categories_navigation.test.js +90 -0
- package/dist/esnext/services/categories_navigation.d.ts +69 -48
- package/dist/esnext/services/categories_navigation.js +53 -51
- package/dist/esnext/services/search.d.ts +47 -47
- package/dist/esnext/services/search.js +51 -51
- package/dist/esnext/services/site_setup.d.ts +7 -7
- package/dist/esnext/services/site_setup.js +69 -69
- package/dist/esnext/utils/DynamicStyle.d.ts +7 -7
- package/dist/esnext/utils/DynamicStyle.js +5 -5
- package/dist/esnext/utils/defaults.d.ts +8 -8
- package/dist/esnext/utils/defaults.js +9 -9
- package/dist/esnext/utils/getDynamicStylesVar.d.ts +1 -1
- package/dist/esnext/utils/getDynamicStylesVar.js +5 -5
- package/dist/esnext/utils/getRoutingState.d.ts +9 -9
- package/dist/esnext/utils/getRoutingState.js +13 -13
- package/dist/esnext/utils/makeServingRequests.d.ts +6 -6
- package/dist/esnext/utils/makeServingRequests.js +32 -32
- package/dist/node/plugin/extendOptimizeDeps.d.ts +2 -2
- package/dist/node/plugin/extendOptimizeDeps.js +14 -14
- package/dist/node/plugin/index.d.ts +3 -3
- package/dist/node/plugin/index.js +13 -13
- package/dist/node/plugin/injectCSS.d.ts +2 -2
- package/dist/node/plugin/injectCSS.js +25 -25
- package/dist/node/plugin/suppressWarnings.d.ts +2 -2
- package/dist/node/plugin/suppressWarnings.js +21 -21
- package/package.json +37 -34
- package/dist/esnext/styles/fast-simon.css +0 -622
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import { GridAreaUtils } from "@fast-simon/utilities";
|
|
2
|
-
export class StylesUtil {
|
|
3
|
-
}
|
|
4
|
-
StylesUtil.getDynamicStylesObject = (gridSettings) => {
|
|
5
|
-
const gridStyles = StylesUtil.getGridCustomStyles(gridSettings);
|
|
6
|
-
const imageCustomStyles = StylesUtil.getProductImageCustomStyles(gridSettings.product);
|
|
7
|
-
const addToCartCustomStyles = StylesUtil.getAddToCartCustomStyles(gridSettings.product.addToCart);
|
|
8
|
-
const priceCustomStyles = StylesUtil.getPriceCustomStyles(gridSettings.product.price);
|
|
9
|
-
const titleCustomStyles = StylesUtil.getProductTitleCustomStyles(gridSettings.product.title);
|
|
10
|
-
const productCardCustomStyles = StylesUtil.getProductCardCustomStyles(gridSettings.product);
|
|
11
|
-
const compareStyles = StylesUtil.getCompareStyles(gridSettings.product.compare);
|
|
12
|
-
return [
|
|
13
|
-
{ className: 'fs-grid', styles: gridStyles },
|
|
14
|
-
{ className: 'fs-product-card-img', styles: imageCustomStyles },
|
|
15
|
-
{ className: 'fs-product-add-to-cart', styles: addToCartCustomStyles.base },
|
|
16
|
-
{ className: 'fs-product-add-to-cart:hover', styles: addToCartCustomStyles.hover },
|
|
17
|
-
{ className: 'fs-product-card-price', styles: priceCustomStyles.base },
|
|
18
|
-
{ className: 'fs-price-with-compare', styles: priceCustomStyles.withCompare },
|
|
19
|
-
{ className: 'fs-price-without-compare', styles: priceCustomStyles.withoutCompare },
|
|
20
|
-
{ className: 'fs-product-card-title', styles: titleCustomStyles },
|
|
21
|
-
{ className: 'fs-product-card', styles: productCardCustomStyles.base },
|
|
22
|
-
{ className: 'fs-product-card:hover', styles: productCardCustomStyles.hover },
|
|
23
|
-
{ className: 'fs-product-card-info', styles: productCardCustomStyles.productInfo },
|
|
24
|
-
{ className: 'fs-info-areas-compare', styles: productCardCustomStyles.gridAreasWithCompare },
|
|
25
|
-
{ className: 'fs-info-areas', styles: productCardCustomStyles.gridAreasWithoutCompare },
|
|
26
|
-
{ className: 'fs-product-card-compare', styles: compareStyles }
|
|
27
|
-
];
|
|
28
|
-
};
|
|
29
|
-
StylesUtil.getGridCustomStyles = (gridSettings) => {
|
|
30
|
-
return {
|
|
31
|
-
"grid-template-columns": `repeat(${gridSettings.numberOfColumns}, calc(${100 / Number(gridSettings.numberOfColumns)}% - ${gridSettings.gridColumnGap}))`,
|
|
32
|
-
"grid-row-gap": gridSettings.gridRowGap,
|
|
33
|
-
"grid-column-gap": gridSettings.gridColumnGap,
|
|
34
|
-
"margin-left": gridSettings.gridColumnGap
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
StylesUtil.getProductImageCustomStyles = (productSettings) => {
|
|
38
|
-
return {
|
|
39
|
-
'aspect-ratio': productSettings.imageRatio,
|
|
40
|
-
'object-fit': productSettings.imageFit
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
StylesUtil.getAddToCartCustomStyles = (addToCart) => {
|
|
44
|
-
return {
|
|
45
|
-
base: {
|
|
46
|
-
'font-weight': addToCart.font.fontWeight,
|
|
47
|
-
'font-family': addToCart.font.font,
|
|
48
|
-
'font-size': addToCart.font.fontSize,
|
|
49
|
-
'letter-spacing': addToCart.font.letterSpacing,
|
|
50
|
-
'color': addToCart.color,
|
|
51
|
-
'background-color': addToCart.backgroundColor,
|
|
52
|
-
'border': addToCart.border,
|
|
53
|
-
'border-radius': addToCart.borderRadius,
|
|
54
|
-
'opacity': addToCart.showOnHover ? 0 : 1
|
|
55
|
-
},
|
|
56
|
-
hover: {
|
|
57
|
-
'background-color': addToCart.changeColorsOnHover && addToCart.backgroundColorOnHover !== 'unset' ? addToCart.backgroundColorOnHover : addToCart.backgroundColor,
|
|
58
|
-
'color': addToCart.changeColorsOnHover && addToCart.backgroundColorOnHover !== 'unset' ? addToCart.textColorsOnHover : addToCart.color,
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
StylesUtil.getPriceCustomStyles = (priceSettings, comparePrice) => {
|
|
63
|
-
return {
|
|
64
|
-
base: {
|
|
65
|
-
'font-weight': priceSettings?.font.fontWeight,
|
|
66
|
-
'font-family': priceSettings?.font.font,
|
|
67
|
-
'font-size': priceSettings?.font.fontSize,
|
|
68
|
-
'letter-spacing': priceSettings?.font.letterSpacing,
|
|
69
|
-
'line-height': priceSettings?.font.lineHeight,
|
|
70
|
-
},
|
|
71
|
-
withCompare: {
|
|
72
|
-
'text-align': priceSettings.alignIfCompare,
|
|
73
|
-
'color': priceSettings.colorIfCompareEnable ? priceSettings?.colorIfCompareEnable : priceSettings.color
|
|
74
|
-
},
|
|
75
|
-
withoutCompare: {
|
|
76
|
-
'text-align': priceSettings?.font.textAlign,
|
|
77
|
-
'color': priceSettings.color
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
StylesUtil.getProductTitleCustomStyles = (titleSettings) => {
|
|
82
|
-
return {
|
|
83
|
-
'-webkit-line-clamp': titleSettings?.numberOfLines,
|
|
84
|
-
'font-weight': titleSettings?.font.fontWeight,
|
|
85
|
-
'text-align': titleSettings?.font.textAlign,
|
|
86
|
-
'font-family': titleSettings?.font.font,
|
|
87
|
-
'font-size': titleSettings?.font.fontSize,
|
|
88
|
-
'letter-spacing': titleSettings?.font.letterSpacing,
|
|
89
|
-
'line-height': titleSettings?.font.lineHeight,
|
|
90
|
-
'color': titleSettings?.color
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
StylesUtil.getProductCardCustomStyles = (productSettings) => {
|
|
94
|
-
return {
|
|
95
|
-
base: {
|
|
96
|
-
'padding': productSettings?.padding,
|
|
97
|
-
'border': productSettings?.showBorderOnHover ? undefined : productSettings?.border,
|
|
98
|
-
'border-radius': productSettings?.borderRadius + "%",
|
|
99
|
-
'shadow': productSettings?.shadow,
|
|
100
|
-
'justify-content': productSettings?.addToCart.isActive && productSettings?.addToCart.addToCartType === 'product level' ? 'space-between' : ''
|
|
101
|
-
},
|
|
102
|
-
hover: {
|
|
103
|
-
'border': productSettings?.showBorderOnHover ? productSettings?.border : undefined,
|
|
104
|
-
},
|
|
105
|
-
gridAreasWithCompare: { 'grid-template-areas': GridAreaUtils.arrangeGridAreas(productSettings?.info.gridAreas, true) },
|
|
106
|
-
gridAreasWithoutCompare: { 'grid-template-areas': GridAreaUtils.arrangeGridAreas(productSettings?.info.gridAreas, false) },
|
|
107
|
-
productInfo: {
|
|
108
|
-
padding: productSettings?.info.padding
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
StylesUtil.getCompareStyles = (compareSettings) => {
|
|
113
|
-
return {
|
|
114
|
-
'font-weight': compareSettings.font.fontWeight,
|
|
115
|
-
'text-align': compareSettings.font.textAlign,
|
|
116
|
-
'font-family': compareSettings.font.font,
|
|
117
|
-
'font-size': compareSettings.font.fontSize,
|
|
118
|
-
'letter-spacing': compareSettings.font.letterSpacing,
|
|
119
|
-
'line-height': compareSettings.font.lineHeight,
|
|
120
|
-
'color': compareSettings.color
|
|
121
|
-
};
|
|
122
|
-
};
|
|
1
|
+
import { GridAreaUtils } from "@fast-simon/utilities";
|
|
2
|
+
export class StylesUtil {
|
|
3
|
+
}
|
|
4
|
+
StylesUtil.getDynamicStylesObject = (gridSettings) => {
|
|
5
|
+
const gridStyles = StylesUtil.getGridCustomStyles(gridSettings);
|
|
6
|
+
const imageCustomStyles = StylesUtil.getProductImageCustomStyles(gridSettings.product);
|
|
7
|
+
const addToCartCustomStyles = StylesUtil.getAddToCartCustomStyles(gridSettings.product.addToCart);
|
|
8
|
+
const priceCustomStyles = StylesUtil.getPriceCustomStyles(gridSettings.product.price);
|
|
9
|
+
const titleCustomStyles = StylesUtil.getProductTitleCustomStyles(gridSettings.product.title);
|
|
10
|
+
const productCardCustomStyles = StylesUtil.getProductCardCustomStyles(gridSettings.product);
|
|
11
|
+
const compareStyles = StylesUtil.getCompareStyles(gridSettings.product.compare);
|
|
12
|
+
return [
|
|
13
|
+
{ className: 'fs-grid', styles: gridStyles },
|
|
14
|
+
{ className: 'fs-product-card-img', styles: imageCustomStyles },
|
|
15
|
+
{ className: 'fs-product-add-to-cart', styles: addToCartCustomStyles.base },
|
|
16
|
+
{ className: 'fs-product-add-to-cart:hover', styles: addToCartCustomStyles.hover },
|
|
17
|
+
{ className: 'fs-product-card-price', styles: priceCustomStyles.base },
|
|
18
|
+
{ className: 'fs-price-with-compare', styles: priceCustomStyles.withCompare },
|
|
19
|
+
{ className: 'fs-price-without-compare', styles: priceCustomStyles.withoutCompare },
|
|
20
|
+
{ className: 'fs-product-card-title', styles: titleCustomStyles },
|
|
21
|
+
{ className: 'fs-product-card', styles: productCardCustomStyles.base },
|
|
22
|
+
{ className: 'fs-product-card:hover', styles: productCardCustomStyles.hover },
|
|
23
|
+
{ className: 'fs-product-card-info', styles: productCardCustomStyles.productInfo },
|
|
24
|
+
{ className: 'fs-info-areas-compare', styles: productCardCustomStyles.gridAreasWithCompare },
|
|
25
|
+
{ className: 'fs-info-areas', styles: productCardCustomStyles.gridAreasWithoutCompare },
|
|
26
|
+
{ className: 'fs-product-card-compare', styles: compareStyles }
|
|
27
|
+
];
|
|
28
|
+
};
|
|
29
|
+
StylesUtil.getGridCustomStyles = (gridSettings) => {
|
|
30
|
+
return {
|
|
31
|
+
"grid-template-columns": `repeat(${gridSettings.numberOfColumns}, calc(${100 / Number(gridSettings.numberOfColumns)}% - ${gridSettings.gridColumnGap}))`,
|
|
32
|
+
"grid-row-gap": gridSettings.gridRowGap,
|
|
33
|
+
"grid-column-gap": gridSettings.gridColumnGap,
|
|
34
|
+
"margin-left": gridSettings.gridColumnGap
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
StylesUtil.getProductImageCustomStyles = (productSettings) => {
|
|
38
|
+
return {
|
|
39
|
+
'aspect-ratio': productSettings.imageRatio,
|
|
40
|
+
'object-fit': productSettings.imageFit
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
StylesUtil.getAddToCartCustomStyles = (addToCart) => {
|
|
44
|
+
return {
|
|
45
|
+
base: {
|
|
46
|
+
'font-weight': addToCart.font.fontWeight,
|
|
47
|
+
'font-family': addToCart.font.font,
|
|
48
|
+
'font-size': addToCart.font.fontSize,
|
|
49
|
+
'letter-spacing': addToCart.font.letterSpacing,
|
|
50
|
+
'color': addToCart.color,
|
|
51
|
+
'background-color': addToCart.backgroundColor,
|
|
52
|
+
'border': addToCart.border,
|
|
53
|
+
'border-radius': addToCart.borderRadius,
|
|
54
|
+
'opacity': addToCart.showOnHover ? 0 : 1
|
|
55
|
+
},
|
|
56
|
+
hover: {
|
|
57
|
+
'background-color': addToCart.changeColorsOnHover && addToCart.backgroundColorOnHover !== 'unset' ? addToCart.backgroundColorOnHover : addToCart.backgroundColor,
|
|
58
|
+
'color': addToCart.changeColorsOnHover && addToCart.backgroundColorOnHover !== 'unset' ? addToCart.textColorsOnHover : addToCart.color,
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
StylesUtil.getPriceCustomStyles = (priceSettings, comparePrice) => {
|
|
63
|
+
return {
|
|
64
|
+
base: {
|
|
65
|
+
'font-weight': priceSettings?.font.fontWeight,
|
|
66
|
+
'font-family': priceSettings?.font.font,
|
|
67
|
+
'font-size': priceSettings?.font.fontSize,
|
|
68
|
+
'letter-spacing': priceSettings?.font.letterSpacing,
|
|
69
|
+
'line-height': priceSettings?.font.lineHeight,
|
|
70
|
+
},
|
|
71
|
+
withCompare: {
|
|
72
|
+
'text-align': priceSettings.alignIfCompare,
|
|
73
|
+
'color': priceSettings.colorIfCompareEnable ? priceSettings?.colorIfCompareEnable : priceSettings.color
|
|
74
|
+
},
|
|
75
|
+
withoutCompare: {
|
|
76
|
+
'text-align': priceSettings?.font.textAlign,
|
|
77
|
+
'color': priceSettings.color
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
StylesUtil.getProductTitleCustomStyles = (titleSettings) => {
|
|
82
|
+
return {
|
|
83
|
+
'-webkit-line-clamp': titleSettings?.numberOfLines,
|
|
84
|
+
'font-weight': titleSettings?.font.fontWeight,
|
|
85
|
+
'text-align': titleSettings?.font.textAlign,
|
|
86
|
+
'font-family': titleSettings?.font.font,
|
|
87
|
+
'font-size': titleSettings?.font.fontSize,
|
|
88
|
+
'letter-spacing': titleSettings?.font.letterSpacing,
|
|
89
|
+
'line-height': titleSettings?.font.lineHeight,
|
|
90
|
+
'color': titleSettings?.color
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
StylesUtil.getProductCardCustomStyles = (productSettings) => {
|
|
94
|
+
return {
|
|
95
|
+
base: {
|
|
96
|
+
'padding': productSettings?.padding,
|
|
97
|
+
'border': productSettings?.showBorderOnHover ? undefined : productSettings?.border,
|
|
98
|
+
'border-radius': productSettings?.borderRadius + "%",
|
|
99
|
+
'shadow': productSettings?.shadow,
|
|
100
|
+
'justify-content': productSettings?.addToCart.isActive && productSettings?.addToCart.addToCartType === 'product level' ? 'space-between' : ''
|
|
101
|
+
},
|
|
102
|
+
hover: {
|
|
103
|
+
'border': productSettings?.showBorderOnHover ? productSettings?.border : undefined,
|
|
104
|
+
},
|
|
105
|
+
gridAreasWithCompare: { 'grid-template-areas': GridAreaUtils.arrangeGridAreas(productSettings?.info.gridAreas, true) },
|
|
106
|
+
gridAreasWithoutCompare: { 'grid-template-areas': GridAreaUtils.arrangeGridAreas(productSettings?.info.gridAreas, false) },
|
|
107
|
+
productInfo: {
|
|
108
|
+
padding: productSettings?.info.padding
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
StylesUtil.getCompareStyles = (compareSettings) => {
|
|
113
|
+
return {
|
|
114
|
+
'font-weight': compareSettings.font.fontWeight,
|
|
115
|
+
'text-align': compareSettings.font.textAlign,
|
|
116
|
+
'font-family': compareSettings.font.font,
|
|
117
|
+
'font-size': compareSettings.font.fontSize,
|
|
118
|
+
'letter-spacing': compareSettings.font.letterSpacing,
|
|
119
|
+
'line-height': compareSettings.font.lineHeight,
|
|
120
|
+
'color': compareSettings.color
|
|
121
|
+
};
|
|
122
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface Props {
|
|
3
|
-
totalResults: number;
|
|
4
|
-
term: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function ResultsSummaryServer({ totalResults, term }: Props): React.JSX.Element;
|
|
7
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
totalResults: number;
|
|
4
|
+
term: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function ResultsSummaryServer({ totalResults, term }: Props): React.JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export function ResultsSummaryServer({ totalResults, term }) {
|
|
3
|
-
return (React.createElement("div", { className: 'fs-summary' },
|
|
4
|
-
React.createElement("div", null, term),
|
|
5
|
-
React.createElement("div", null,
|
|
6
|
-
totalResults,
|
|
7
|
-
" results")));
|
|
8
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export function ResultsSummaryServer({ totalResults, term }) {
|
|
3
|
+
return (React.createElement("div", { className: 'fs-summary' },
|
|
4
|
+
React.createElement("div", null, term),
|
|
5
|
+
React.createElement("div", null,
|
|
6
|
+
totalResults,
|
|
7
|
+
" results")));
|
|
8
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SortBy, SortSetupOption } from "../../@types/sortBy";
|
|
3
|
-
import { SortingOption } from "../../@types/editor";
|
|
4
|
-
interface Props {
|
|
5
|
-
sortSetup: SortSetupOption[];
|
|
6
|
-
sortingOptions: SortingOption[];
|
|
7
|
-
sortBy?: SortBy;
|
|
8
|
-
}
|
|
9
|
-
export declare function SortByClient({ sortSetup, sortingOptions, sortBy }: Props): React.JSX.Element;
|
|
10
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortBy, SortSetupOption } from "../../@types/sortBy";
|
|
3
|
+
import { SortingOption } from "../../@types/editor";
|
|
4
|
+
interface Props {
|
|
5
|
+
sortSetup: SortSetupOption[];
|
|
6
|
+
sortingOptions: SortingOption[];
|
|
7
|
+
sortBy?: SortBy;
|
|
8
|
+
}
|
|
9
|
+
export declare function SortByClient({ sortSetup, sortingOptions, sortBy }: Props): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { getOptions } from "./utils";
|
|
3
|
-
import { DesktopSortByClient } from "./components/DesktopSortBy.client";
|
|
4
|
-
export function SortByClient({ sortSetup, sortingOptions, sortBy }) {
|
|
5
|
-
const options = getOptions({ sortSetup, sortingOptions });
|
|
6
|
-
const currentSort = options.find(option => option.id === sortBy);
|
|
7
|
-
return (React.createElement(DesktopSortByClient, { options: options, current: currentSort }));
|
|
8
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getOptions } from "./utils";
|
|
3
|
+
import { DesktopSortByClient } from "./components/DesktopSortBy.client";
|
|
4
|
+
export function SortByClient({ sortSetup, sortingOptions, sortBy }) {
|
|
5
|
+
const options = getOptions({ sortSetup, sortingOptions });
|
|
6
|
+
const currentSort = options.find(option => option.id === sortBy);
|
|
7
|
+
return (React.createElement(DesktopSortByClient, { options: options, current: currentSort }));
|
|
8
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SelectItem } from "../../../@types/sortBy";
|
|
3
|
-
interface Props {
|
|
4
|
-
options: SelectItem[];
|
|
5
|
-
current?: SelectItem;
|
|
6
|
-
}
|
|
7
|
-
export declare function DesktopSortByClient({ options, current }: Props): React.JSX.Element;
|
|
8
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectItem } from "../../../@types/sortBy";
|
|
3
|
+
interface Props {
|
|
4
|
+
options: SelectItem[];
|
|
5
|
+
current?: SelectItem;
|
|
6
|
+
}
|
|
7
|
+
export declare function DesktopSortByClient({ options, current }: Props): React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
import { DownArrowIcon } from "../../../icons/DownArrowIcon";
|
|
3
|
-
import { Defaults } from "../../../utils/defaults";
|
|
4
|
-
import { useNavigate, useServerProps, useUrl } from "@shopify/hydrogen";
|
|
5
|
-
import { useClickOutside } from "../../../hooks/useClickOutside";
|
|
6
|
-
export function DesktopSortByClient({ options, current }) {
|
|
7
|
-
const [selected, setSelected] = useState(current ?? options[0]);
|
|
8
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
9
|
-
const { setServerProps, serverProps } = useServerProps();
|
|
10
|
-
const url = useUrl();
|
|
11
|
-
const navigation = useNavigate();
|
|
12
|
-
const menuRef = useRef(null);
|
|
13
|
-
const onClickOutside = () => setIsOpen(false);
|
|
14
|
-
useClickOutside(menuRef, onClickOutside);
|
|
15
|
-
const changeDropdownMode = () => setIsOpen(!isOpen);
|
|
16
|
-
const onSelect = (option) => {
|
|
17
|
-
setSelected(option);
|
|
18
|
-
setIsOpen(false);
|
|
19
|
-
url.searchParams.set('sort', option.id);
|
|
20
|
-
url.searchParams.delete('page');
|
|
21
|
-
navigation(url.href);
|
|
22
|
-
setServerProps(Defaults.fastSimonProps, { ...serverProps?.[Defaults.fastSimonProps], sortBy: option.id, page: 1 });
|
|
23
|
-
};
|
|
24
|
-
return (React.createElement("div", { ref: menuRef, className: "select-container" },
|
|
25
|
-
React.createElement("div", { className: "fs-select-wrapper" },
|
|
26
|
-
React.createElement("div", { className: `select-button ${isOpen ? 'select-button-open' : ''}`, onClick: changeDropdownMode },
|
|
27
|
-
React.createElement("span", null, selected.text),
|
|
28
|
-
React.createElement(DownArrowIcon, { rotate: isOpen })),
|
|
29
|
-
React.createElement("div", { className: "custom-options" }, isOpen ? options.map(option => (React.createElement("div", { key: option.id, className: `dropdown-item ${option.id === selected.id ? 'selected-option' : ''}`, onClick: () => onSelect(option) }, option.text))) : null))));
|
|
30
|
-
}
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { DownArrowIcon } from "../../../icons/DownArrowIcon";
|
|
3
|
+
import { Defaults } from "../../../utils/defaults";
|
|
4
|
+
import { useNavigate, useServerProps, useUrl } from "@shopify/hydrogen";
|
|
5
|
+
import { useClickOutside } from "../../../hooks/useClickOutside";
|
|
6
|
+
export function DesktopSortByClient({ options, current }) {
|
|
7
|
+
const [selected, setSelected] = useState(current ?? options[0]);
|
|
8
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
9
|
+
const { setServerProps, serverProps } = useServerProps();
|
|
10
|
+
const url = useUrl();
|
|
11
|
+
const navigation = useNavigate();
|
|
12
|
+
const menuRef = useRef(null);
|
|
13
|
+
const onClickOutside = () => setIsOpen(false);
|
|
14
|
+
useClickOutside(menuRef, onClickOutside);
|
|
15
|
+
const changeDropdownMode = () => setIsOpen(!isOpen);
|
|
16
|
+
const onSelect = (option) => {
|
|
17
|
+
setSelected(option);
|
|
18
|
+
setIsOpen(false);
|
|
19
|
+
url.searchParams.set('sort', option.id);
|
|
20
|
+
url.searchParams.delete('page');
|
|
21
|
+
navigation(url.href);
|
|
22
|
+
setServerProps(Defaults.fastSimonProps, { ...serverProps?.[Defaults.fastSimonProps], sortBy: option.id, page: 1 });
|
|
23
|
+
};
|
|
24
|
+
return (React.createElement("div", { ref: menuRef, className: "select-container" },
|
|
25
|
+
React.createElement("div", { className: "fs-select-wrapper" },
|
|
26
|
+
React.createElement("div", { className: `select-button ${isOpen ? 'select-button-open' : ''}`, onClick: changeDropdownMode },
|
|
27
|
+
React.createElement("span", null, selected.text),
|
|
28
|
+
React.createElement(DownArrowIcon, { rotate: isOpen })),
|
|
29
|
+
React.createElement("div", { className: "custom-options" }, isOpen ? options.map(option => (React.createElement("div", { key: option.id, className: `dropdown-item ${option.id === selected.id ? 'selected-option' : ''}`, onClick: () => onSelect(option) }, option.text))) : null))));
|
|
30
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SelectItem, SortSetupOption } from "../../@types/sortBy";
|
|
2
|
-
import { SortingOption } from "../../@types/editor";
|
|
3
|
-
interface Props {
|
|
4
|
-
sortSetup: SortSetupOption[];
|
|
5
|
-
sortingOptions: SortingOption[];
|
|
6
|
-
}
|
|
7
|
-
export declare function getOptions({ sortSetup, sortingOptions }: Props): SelectItem[];
|
|
8
|
-
export {};
|
|
1
|
+
import { SelectItem, SortSetupOption } from "../../@types/sortBy";
|
|
2
|
+
import { SortingOption } from "../../@types/editor";
|
|
3
|
+
interface Props {
|
|
4
|
+
sortSetup: SortSetupOption[];
|
|
5
|
+
sortingOptions: SortingOption[];
|
|
6
|
+
}
|
|
7
|
+
export declare function getOptions({ sortSetup, sortingOptions }: Props): SelectItem[];
|
|
8
|
+
export {};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const serverNameToId = {
|
|
2
|
-
'relevency': '0',
|
|
3
|
-
'price_min_to_max': '1',
|
|
4
|
-
'price_max_to_min': '2',
|
|
5
|
-
'creation_date': '3',
|
|
6
|
-
'creation_date_oldest': '4',
|
|
7
|
-
'popularity': '5',
|
|
8
|
-
'reviews': '6',
|
|
9
|
-
'a_to_z': '7',
|
|
10
|
-
'z_to_a': '8'
|
|
11
|
-
};
|
|
12
|
-
export function getOptions({ sortSetup, sortingOptions }) {
|
|
13
|
-
const sortOptions = [];
|
|
14
|
-
sortSetup.filter(value => value.active).forEach(option => {
|
|
15
|
-
const item = sortingOptions?.find(item => serverNameToId[item.backendName] === option.id);
|
|
16
|
-
if (item) {
|
|
17
|
-
sortOptions.push({ text: item.customName, id: item.backendName });
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const sortOptionsPositioned = [];
|
|
21
|
-
sortingOptions.forEach(option => {
|
|
22
|
-
const sortItem = sortOptions.find(item => option.backendName === item.id);
|
|
23
|
-
if (sortItem) {
|
|
24
|
-
sortOptionsPositioned.push(sortItem);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
return sortOptionsPositioned;
|
|
28
|
-
}
|
|
1
|
+
const serverNameToId = {
|
|
2
|
+
'relevency': '0',
|
|
3
|
+
'price_min_to_max': '1',
|
|
4
|
+
'price_max_to_min': '2',
|
|
5
|
+
'creation_date': '3',
|
|
6
|
+
'creation_date_oldest': '4',
|
|
7
|
+
'popularity': '5',
|
|
8
|
+
'reviews': '6',
|
|
9
|
+
'a_to_z': '7',
|
|
10
|
+
'z_to_a': '8'
|
|
11
|
+
};
|
|
12
|
+
export function getOptions({ sortSetup, sortingOptions }) {
|
|
13
|
+
const sortOptions = [];
|
|
14
|
+
sortSetup.filter(value => value.active).forEach(option => {
|
|
15
|
+
const item = sortingOptions?.find(item => serverNameToId[item.backendName] === option.id);
|
|
16
|
+
if (item) {
|
|
17
|
+
sortOptions.push({ text: item.customName, id: item.backendName });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const sortOptionsPositioned = [];
|
|
21
|
+
sortingOptions.forEach(option => {
|
|
22
|
+
const sortItem = sortOptions.find(item => option.backendName === item.id);
|
|
23
|
+
if (sortItem) {
|
|
24
|
+
sortOptionsPositioned.push(sortItem);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return sortOptionsPositioned;
|
|
28
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './FastSimonProvider.server';
|
|
2
|
-
export * from './FastSimonApp.server';
|
|
1
|
+
export * from './FastSimonProvider.server';
|
|
2
|
+
export * from './FastSimonApp.server';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './FastSimonProvider.server';
|
|
2
|
-
export * from './FastSimonApp.server';
|
|
1
|
+
export * from './FastSimonProvider.server';
|
|
2
|
+
export * from './FastSimonApp.server';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HydrogenRouteProps } from "@shopify/hydrogen";
|
|
2
|
-
export declare const setRoutingContext: (request: HydrogenRouteProps) => any;
|
|
1
|
+
import { HydrogenRouteProps } from "@shopify/hydrogen";
|
|
2
|
+
export declare const setRoutingContext: (request: HydrogenRouteProps) => any;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useRequestContext } from "@shopify/hydrogen";
|
|
2
|
-
import { Defaults } from "../utils/defaults";
|
|
3
|
-
export const setRoutingContext = (request) => {
|
|
4
|
-
const context = useRequestContext(Defaults.fastSimonServerContextScope);
|
|
5
|
-
const routingState = request.ctx.router.serverProps?.[Defaults.fastSimonProps];
|
|
6
|
-
context[Defaults.fastSimonProps] = {
|
|
7
|
-
page: routingState?.page ?? 1,
|
|
8
|
-
narrow: routingState?.narrow,
|
|
9
|
-
query: routingState?.query,
|
|
10
|
-
collectionID: routingState?.collectionID,
|
|
11
|
-
sort: routingState?.sort
|
|
12
|
-
};
|
|
13
|
-
return context[Defaults.fastSimonProps];
|
|
14
|
-
};
|
|
1
|
+
import { useRequestContext } from "@shopify/hydrogen";
|
|
2
|
+
import { Defaults } from "../utils/defaults";
|
|
3
|
+
export const setRoutingContext = (request) => {
|
|
4
|
+
const context = useRequestContext(Defaults.fastSimonServerContextScope);
|
|
5
|
+
const routingState = request.ctx.router.serverProps?.[Defaults.fastSimonProps];
|
|
6
|
+
context[Defaults.fastSimonProps] = {
|
|
7
|
+
page: routingState?.page ?? 1,
|
|
8
|
+
narrow: routingState?.narrow,
|
|
9
|
+
query: routingState?.query,
|
|
10
|
+
collectionID: routingState?.collectionID,
|
|
11
|
+
sort: routingState?.sort
|
|
12
|
+
};
|
|
13
|
+
return context[Defaults.fastSimonProps];
|
|
14
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface Props {
|
|
2
|
-
uuid: string;
|
|
3
|
-
storeID: number;
|
|
4
|
-
userAgent: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const setSiteScopedServerContext: ({ uuid, storeID, userAgent }: Props) => void;
|
|
1
|
+
export interface Props {
|
|
2
|
+
uuid: string;
|
|
3
|
+
storeID: number;
|
|
4
|
+
userAgent: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const setSiteScopedServerContext: ({ uuid, storeID, userAgent }: Props) => void;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useRequestContext } from "@shopify/hydrogen";
|
|
2
|
-
import { Defaults } from "../utils/defaults";
|
|
3
|
-
import { Site } from "../services/site_setup";
|
|
4
|
-
export const setSiteScopedServerContext = ({ uuid, storeID, userAgent }) => {
|
|
5
|
-
const fastSimonContext = useRequestContext(Defaults.fastSimonServerContextScope); // create scoped context
|
|
6
|
-
const device = userAgent.includes('Mobi') ? 'mobile' : 'desktop'; // detect device
|
|
7
|
-
fastSimonContext[Defaults.fastSimonServerContextScope] = {
|
|
8
|
-
uuid: uuid,
|
|
9
|
-
storeID: storeID,
|
|
10
|
-
device: device
|
|
11
|
-
};
|
|
12
|
-
if (!fastSimonContext[Defaults.fastSimonServerContextScope]?.config) {
|
|
13
|
-
// fetch site configuration and set to context
|
|
14
|
-
const config = Site.getSiteConfiguration();
|
|
15
|
-
fastSimonContext[Defaults.fastSimonServerContextScope]['config'] = config;
|
|
16
|
-
fastSimonContext[Defaults.fastSimonServerContextScope]['editorSettings'] = device === 'mobile' ? config.settings.mobileSettings : config.settings.desktopSettings;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
1
|
+
import { useRequestContext } from "@shopify/hydrogen";
|
|
2
|
+
import { Defaults } from "../utils/defaults";
|
|
3
|
+
import { Site } from "../services/site_setup";
|
|
4
|
+
export const setSiteScopedServerContext = ({ uuid, storeID, userAgent }) => {
|
|
5
|
+
const fastSimonContext = useRequestContext(Defaults.fastSimonServerContextScope); // create scoped context
|
|
6
|
+
const device = userAgent.includes('Mobi') ? 'mobile' : 'desktop'; // detect device
|
|
7
|
+
fastSimonContext[Defaults.fastSimonServerContextScope] = {
|
|
8
|
+
uuid: uuid,
|
|
9
|
+
storeID: storeID,
|
|
10
|
+
device: device
|
|
11
|
+
};
|
|
12
|
+
if (!fastSimonContext[Defaults.fastSimonServerContextScope]?.config) {
|
|
13
|
+
// fetch site configuration and set to context
|
|
14
|
+
const config = Site.getSiteConfiguration();
|
|
15
|
+
fastSimonContext[Defaults.fastSimonServerContextScope]['config'] = config;
|
|
16
|
+
fastSimonContext[Defaults.fastSimonServerContextScope]['editorSettings'] = device === 'mobile' ? config.settings.mobileSettings : config.settings.desktopSettings;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare function ResizeDetect(): React.JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function ResizeDetect(): React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useScreenSize } from "./useScreenSize";
|
|
3
|
-
export function ResizeDetect() {
|
|
4
|
-
useScreenSize();
|
|
5
|
-
return (React.createElement(React.Fragment, null));
|
|
6
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useScreenSize } from "./useScreenSize";
|
|
3
|
+
export function ResizeDetect() {
|
|
4
|
+
useScreenSize();
|
|
5
|
+
return (React.createElement(React.Fragment, null));
|
|
6
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useClickOutside(ref: any, callback: () => void): void;
|
|
1
|
+
export declare function useClickOutside(ref: any, callback: () => void): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
export function useClickOutside(ref, callback) {
|
|
3
|
-
useEffect(() => {
|
|
4
|
-
function handleClickOutside(event) {
|
|
5
|
-
if (ref?.current && !ref?.current.contains(event.target)) {
|
|
6
|
-
callback();
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
10
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
11
|
-
}, [ref]);
|
|
12
|
-
}
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export function useClickOutside(ref, callback) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
function handleClickOutside(event) {
|
|
5
|
+
if (ref?.current && !ref?.current.contains(event.target)) {
|
|
6
|
+
callback();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
10
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
11
|
+
}, [ref]);
|
|
12
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useScreenSize: () => string | undefined;
|
|
1
|
+
export declare const useScreenSize: () => string | undefined;
|