@whatmore-repo/whatmore-reactnative-sdk 1.0.11 → 1.0.13
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/commands.txt +45 -38
- package/index.js +31 -31
- package/package.json +29 -29
- package/pre-integration-steps.txt +2 -2
- package/src/api/cart-commands/CartCommands.js +26 -26
- package/src/api/navigation-commands/NavigationCommands.js +16 -16
- package/src/api/partners/PartnerUtils.js +10 -10
- package/src/api/partners/appbrew/AppbrewCommands.js +26 -26
- package/src/api/product-details-commands/ProductDetailsCommands.js +389 -389
- package/src/api/shopify-commands/ShopifyCommands.js +28 -28
- package/src/api/whatmore-backend/WhatmoreMetricCommands.js +159 -159
- package/src/components/EventClickComponent.js +30 -30
- package/src/components/EventShoppingOverlay.js +75 -74
- package/src/components/EventShoppingView.js +31 -31
- package/src/components/EventsVerticalSwipeView.js +59 -59
- package/src/components/EventsVerticalSwipeViewNoModal.js +51 -51
- package/src/components/WhatmoreRootComponent.js +88 -88
- package/src/components/commons/AppMuteUnmuteIcon.js +35 -35
- package/src/components/cta-buttons/AddToCartButton.jsx +345 -345
- package/src/components/product-tiles/ProductPriceBadge.js +51 -51
- package/src/components/product-tiles/ProductTileV1.js +204 -204
- package/src/components/product-tiles/SelectVariantComponent.js +116 -116
- package/src/components/video-player/AppVideoPlayer.js +25 -25
- package/src/constants/AppGlobalVars.js +12 -12
- package/src/globals/useAppState_APP.js +17 -17
- package/src/hooks/useAddToCartStates.js +194 -194
- package/src/{components/icons → icons}/icon-components/CartIcon.jsx +26 -26
- package/src/{components/icons → icons}/icon-components/LoadingIcon.jsx +17 -17
- package/src/{components/icons → icons}/icon-components/MuteIcon.jsx +22 -22
- package/src/{components/icons → icons}/icon-components/PlusIcon.jsx +26 -26
- package/src/{components/icons → icons}/icon-components/UnmuteIcon.jsx +22 -22
- package/src/{components/icons → icons}/svg-utils.txt +6 -6
- package/src/utils/ColorUtils.js +39 -39
- package/src/utils/EventSanityUtils.js +21 -21
- package/src/utils/PriceUtils.js +27 -27
- package/src/utils/ProductUtils.js +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## SVG repo:
|
|
2
|
-
https://www.svgrepo.com/vectors/volume/
|
|
3
|
-
|
|
4
|
-
## SVG to react-native
|
|
5
|
-
https://transform.tools/svg-to-react-native
|
|
6
|
-
|
|
1
|
+
## SVG repo:
|
|
2
|
+
https://www.svgrepo.com/vectors/volume/
|
|
3
|
+
|
|
4
|
+
## SVG to react-native
|
|
5
|
+
https://transform.tools/svg-to-react-native
|
|
6
|
+
|
package/src/utils/ColorUtils.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
// Version 4.1
|
|
2
|
-
|
|
3
|
-
// https://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
|
|
4
|
-
// https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js)
|
|
5
|
-
|
|
6
|
-
// Opacity level 0-15
|
|
7
|
-
export const shadeColorHex = function(hexCode, opacityLevel){
|
|
8
|
-
return hexCode + opacityLevel.toString(16) + opacityLevel.toString(16);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const shadeColor=(p,c0,c1,l)=>{
|
|
12
|
-
let r,g,b,P,f,t,h,m=Math.round,a=typeof(c1)=="string";
|
|
13
|
-
if(typeof(p)!="number"||p<-1||p>1||typeof(c0)!="string"||(c0[0]!='r'&&c0[0]!='#')||(c1&&!a))return null;
|
|
14
|
-
h=c0.length>9,h=a?c1.length>9?true:c1=="c"?!h:false:h,f=shadeColor.pSBCr(c0),P=p<0,t=c1&&c1!="c"?shadeColor.pSBCr(c1):P?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},p=P?p*-1:p,P=1-p;
|
|
15
|
-
if(!f||!t)return null;
|
|
16
|
-
if(l)r=m(P*f.r+p*t.r),g=m(P*f.g+p*t.g),b=m(P*f.b+p*t.b);
|
|
17
|
-
else r=m((P*f.r**2+p*t.r**2)**0.5),g=m((P*f.g**2+p*t.g**2)**0.5),b=m((P*f.b**2+p*t.b**2)**0.5);
|
|
18
|
-
a=f.a,t=t.a,f=a>=0||t>=0,a=f?a<0?t:t<0?a:a*P+t*p:0;
|
|
19
|
-
if(h)return"rgb"+(f?"a(":"(")+r+","+g+","+b+(f?","+m(a*1000)/1000:"")+")";
|
|
20
|
-
else return"#"+(4294967296+r*16777216+g*65536+b*256+(f?m(a*255):0)).toString(16).slice(1,f?undefined:-2)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
shadeColor.pSBCr=(d)=>{
|
|
24
|
-
const i=parseInt;
|
|
25
|
-
let n=d.length,x={};
|
|
26
|
-
if(n>9){
|
|
27
|
-
const [r, g, b, a] = (d = d.split(','));
|
|
28
|
-
n = d.length;
|
|
29
|
-
if(n<3||n>4)return null;
|
|
30
|
-
x.r=i(r[3]=="a"?r.slice(5):r.slice(4)),x.g=i(g),x.b=i(b),x.a=a?parseFloat(a):-1
|
|
31
|
-
}else{
|
|
32
|
-
if(n==8||n==6||n<4)return null;
|
|
33
|
-
if(n<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(n>4?d[4]+d[4]:"");
|
|
34
|
-
d=i(d.slice(1),16);
|
|
35
|
-
if(n==9||n==5)x.r=d>>24&255,x.g=d>>16&255,x.b=d>>8&255,x.a=Math.round((d&255)/0.255)/1000;
|
|
36
|
-
else x.r=d>>16,x.g=d>>8&255,x.b=d&255,x.a=-1
|
|
37
|
-
}return x
|
|
38
|
-
};
|
|
39
|
-
|
|
1
|
+
// Version 4.1
|
|
2
|
+
|
|
3
|
+
// https://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
|
|
4
|
+
// https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js)
|
|
5
|
+
|
|
6
|
+
// Opacity level 0-15
|
|
7
|
+
export const shadeColorHex = function(hexCode, opacityLevel){
|
|
8
|
+
return hexCode + opacityLevel.toString(16) + opacityLevel.toString(16);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const shadeColor=(p,c0,c1,l)=>{
|
|
12
|
+
let r,g,b,P,f,t,h,m=Math.round,a=typeof(c1)=="string";
|
|
13
|
+
if(typeof(p)!="number"||p<-1||p>1||typeof(c0)!="string"||(c0[0]!='r'&&c0[0]!='#')||(c1&&!a))return null;
|
|
14
|
+
h=c0.length>9,h=a?c1.length>9?true:c1=="c"?!h:false:h,f=shadeColor.pSBCr(c0),P=p<0,t=c1&&c1!="c"?shadeColor.pSBCr(c1):P?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},p=P?p*-1:p,P=1-p;
|
|
15
|
+
if(!f||!t)return null;
|
|
16
|
+
if(l)r=m(P*f.r+p*t.r),g=m(P*f.g+p*t.g),b=m(P*f.b+p*t.b);
|
|
17
|
+
else r=m((P*f.r**2+p*t.r**2)**0.5),g=m((P*f.g**2+p*t.g**2)**0.5),b=m((P*f.b**2+p*t.b**2)**0.5);
|
|
18
|
+
a=f.a,t=t.a,f=a>=0||t>=0,a=f?a<0?t:t<0?a:a*P+t*p:0;
|
|
19
|
+
if(h)return"rgb"+(f?"a(":"(")+r+","+g+","+b+(f?","+m(a*1000)/1000:"")+")";
|
|
20
|
+
else return"#"+(4294967296+r*16777216+g*65536+b*256+(f?m(a*255):0)).toString(16).slice(1,f?undefined:-2)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
shadeColor.pSBCr=(d)=>{
|
|
24
|
+
const i=parseInt;
|
|
25
|
+
let n=d.length,x={};
|
|
26
|
+
if(n>9){
|
|
27
|
+
const [r, g, b, a] = (d = d.split(','));
|
|
28
|
+
n = d.length;
|
|
29
|
+
if(n<3||n>4)return null;
|
|
30
|
+
x.r=i(r[3]=="a"?r.slice(5):r.slice(4)),x.g=i(g),x.b=i(b),x.a=a?parseFloat(a):-1
|
|
31
|
+
}else{
|
|
32
|
+
if(n==8||n==6||n<4)return null;
|
|
33
|
+
if(n<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(n>4?d[4]+d[4]:"");
|
|
34
|
+
d=i(d.slice(1),16);
|
|
35
|
+
if(n==9||n==5)x.r=d>>24&255,x.g=d>>16&255,x.b=d>>8&255,x.a=Math.round((d&255)/0.255)/1000;
|
|
36
|
+
else x.r=d>>16,x.g=d>>8&255,x.b=d&255,x.a=-1
|
|
37
|
+
}return x
|
|
38
|
+
};
|
|
39
|
+
|
|
40
40
|
export default shadeColor;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export const removeInvalidEvents = function(data, brandId){
|
|
2
|
-
if(data == null){
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
return data.filter((event) => {
|
|
7
|
-
return event.products.length > 0;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const extractEvents = function(data, isCollectionsTemplate){
|
|
12
|
-
if(data == null){
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if(isCollectionsTemplate){
|
|
17
|
-
return (data[0]['events']);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
1
|
+
export const removeInvalidEvents = function(data, brandId){
|
|
2
|
+
if(data == null){
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return data.filter((event) => {
|
|
7
|
+
return event.products.length > 0;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const extractEvents = function(data, isCollectionsTemplate){
|
|
12
|
+
if(data == null){
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if(isCollectionsTemplate){
|
|
17
|
+
return (data[0]['events']);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return data;
|
|
21
|
+
}
|
package/src/utils/PriceUtils.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import getSymbolFromCurrency from 'currency-symbol-map'
|
|
3
|
-
|
|
4
|
-
function priceWithCommas(price){
|
|
5
|
-
return price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function roundedPrice(price){
|
|
9
|
-
// is decimal more than 0.1
|
|
10
|
-
if(price % 1 >= 0.1){
|
|
11
|
-
// if decimal value is more than 0.1 but not significant in that currency
|
|
12
|
-
const priceAsString = price.toString();
|
|
13
|
-
if(priceAsString.split('.')[0].length >= 4){
|
|
14
|
-
return parseInt(price);
|
|
15
|
-
}
|
|
16
|
-
return price.toFixed(2);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return parseInt(price);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getPriceStringWithCurrency(price, spaceString = "", currencyCode = "INR"){
|
|
23
|
-
if(!price || typeof price == undefined){
|
|
24
|
-
return "";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return getSymbolFromCurrency(currencyCode) + spaceString + priceWithCommas(roundedPrice(price));
|
|
1
|
+
|
|
2
|
+
import getSymbolFromCurrency from 'currency-symbol-map'
|
|
3
|
+
|
|
4
|
+
function priceWithCommas(price){
|
|
5
|
+
return price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function roundedPrice(price){
|
|
9
|
+
// is decimal more than 0.1
|
|
10
|
+
if(price % 1 >= 0.1){
|
|
11
|
+
// if decimal value is more than 0.1 but not significant in that currency
|
|
12
|
+
const priceAsString = price.toString();
|
|
13
|
+
if(priceAsString.split('.')[0].length >= 4){
|
|
14
|
+
return parseInt(price);
|
|
15
|
+
}
|
|
16
|
+
return price.toFixed(2);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return parseInt(price);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getPriceStringWithCurrency(price, spaceString = "", currencyCode = "INR"){
|
|
23
|
+
if(!price || typeof price == undefined){
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return getSymbolFromCurrency(currencyCode) + spaceString + priceWithCommas(roundedPrice(price));
|
|
28
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function getProductHandle(product){
|
|
4
|
-
const match = product.product_link.match(/\/products\/([^/?&]+)/);
|
|
5
|
-
return match ? match[1] : null;
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export function getProductHandle(product){
|
|
4
|
+
const match = product.product_link.match(/\/products\/([^/?&]+)/);
|
|
5
|
+
return match ? match[1] : null;
|
|
6
6
|
}
|