@whatmore-repo/whatmore-reactnative-sdk 1.0.11 → 1.0.12
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 +74 -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,117 +1,117 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { getGlobalState, useGlobalState } from "../../globals/useAppState_APP";
|
|
4
|
-
import { View, Text, TouchableOpacity } from 'react-native';
|
|
5
|
-
// import { Divider } from 'react-native-paper';
|
|
6
|
-
|
|
7
|
-
function SelectVariantComponent(props){
|
|
8
|
-
const product = props.product;
|
|
9
|
-
const event = props.event;
|
|
10
|
-
const productVariantOptions = props.productVariantOptions;
|
|
11
|
-
const width = props.width ?? '100%';
|
|
12
|
-
const height = props.height ?? 'auto';
|
|
13
|
-
const baseFontSize = props.baseFontSize ?? 10;
|
|
14
|
-
const onOptionSelected = props.onOptionSelected;
|
|
15
|
-
const optionTitleColor = props.optionTitleColor ?? "black";
|
|
16
|
-
|
|
17
|
-
const isInDesignMode = getGlobalState('isInDesignMode');
|
|
18
|
-
const isDemoBrand = getGlobalState('isDemoBrand');
|
|
19
|
-
const whatmorePrimaryColor = getGlobalState('whatmorePrimaryColor');
|
|
20
|
-
const whatmorePrimaryFont = getGlobalState('whatmorePrimaryFont');
|
|
21
|
-
const whatmoreShopId = getGlobalState('whatmoreShopId');
|
|
22
|
-
|
|
23
|
-
function _getFirstAvailableOption(options){
|
|
24
|
-
if(options.length == 0){return null;}
|
|
25
|
-
|
|
26
|
-
const availableOptions = options.filter(option => option['available']);
|
|
27
|
-
if(availableOptions.length == 0){return null;}
|
|
28
|
-
|
|
29
|
-
return availableOptions[0]['option'];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const [selectedOptions, setSelectedOptions] = useState(
|
|
33
|
-
[
|
|
34
|
-
_getFirstAvailableOption(productVariantOptions[0]),
|
|
35
|
-
_getFirstAvailableOption(productVariantOptions[1]),
|
|
36
|
-
_getFirstAvailableOption(productVariantOptions[2])
|
|
37
|
-
]
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
useEffect(()=>{
|
|
41
|
-
onOptionSelected(selectedOptions);
|
|
42
|
-
}, [selectedOptions]);
|
|
43
|
-
|
|
44
|
-
function _getPaddingForOption(optionName){
|
|
45
|
-
return optionName.length >= 3 ? 0 : (baseFontSize * 0.5);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<View style={{flexDirection: 'column', width: '100%', justifyContent: 'flex-start', alignItems: 'center'}}>
|
|
50
|
-
{productVariantOptions.map((options, index) => {
|
|
51
|
-
if(options.length === 0) return null;
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<View style={{flexDirection: 'column', alignItems: 'center', justifyContent: 'flex-start', width: '100%'}} key={index}>
|
|
55
|
-
<View
|
|
56
|
-
style={{
|
|
57
|
-
width: '30%', height: 2, alignItems: 'center',
|
|
58
|
-
backgroundColor: 'gray', marginTop: 10, marginBottom: 10
|
|
59
|
-
}}></View>
|
|
60
|
-
<Text
|
|
61
|
-
style={{
|
|
62
|
-
fontSize: baseFontSize * 1.2,
|
|
63
|
-
color: optionTitleColor,
|
|
64
|
-
fontFamily: whatmorePrimaryFont,
|
|
65
|
-
textAlign: 'center',
|
|
66
|
-
fontWeight: 'bold'
|
|
67
|
-
}}
|
|
68
|
-
>
|
|
69
|
-
{options[0]['type']}
|
|
70
|
-
</Text>
|
|
71
|
-
<View
|
|
72
|
-
style={{
|
|
73
|
-
flexDirection: 'row', justifyContent: 'center', flexWrap: 'wrap',
|
|
74
|
-
marginTop: 5
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
{options.map(option => (
|
|
78
|
-
<TouchableOpacity key={option['option']}
|
|
79
|
-
style={{
|
|
80
|
-
borderRadius: 2,
|
|
81
|
-
padding: 2,
|
|
82
|
-
backgroundColor: option['option'] === selectedOptions[index] ? whatmorePrimaryColor : 'white',
|
|
83
|
-
marginLeft: 5, marginRight: 5
|
|
84
|
-
}}
|
|
85
|
-
onPress={(e) => {
|
|
86
|
-
e.stopPropagation();
|
|
87
|
-
option['available'] && setSelectedOptions([
|
|
88
|
-
index === 0 ? option['option'] : selectedOptions[0],
|
|
89
|
-
index === 1 ? option['option'] : selectedOptions[1],
|
|
90
|
-
index === 2 ? option['option'] : selectedOptions[2]
|
|
91
|
-
]);
|
|
92
|
-
}}
|
|
93
|
-
>
|
|
94
|
-
<Text
|
|
95
|
-
style={{
|
|
96
|
-
textDecorationLine: option['available'] ? 'none' : 'line-through',
|
|
97
|
-
fontSize: baseFontSize,
|
|
98
|
-
color: option['available'] ? (option['option'] === selectedOptions[index] ? 'white' : 'black') : 'gray',
|
|
99
|
-
fontFamily: whatmorePrimaryFont,
|
|
100
|
-
textAlign: 'center',
|
|
101
|
-
paddingHorizontal: _getPaddingForOption(option['option'])
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
{option['option']}
|
|
105
|
-
</Text>
|
|
106
|
-
</TouchableOpacity>
|
|
107
|
-
))}
|
|
108
|
-
</View>
|
|
109
|
-
</View>
|
|
110
|
-
);
|
|
111
|
-
})}
|
|
112
|
-
</View>
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { getGlobalState, useGlobalState } from "../../globals/useAppState_APP";
|
|
4
|
+
import { View, Text, TouchableOpacity } from 'react-native';
|
|
5
|
+
// import { Divider } from 'react-native-paper';
|
|
6
|
+
|
|
7
|
+
function SelectVariantComponent(props){
|
|
8
|
+
const product = props.product;
|
|
9
|
+
const event = props.event;
|
|
10
|
+
const productVariantOptions = props.productVariantOptions;
|
|
11
|
+
const width = props.width ?? '100%';
|
|
12
|
+
const height = props.height ?? 'auto';
|
|
13
|
+
const baseFontSize = props.baseFontSize ?? 10;
|
|
14
|
+
const onOptionSelected = props.onOptionSelected;
|
|
15
|
+
const optionTitleColor = props.optionTitleColor ?? "black";
|
|
16
|
+
|
|
17
|
+
const isInDesignMode = getGlobalState('isInDesignMode');
|
|
18
|
+
const isDemoBrand = getGlobalState('isDemoBrand');
|
|
19
|
+
const whatmorePrimaryColor = getGlobalState('whatmorePrimaryColor');
|
|
20
|
+
const whatmorePrimaryFont = getGlobalState('whatmorePrimaryFont');
|
|
21
|
+
const whatmoreShopId = getGlobalState('whatmoreShopId');
|
|
22
|
+
|
|
23
|
+
function _getFirstAvailableOption(options){
|
|
24
|
+
if(options.length == 0){return null;}
|
|
25
|
+
|
|
26
|
+
const availableOptions = options.filter(option => option['available']);
|
|
27
|
+
if(availableOptions.length == 0){return null;}
|
|
28
|
+
|
|
29
|
+
return availableOptions[0]['option'];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const [selectedOptions, setSelectedOptions] = useState(
|
|
33
|
+
[
|
|
34
|
+
_getFirstAvailableOption(productVariantOptions[0]),
|
|
35
|
+
_getFirstAvailableOption(productVariantOptions[1]),
|
|
36
|
+
_getFirstAvailableOption(productVariantOptions[2])
|
|
37
|
+
]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
useEffect(()=>{
|
|
41
|
+
onOptionSelected(selectedOptions);
|
|
42
|
+
}, [selectedOptions]);
|
|
43
|
+
|
|
44
|
+
function _getPaddingForOption(optionName){
|
|
45
|
+
return optionName.length >= 3 ? 0 : (baseFontSize * 0.5);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View style={{flexDirection: 'column', width: '100%', justifyContent: 'flex-start', alignItems: 'center'}}>
|
|
50
|
+
{productVariantOptions.map((options, index) => {
|
|
51
|
+
if(options.length === 0) return null;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View style={{flexDirection: 'column', alignItems: 'center', justifyContent: 'flex-start', width: '100%'}} key={index}>
|
|
55
|
+
<View
|
|
56
|
+
style={{
|
|
57
|
+
width: '30%', height: 2, alignItems: 'center',
|
|
58
|
+
backgroundColor: 'gray', marginTop: 10, marginBottom: 10
|
|
59
|
+
}}></View>
|
|
60
|
+
<Text
|
|
61
|
+
style={{
|
|
62
|
+
fontSize: baseFontSize * 1.2,
|
|
63
|
+
color: optionTitleColor,
|
|
64
|
+
fontFamily: whatmorePrimaryFont,
|
|
65
|
+
textAlign: 'center',
|
|
66
|
+
fontWeight: 'bold'
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{options[0]['type']}
|
|
70
|
+
</Text>
|
|
71
|
+
<View
|
|
72
|
+
style={{
|
|
73
|
+
flexDirection: 'row', justifyContent: 'center', flexWrap: 'wrap',
|
|
74
|
+
marginTop: 5
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{options.map(option => (
|
|
78
|
+
<TouchableOpacity key={option['option']}
|
|
79
|
+
style={{
|
|
80
|
+
borderRadius: 2,
|
|
81
|
+
padding: 2,
|
|
82
|
+
backgroundColor: option['option'] === selectedOptions[index] ? whatmorePrimaryColor : 'white',
|
|
83
|
+
marginLeft: 5, marginRight: 5
|
|
84
|
+
}}
|
|
85
|
+
onPress={(e) => {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
option['available'] && setSelectedOptions([
|
|
88
|
+
index === 0 ? option['option'] : selectedOptions[0],
|
|
89
|
+
index === 1 ? option['option'] : selectedOptions[1],
|
|
90
|
+
index === 2 ? option['option'] : selectedOptions[2]
|
|
91
|
+
]);
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
<Text
|
|
95
|
+
style={{
|
|
96
|
+
textDecorationLine: option['available'] ? 'none' : 'line-through',
|
|
97
|
+
fontSize: baseFontSize,
|
|
98
|
+
color: option['available'] ? (option['option'] === selectedOptions[index] ? 'white' : 'black') : 'gray',
|
|
99
|
+
fontFamily: whatmorePrimaryFont,
|
|
100
|
+
textAlign: 'center',
|
|
101
|
+
paddingHorizontal: _getPaddingForOption(option['option'])
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{option['option']}
|
|
105
|
+
</Text>
|
|
106
|
+
</TouchableOpacity>
|
|
107
|
+
))}
|
|
108
|
+
</View>
|
|
109
|
+
</View>
|
|
110
|
+
);
|
|
111
|
+
})}
|
|
112
|
+
</View>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
117
|
export default SelectVariantComponent;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useGlobalState } from '../../globals/useAppState_APP';
|
|
3
|
-
import Video from 'react-native-video';
|
|
4
|
-
|
|
5
|
-
export default function AppVideoPlayer(props) {
|
|
6
|
-
const video = React.useRef(null);
|
|
7
|
-
const [isAppMuted] = useGlobalState("isAppMuted");
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<Video
|
|
11
|
-
source={{uri: props.videoUrl}}
|
|
12
|
-
ref={video}
|
|
13
|
-
muted={isAppMuted ? true : props.isMuted}
|
|
14
|
-
controls={false}
|
|
15
|
-
resizeMode='cover'
|
|
16
|
-
style={{
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
top: 0,
|
|
19
|
-
left: 0,
|
|
20
|
-
bottom: 0,
|
|
21
|
-
right: 0,
|
|
22
|
-
width: '100%', height: '100%'
|
|
23
|
-
}}
|
|
24
|
-
/>
|
|
25
|
-
)
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useGlobalState } from '../../globals/useAppState_APP';
|
|
3
|
+
import Video from 'react-native-video';
|
|
4
|
+
|
|
5
|
+
export default function AppVideoPlayer(props) {
|
|
6
|
+
const video = React.useRef(null);
|
|
7
|
+
const [isAppMuted] = useGlobalState("isAppMuted");
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Video
|
|
11
|
+
source={{uri: props.videoUrl}}
|
|
12
|
+
ref={video}
|
|
13
|
+
muted={isAppMuted ? true : props.isMuted}
|
|
14
|
+
controls={false}
|
|
15
|
+
resizeMode='cover'
|
|
16
|
+
style={{
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
top: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
bottom: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
width: '100%', height: '100%'
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
26
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export const WHATMORE_BACKEND_BASE_URL = "https://api.whatmore.live";
|
|
2
|
-
export const WHATMORE_BACKEND_CACHE_BASE_URL = "https://whatmore-api-cdn-cache.azureedge.net";
|
|
3
|
-
|
|
4
|
-
// widget types
|
|
5
|
-
export const carousel = "carousel"
|
|
6
|
-
export const videoPopup = "video_popup"
|
|
7
|
-
export const stories = "stories"
|
|
8
|
-
|
|
9
|
-
// page types
|
|
10
|
-
export const homepage = "homepage"
|
|
11
|
-
export const productPage = "product_page"
|
|
12
|
-
|
|
1
|
+
export const WHATMORE_BACKEND_BASE_URL = "https://api.whatmore.live";
|
|
2
|
+
export const WHATMORE_BACKEND_CACHE_BASE_URL = "https://whatmore-api-cdn-cache.azureedge.net";
|
|
3
|
+
|
|
4
|
+
// widget types
|
|
5
|
+
export const carousel = "carousel"
|
|
6
|
+
export const videoPopup = "video_popup"
|
|
7
|
+
export const stories = "stories"
|
|
8
|
+
|
|
9
|
+
// page types
|
|
10
|
+
export const homepage = "homepage"
|
|
11
|
+
export const productPage = "product_page"
|
|
12
|
+
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { createGlobalState } from "react-hooks-global-state";
|
|
2
|
-
|
|
3
|
-
export const { GlobalStateProvider, useGlobalState, getGlobalState, setGlobalState } = createGlobalState({
|
|
4
|
-
verticalSwiperViewActiveIndex: 0,
|
|
5
|
-
isAppMuted: false,
|
|
6
|
-
brandDomainContext: 'shopify',
|
|
7
|
-
isInDesignMode: true,
|
|
8
|
-
isDemoBrand: true,
|
|
9
|
-
whatmoreShopId: '58669793418',
|
|
10
|
-
whatmorePrimaryFont: 'sans-serif',
|
|
11
|
-
whatmorePrimaryColor: '#d97777',
|
|
12
|
-
whatmoreAllowAutoSlide: true,
|
|
13
|
-
whatmoreAddedToCart: false,
|
|
14
|
-
commandsObject: {},
|
|
15
|
-
template: 'template-swipe-a',
|
|
16
|
-
modalUsed: true,
|
|
17
|
-
activateMock: false
|
|
1
|
+
import { createGlobalState } from "react-hooks-global-state";
|
|
2
|
+
|
|
3
|
+
export const { GlobalStateProvider, useGlobalState, getGlobalState, setGlobalState } = createGlobalState({
|
|
4
|
+
verticalSwiperViewActiveIndex: 0,
|
|
5
|
+
isAppMuted: false,
|
|
6
|
+
brandDomainContext: 'shopify',
|
|
7
|
+
isInDesignMode: true,
|
|
8
|
+
isDemoBrand: true,
|
|
9
|
+
whatmoreShopId: '58669793418',
|
|
10
|
+
whatmorePrimaryFont: 'sans-serif',
|
|
11
|
+
whatmorePrimaryColor: '#d97777',
|
|
12
|
+
whatmoreAllowAutoSlide: true,
|
|
13
|
+
whatmoreAddedToCart: false,
|
|
14
|
+
commandsObject: {},
|
|
15
|
+
template: 'template-swipe-a',
|
|
16
|
+
modalUsed: true,
|
|
17
|
+
activateMock: false
|
|
18
18
|
});
|