@shopgate/engage 7.32.0-beta.3 → 7.32.0-beta.4
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/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.d.ts +2 -1
- package/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.d.ts.map +1 -1
- package/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.js +23 -1
- package/admin-preview/components/FrontendSettingsPreviewBridge/helpers.d.ts +7 -1
- package/admin-preview/components/FrontendSettingsPreviewBridge/helpers.d.ts.map +1 -1
- package/admin-preview/components/FrontendSettingsPreviewBridge/helpers.js +14 -2
- package/admin-preview/components/FrontendSettingsPreviewBridge/types.d.ts +6 -0
- package/admin-preview/components/FrontendSettingsPreviewBridge/types.d.ts.map +1 -1
- package/components/Badge/Badge.d.ts +30 -0
- package/components/Badge/Badge.d.ts.map +1 -0
- package/components/Badge/Badge.js +48 -0
- package/components/Badge/index.d.ts +3 -0
- package/components/Badge/index.d.ts.map +1 -0
- package/components/Badge/index.js +1 -0
- package/components/Badge/spec.d.ts +2 -0
- package/components/Badge/spec.d.ts.map +1 -0
- package/components/Badge/spec.js +75 -0
- package/components/View/components/Content/index.d.ts.map +1 -1
- package/components/View/components/Content/index.js +4 -1
- package/components/index.d.ts +1 -0
- package/components/index.d.ts.map +1 -1
- package/components/index.js +2 -1
- package/core/hooks/useLocalStorage.d.ts +8 -0
- package/core/hooks/useLocalStorage.d.ts.map +1 -1
- package/core/hooks/useLocalStorage.js +22 -15
- package/core/initialization/fetchSettings.d.ts +12 -0
- package/core/initialization/fetchSettings.d.ts.map +1 -0
- package/core/initialization/fetchSettings.js +134 -0
- package/core/initialization/index.d.ts +33 -2
- package/core/initialization/index.d.ts.map +1 -1
- package/core/initialization/index.js +25 -103
- package/package.json +9 -9
- package/product/components/Description/index.js +0 -2
- package/product/components/ProductCard/index.js +1 -0
- package/product/components/ProductGrid/components/Item/components/ItemDetails/index.js +1 -1
- package/product/components/ProductGrid/components/Item/components/ItemImage/index.js +10 -0
- package/product/components/ProductGrid/components/Item/components/ItemName/index.js +1 -0
- package/product/components/ProductGrid/components/Item/index.js +0 -1
- package/product/components/ProductGrid/components/Layout/index.js +17 -3
- package/product/components/ProductList/components/Layout/index.js +8 -20
- package/styles/helpers/index.d.ts +1 -0
- package/styles/helpers/index.js +1 -0
- package/styles/helpers/loadThemeCss.d.ts +14 -0
- package/styles/helpers/loadThemeCss.d.ts.map +1 -0
- package/styles/helpers/loadThemeCss.js +112 -0
- package/styles/index.d.ts +1 -1
- package/styles/index.d.ts.map +1 -1
- package/styles/reset/root.js +1 -1
- package/styles/theme/createDefaultThemeOptions/index.d.ts.map +1 -1
- package/styles/theme/createDefaultThemeOptions/index.js +12 -1
- package/styles/theme/createTheme/createComponents.types.d.ts +22 -0
- package/styles/theme/createTheme/createComponents.types.d.ts.map +1 -1
- package/styles/theme/createTheme/createComponents.types.js +23 -1
- package/styles/theme/createTheme/createCssVarsForColorSchemeThemes.d.ts.map +1 -1
- package/styles/theme/createTheme/createCssVarsForColorSchemeThemes.js +4 -1
- package/styles/theme/createTheme/index.d.ts +1 -0
- package/styles/theme/createTheme/index.d.ts.map +1 -1
- package/styles/theme/createTheme/index.js +2 -0
- package/styles/theme/createTheme/types.d.ts +2 -2
- package/styles/theme/createTheme/types.d.ts.map +1 -1
- package/styles/theme/createTheme/types.js +2 -3
- package/styles/theme/hooks/useColorScheme.d.ts +4 -3
- package/styles/theme/hooks/useColorScheme.d.ts.map +1 -1
- package/styles/theme/hooks/useColorScheme.js +4 -3
- package/styles/theme/index.d.ts +1 -1
- package/styles/theme/index.d.ts.map +1 -1
- package/styles/theme/providers/ColorSchemeContext.d.ts +19 -0
- package/styles/theme/providers/ColorSchemeContext.d.ts.map +1 -0
- package/styles/theme/providers/ColorSchemeContext.js +6 -0
- package/styles/theme/providers/ThemeProvider.d.ts +2 -12
- package/styles/theme/providers/ThemeProvider.d.ts.map +1 -1
- package/styles/theme/providers/ThemeProvider.js +32 -8
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { withScope, captureMessage, Severity as SentrySeverity } from '@sentry/browser';
|
|
2
|
+
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
import { receiveShopSettings, errorShopSettings } from '@shopgate/engage/settings/action-creators/shopSettings';
|
|
4
|
+
import { receiveMerchantSettings } from '@shopgate/engage/settings/action-creators/merchantSettings';
|
|
5
|
+
import { receiveAppSettings } from '@shopgate/engage/settings/action-creators/appSettings';
|
|
6
|
+
const REQUEST_TIMEOUT = 3000;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The payload types the settings action creators declare. Derived rather than written out,
|
|
10
|
+
* because shopSettings and merchantSettings are untyped JS whose JSDoc describes their payload
|
|
11
|
+
* as `{Array}` / `{Object}` whereas the JSONP files actually send a settings object. Deriving
|
|
12
|
+
* keeps this file honest about the mismatch and picks up the real types once that JSDoc is fixed.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Injects a script tag to fetch a settings JSONP.
|
|
17
|
+
* @param id The script id.
|
|
18
|
+
* @param src The script url.
|
|
19
|
+
* @param onError Callback for error situations.
|
|
20
|
+
*/
|
|
21
|
+
const injectScript = (id, src, onError) => {
|
|
22
|
+
const existingTag = document.querySelector(`#${id}`);
|
|
23
|
+
if (existingTag) {
|
|
24
|
+
existingTag.remove();
|
|
25
|
+
}
|
|
26
|
+
const scriptTag = document.createElement('script');
|
|
27
|
+
scriptTag.setAttribute('src', src);
|
|
28
|
+
scriptTag.setAttribute('id', id);
|
|
29
|
+
scriptTag.onerror = onError;
|
|
30
|
+
document.head.appendChild(scriptTag);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Loads a single JSONP settings source. Resolves when the payload arrived, when the script
|
|
35
|
+
* failed to load, or when REQUEST_TIMEOUT elapsed - it never rejects, so that no single
|
|
36
|
+
* source can block or delay app start indefinitely.
|
|
37
|
+
* @param params The loader params.
|
|
38
|
+
* @returns A promise that resolves once the source settled.
|
|
39
|
+
*/
|
|
40
|
+
const loadJsonpSettings = params => new Promise(resolve => {
|
|
41
|
+
const {
|
|
42
|
+
id,
|
|
43
|
+
url,
|
|
44
|
+
callbackName,
|
|
45
|
+
onReceive,
|
|
46
|
+
onError
|
|
47
|
+
} = params;
|
|
48
|
+
let settled = false;
|
|
49
|
+
let timeout;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Resolves the promise once, whichever of payload / error / timeout comes first.
|
|
53
|
+
*/
|
|
54
|
+
const settle = () => {
|
|
55
|
+
if (settled) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
settled = true;
|
|
59
|
+
clearTimeout(timeout);
|
|
60
|
+
resolve();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Started before the callback and the script are wired up, so that a synchronously firing
|
|
64
|
+
// callback / error (e.g. a data: url) settles against an already assigned timeout - otherwise
|
|
65
|
+
// clearTimeout would no-op and this timer would still fire a false timeout warning.
|
|
66
|
+
timeout = setTimeout(() => {
|
|
67
|
+
withScope(scope => {
|
|
68
|
+
scope.setLevel(SentrySeverity.Warning);
|
|
69
|
+
scope.setExtra('settingsUrl', url);
|
|
70
|
+
scope.setExtra('timeout', REQUEST_TIMEOUT);
|
|
71
|
+
captureMessage(`Fetching settings took too long: ${id}`);
|
|
72
|
+
});
|
|
73
|
+
settle();
|
|
74
|
+
}, REQUEST_TIMEOUT);
|
|
75
|
+
|
|
76
|
+
// Registered before the script is injected, since the JSONP files guard their call with
|
|
77
|
+
// `window.setX && window.setX(...)` - a callback assigned too late is a silent no-op.
|
|
78
|
+
// Deliberately never removed: the timeout may settle while the script is still in flight,
|
|
79
|
+
// and a payload arriving after that should still hydrate the store.
|
|
80
|
+
window[callbackName] = settings => {
|
|
81
|
+
onReceive(settings);
|
|
82
|
+
settle();
|
|
83
|
+
};
|
|
84
|
+
injectScript(id, url, error => {
|
|
85
|
+
withScope(scope => {
|
|
86
|
+
scope.setLevel(SentrySeverity.Error);
|
|
87
|
+
scope.setExtra('settingsUrl', url);
|
|
88
|
+
captureMessage(`Fetching settings failed: ${id}`);
|
|
89
|
+
});
|
|
90
|
+
onError?.(error);
|
|
91
|
+
settle();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Fetches all configured JSONP settings sources in parallel. Sources without a configured url
|
|
97
|
+
* are skipped. Never rejects - every source falls back to the defaults of its reducer.
|
|
98
|
+
* @param store Reference to the store.
|
|
99
|
+
* @returns A promise that resolves once all configured sources settled.
|
|
100
|
+
*/
|
|
101
|
+
export const fetchSettings = async store => {
|
|
102
|
+
const {
|
|
103
|
+
settingsUrl,
|
|
104
|
+
merchantSettingsUrl,
|
|
105
|
+
appSettingsUrl
|
|
106
|
+
} = appConfig;
|
|
107
|
+
const loaders = [];
|
|
108
|
+
if (settingsUrl) {
|
|
109
|
+
loaders.push(loadJsonpSettings({
|
|
110
|
+
id: 'shop-settings-jsonp',
|
|
111
|
+
url: settingsUrl,
|
|
112
|
+
callbackName: 'setShopSettings',
|
|
113
|
+
onReceive: settings => store.dispatch(receiveShopSettings(settings)),
|
|
114
|
+
onError: error => store.dispatch(errorShopSettings(error))
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
if (merchantSettingsUrl) {
|
|
118
|
+
loaders.push(loadJsonpSettings({
|
|
119
|
+
id: 'merchant-settings-jsonp',
|
|
120
|
+
url: merchantSettingsUrl,
|
|
121
|
+
callbackName: 'setMerchantSettings',
|
|
122
|
+
onReceive: settings => store.dispatch(receiveMerchantSettings(settings))
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
if (appSettingsUrl) {
|
|
126
|
+
loaders.push(loadJsonpSettings({
|
|
127
|
+
id: 'app-settings-jsonp',
|
|
128
|
+
url: appSettingsUrl,
|
|
129
|
+
callbackName: 'setAppSettings',
|
|
130
|
+
onReceive: settings => store.dispatch(receiveAppSettings(settings))
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
await Promise.all(loaders);
|
|
134
|
+
};
|
|
@@ -1,4 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { Store as ReduxStore, UnknownAction } from 'redux';
|
|
2
|
+
import { configureStore } from '@shopgate/pwa-common/store';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
SGConnectDev?: {
|
|
6
|
+
isDevBrowser: boolean;
|
|
7
|
+
isDev: boolean;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The app's redux store. Assembled here because configureStore is untyped JS whose JSDoc widens
|
|
13
|
+
* the return value to `Object`.
|
|
14
|
+
*
|
|
15
|
+
* dispatch stays permissive rather than using redux-thunk's ThunkDispatch: the action creators
|
|
16
|
+
* this module dispatches are untyped JS annotated `@returns {Object}` / `{Function}`, which match
|
|
17
|
+
* neither UnknownAction nor ThunkAction. Tightening it here would only force casts at every call
|
|
18
|
+
* site - it needs the JSDoc on those action creators to be fixed first.
|
|
19
|
+
*/
|
|
20
|
+
type Store = Omit<ReduxStore<unknown, UnknownAction>, 'dispatch'> & {
|
|
21
|
+
dispatch: (action: unknown) => unknown;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Initializes the app: sets up i18n, creates the store, fetches the client information and the
|
|
25
|
+
* dynamic settings, and runs all registered app initialization handlers.
|
|
26
|
+
* @param locales An object with locales.
|
|
27
|
+
* @param reducers The reducers from the theme.
|
|
28
|
+
* @param subscribers The subscribers to the streams middleware.
|
|
29
|
+
* @returns The initialized store.
|
|
30
|
+
*/
|
|
31
|
+
export declare const initialize: (locales: Record<string, unknown>, reducers: Parameters<typeof configureStore>[0], subscribers: Parameters<typeof configureStore>[1]) => Promise<{
|
|
32
|
+
store: Store;
|
|
3
33
|
}>;
|
|
34
|
+
export {};
|
|
4
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/initialization/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/initialization/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAgB5D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,YAAY,CAAC,EAAE;YACb,YAAY,EAAE,OAAO,CAAC;YACtB,KAAK,EAAE,OAAO,CAAC;SAChB,CAAC;KACH;CACF;AAED;;;;;;;;GAQG;AACH,KAAK,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IAClE,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CACxC,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,UAAU,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,EAC9C,aAAa,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;;EAuDlD,CAAC"}
|
|
@@ -1,118 +1,37 @@
|
|
|
1
|
-
import { withScope, captureMessage, Severity as SentrySeverity } from '@sentry/browser';
|
|
2
1
|
import moment from 'moment';
|
|
3
2
|
import { configureStore } from '@shopgate/pwa-common/store';
|
|
4
3
|
import { appWillInit, appWillStart } from '@shopgate/pwa-common/action-creators/app';
|
|
5
4
|
import { i18n, getAppBaseUrl, isDev, hasSGJavaScriptBridge, hasWebBridge } from '@shopgate/engage/core/helpers';
|
|
6
5
|
import fetchClientInformation from '@shopgate/pwa-common/actions/client/fetchClientInformation';
|
|
7
|
-
import appConfig from '@shopgate/
|
|
6
|
+
import { appConfig } from '@shopgate/engage';
|
|
8
7
|
import { appInitialization, configuration } from '@shopgate/engage/core/collections';
|
|
9
8
|
import { CONFIGURATION_COLLECTION_KEY_BASE_URL } from '@shopgate/engage/core/constants';
|
|
10
|
-
import { loadCustomStyles } from '@shopgate/engage/styles';
|
|
11
|
-
import {
|
|
12
|
-
import { receiveMerchantSettings } from '@shopgate/engage/settings/action-creators/merchantSettings';
|
|
13
|
-
const {
|
|
14
|
-
locales: {
|
|
15
|
-
currency: currencyLocale = null
|
|
16
|
-
} = {},
|
|
17
|
-
settingsUrl,
|
|
18
|
-
merchantSettingsUrl
|
|
19
|
-
} = appConfig;
|
|
20
|
-
const REQUEST_TIMEOUT = 3000;
|
|
21
|
-
/**
|
|
22
|
-
* Injects a script tag to fetch the shop settings JSONP.
|
|
23
|
-
* @param {string} id The script id
|
|
24
|
-
* @param {string} src The script url
|
|
25
|
-
* @param {Function} onError Callback for error situations.
|
|
26
|
-
*/
|
|
27
|
-
const injectScript = (id, src, onError) => {
|
|
28
|
-
let scriptTag = document.querySelector(`#${id}`);
|
|
29
|
-
if (scriptTag) {
|
|
30
|
-
scriptTag.remove();
|
|
31
|
-
}
|
|
32
|
-
scriptTag = document.createElement('script');
|
|
33
|
-
scriptTag.setAttribute('src', src);
|
|
34
|
-
scriptTag.setAttribute('id', id);
|
|
35
|
-
scriptTag.onerror = onError;
|
|
36
|
-
document.querySelector('head').appendChild(scriptTag);
|
|
37
|
-
};
|
|
9
|
+
import { loadCustomStyles, loadThemeCss } from '@shopgate/engage/styles';
|
|
10
|
+
import { fetchSettings } from "./fetchSettings";
|
|
38
11
|
|
|
39
12
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
13
|
+
* The app's redux store. Assembled here because configureStore is untyped JS whose JSDoc widens
|
|
14
|
+
* the return value to `Object`.
|
|
15
|
+
*
|
|
16
|
+
* dispatch stays permissive rather than using redux-thunk's ThunkDispatch: the action creators
|
|
17
|
+
* this module dispatches are untyped JS annotated `@returns {Object}` / `{Function}`, which match
|
|
18
|
+
* neither UnknownAction nor ThunkAction. Tightening it here would only force casts at every call
|
|
19
|
+
* site - it needs the JSDoc on those action creators to be fixed first.
|
|
43
20
|
*/
|
|
44
|
-
const fetchSettings = store => new Promise((resolve, reject) => {
|
|
45
|
-
if (!settingsUrl) {
|
|
46
|
-
reject();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
let timeout;
|
|
50
|
-
let merchantReceived = null;
|
|
51
|
-
let shopReceived = null;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Evaluates if completed.
|
|
55
|
-
*/
|
|
56
|
-
const evaluateEnd = () => {
|
|
57
|
-
if (!merchantReceived && merchantSettingsUrl || !shopReceived) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
clearTimeout(timeout);
|
|
61
|
-
timeout = null;
|
|
62
|
-
resolve();
|
|
63
|
-
};
|
|
64
21
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
71
|
-
window.setMerchantSettings = settings => {
|
|
72
|
-
store.dispatch(receiveMerchantSettings(settings));
|
|
73
|
-
merchantReceived = true;
|
|
74
|
-
evaluateEnd();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Error handling
|
|
78
|
-
injectScript('shop-settings-jsonp', settingsUrl, error => {
|
|
79
|
-
withScope(scope => {
|
|
80
|
-
scope.setLevel(SentrySeverity.Error);
|
|
81
|
-
scope.setExtra('settingsUrl', settingsUrl);
|
|
82
|
-
captureMessage('Fetching shop settings failed');
|
|
83
|
-
});
|
|
84
|
-
clearTimeout(timeout);
|
|
85
|
-
timeout = null;
|
|
86
|
-
store.dispatch(errorShopSettings(error));
|
|
87
|
-
reject();
|
|
88
|
-
});
|
|
89
|
-
if (merchantSettingsUrl) {
|
|
90
|
-
injectScript('merchant-settings-jsonp', merchantSettingsUrl, () => {
|
|
91
|
-
withScope(scope => {
|
|
92
|
-
scope.setLevel(SentrySeverity.Error);
|
|
93
|
-
scope.setExtra('settingsUrl', merchantSettingsUrl);
|
|
94
|
-
captureMessage('Fetching merchant settings failed');
|
|
95
|
-
});
|
|
96
|
-
clearTimeout(timeout);
|
|
97
|
-
timeout = null;
|
|
98
|
-
reject();
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
timeout = setTimeout(() => {
|
|
102
|
-
withScope(scope => {
|
|
103
|
-
scope.setLevel(SentrySeverity.Warning);
|
|
104
|
-
scope.setExtra('settingsUrl', settingsUrl);
|
|
105
|
-
scope.setExtra('timeout', REQUEST_TIMEOUT);
|
|
106
|
-
captureMessage('Fetching shop settings took too long');
|
|
107
|
-
});
|
|
108
|
-
}, REQUEST_TIMEOUT);
|
|
109
|
-
});
|
|
22
|
+
const {
|
|
23
|
+
locales: {
|
|
24
|
+
currency: currencyLocale = null
|
|
25
|
+
} = {}
|
|
26
|
+
} = appConfig;
|
|
110
27
|
|
|
111
28
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
29
|
+
* Initializes the app: sets up i18n, creates the store, fetches the client information and the
|
|
30
|
+
* dynamic settings, and runs all registered app initialization handlers.
|
|
31
|
+
* @param locales An object with locales.
|
|
32
|
+
* @param reducers The reducers from the theme.
|
|
33
|
+
* @param subscribers The subscribers to the streams middleware.
|
|
34
|
+
* @returns The initialized store.
|
|
116
35
|
*/
|
|
117
36
|
export const initialize = async (locales, reducers, subscribers) => {
|
|
118
37
|
moment.locale(process.env.LOCALE);
|
|
@@ -142,7 +61,10 @@ export const initialize = async (locales, reducers, subscribers) => {
|
|
|
142
61
|
configuration.set(CONFIGURATION_COLLECTION_KEY_BASE_URL, getAppBaseUrl());
|
|
143
62
|
store.dispatch(appWillInit(`${window.location.pathname}${window.location.search}`));
|
|
144
63
|
try {
|
|
145
|
-
|
|
64
|
+
// The order of the style loaders does not affect the cascade: loadThemeCss pins its link to
|
|
65
|
+
// the theme css insertion point in the html template, while loadCustomStyles appends its link
|
|
66
|
+
// to the end of the head.
|
|
67
|
+
const promises = [fetchSettings(store), loadCustomStyles(), loadThemeCss()];
|
|
146
68
|
await Promise.all(promises);
|
|
147
69
|
} catch (e) {
|
|
148
70
|
// Nothing to see here.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.32.0-beta.
|
|
3
|
+
"version": "7.32.0-beta.4",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"scripts": {},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@emotion/react": "^11.14.0",
|
|
20
|
-
"@shopgate/native-modules": "1.0.0-beta.
|
|
21
|
-
"@shopgate/pwa-common": "7.32.0-beta.
|
|
22
|
-
"@shopgate/pwa-common-commerce": "7.32.0-beta.
|
|
23
|
-
"@shopgate/pwa-core": "7.32.0-beta.
|
|
24
|
-
"@shopgate/pwa-ui-ios": "7.32.0-beta.
|
|
25
|
-
"@shopgate/pwa-ui-material": "7.32.0-beta.
|
|
26
|
-
"@shopgate/pwa-ui-shared": "7.32.0-beta.
|
|
20
|
+
"@shopgate/native-modules": "1.0.0-beta.32",
|
|
21
|
+
"@shopgate/pwa-common": "7.32.0-beta.4",
|
|
22
|
+
"@shopgate/pwa-common-commerce": "7.32.0-beta.4",
|
|
23
|
+
"@shopgate/pwa-core": "7.32.0-beta.4",
|
|
24
|
+
"@shopgate/pwa-ui-ios": "7.32.0-beta.4",
|
|
25
|
+
"@shopgate/pwa-ui-material": "7.32.0-beta.4",
|
|
26
|
+
"@shopgate/pwa-ui-shared": "7.32.0-beta.4",
|
|
27
27
|
"@stripe/react-stripe-js": "^1.16.5",
|
|
28
28
|
"@stripe/stripe-js": "^1.44.1",
|
|
29
29
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"validate.js": "^0.13.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@shopgate/pwa-unit-test": "7.
|
|
49
|
+
"@shopgate/pwa-unit-test": "7.31.3",
|
|
50
50
|
"@types/color": "^4.2.0",
|
|
51
51
|
"@types/lodash": "^4.17.24",
|
|
52
52
|
"@types/react-dom": "^17.0.2",
|
|
@@ -16,7 +16,6 @@ const useStyles = makeStyles()(theme => ({
|
|
|
16
16
|
lineHeight: 1.7,
|
|
17
17
|
overflow: 'hidden',
|
|
18
18
|
wordBreak: ['break-all', 'break-word'],
|
|
19
|
-
color: theme.palette.text.primary,
|
|
20
19
|
hyphens: 'auto',
|
|
21
20
|
' ul': {
|
|
22
21
|
listStyle: 'disc'
|
|
@@ -69,7 +68,6 @@ function Description({
|
|
|
69
68
|
variant: "h5",
|
|
70
69
|
component: "div",
|
|
71
70
|
className: cx(classes.title, 'theme__description_heading'),
|
|
72
|
-
color: "textPrimary",
|
|
73
71
|
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
74
72
|
string: "product.description_heading"
|
|
75
73
|
})
|
|
@@ -3,10 +3,16 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { SurroundPortals } from '@shopgate/engage/components';
|
|
4
4
|
import { PRODUCT_ITEM_IMAGE } from '@shopgate/engage/category/constants';
|
|
5
5
|
import { getProductImageSettings, ProductImage } from '@shopgate/engage/product';
|
|
6
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
const {
|
|
8
9
|
ListImage: gridResolutions
|
|
9
10
|
} = getProductImageSettings();
|
|
11
|
+
const useStyles = makeStyles()(theme => ({
|
|
12
|
+
image: {
|
|
13
|
+
background: theme.palette.background.surface
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* The item image component.
|
|
@@ -18,6 +24,9 @@ const ItemImage = ({
|
|
|
18
24
|
name,
|
|
19
25
|
imageUrl
|
|
20
26
|
}) => {
|
|
27
|
+
const {
|
|
28
|
+
classes
|
|
29
|
+
} = useStyles();
|
|
21
30
|
const portalProps = useMemo(() => ({
|
|
22
31
|
productId
|
|
23
32
|
}), [productId]);
|
|
@@ -25,6 +34,7 @@ const ItemImage = ({
|
|
|
25
34
|
portalName: PRODUCT_ITEM_IMAGE,
|
|
26
35
|
portalProps: portalProps,
|
|
27
36
|
children: /*#__PURE__*/_jsx(ProductImage, {
|
|
37
|
+
className: classes.image,
|
|
28
38
|
alt: name,
|
|
29
39
|
src: imageUrl,
|
|
30
40
|
resolutions: gridResolutions,
|
|
@@ -7,6 +7,7 @@ import { makeStyles } from '@shopgate/engage/styles';
|
|
|
7
7
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const useStyles = makeStyles()(theme => ({
|
|
9
9
|
root: {
|
|
10
|
+
fontSize: theme.typography.body2.fontSize,
|
|
10
11
|
fontWeight: theme.typography.fontWeightMedium,
|
|
11
12
|
marginTop: 1,
|
|
12
13
|
wordBreak: ['keep-all', 'break-word'],
|
|
@@ -11,9 +11,23 @@ const useStyles = makeStyles()((theme, {
|
|
|
11
11
|
':not(:empty)': {
|
|
12
12
|
marginTop: 16
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
...(columns <= 2 ? {
|
|
15
|
+
rowGap: 16,
|
|
16
|
+
'& > *': {
|
|
17
|
+
padding: '0px 8px',
|
|
18
|
+
width: `${100 / columns}%`,
|
|
19
|
+
[`&:nth-of-type(${columns}n)`]: {
|
|
20
|
+
paddingRight: 0
|
|
21
|
+
},
|
|
22
|
+
[`&:nth-of-type(${columns}n+1)`]: {
|
|
23
|
+
paddingLeft: 0
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} : {
|
|
27
|
+
display: 'grid',
|
|
28
|
+
gridGap: 16,
|
|
29
|
+
gridTemplateColumns: `repeat(${columns}, 1fr)`
|
|
30
|
+
})
|
|
17
31
|
}
|
|
18
32
|
}));
|
|
19
33
|
|
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import List from '@shopgate/pwa-common/components/List';
|
|
4
|
-
import { makeStyles } from '@shopgate/engage/styles';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const useStyles = makeStyles()(theme => ({
|
|
7
|
-
list: {
|
|
8
|
-
background: theme.palette.background.surface
|
|
9
|
-
}
|
|
10
|
-
}));
|
|
11
4
|
|
|
12
5
|
/**
|
|
13
6
|
* The Product List Layout component.
|
|
14
7
|
* @param {Object} props The component props.
|
|
15
8
|
* @return {JSX}
|
|
16
9
|
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
11
|
const Layout = ({
|
|
18
12
|
children
|
|
19
|
-
}) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
itemScope: true,
|
|
27
|
-
itemType: "http://schema.org/ItemList",
|
|
28
|
-
"data-test-id": "productList",
|
|
29
|
-
children: children
|
|
30
|
-
});
|
|
31
|
-
};
|
|
13
|
+
}) => /*#__PURE__*/_jsx(List, {
|
|
14
|
+
className: "engage__product__product-list",
|
|
15
|
+
itemScope: true,
|
|
16
|
+
itemType: "http://schema.org/ItemList",
|
|
17
|
+
"data-test-id": "productList",
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
32
20
|
Layout.defaultProps = {
|
|
33
21
|
children: null
|
|
34
22
|
};
|
|
@@ -4,6 +4,7 @@ export { setPageContentWidth } from "./setPageContentWidth";
|
|
|
4
4
|
export { setViewportHeight } from "./setViewportHeight";
|
|
5
5
|
export { toggleBodyScroll } from "./toggleBodyScroll";
|
|
6
6
|
export { loadCustomStyles } from "./loadCustomStyles";
|
|
7
|
+
export { loadThemeCss } from "./loadThemeCss";
|
|
7
8
|
export * from "./color";
|
|
8
9
|
export { responsiveMediaQuery } from "../../components/ResponsiveContainer/mediaQuery";
|
|
9
10
|
export { responsiveCondition } from "../../components/ResponsiveContainer/condition";
|
package/styles/helpers/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { setViewportHeight } from "./setViewportHeight";
|
|
|
6
6
|
export { toggleBodyScroll } from "./toggleBodyScroll";
|
|
7
7
|
export { initCSSCustomProps, initCSSCustomPropsFallback } from "./initCSSCustomProperties";
|
|
8
8
|
export { loadCustomStyles } from "./loadCustomStyles";
|
|
9
|
+
export { loadThemeCss } from "./loadThemeCss";
|
|
9
10
|
export * from "./color";
|
|
10
11
|
export { responsiveMediaQuery } from "../../components/ResponsiveContainer/mediaQuery";
|
|
11
12
|
export { responsiveCondition } from "../../components/ResponsiveContainer/condition";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the theme css file. It overrides the css custom properties that are generated during
|
|
3
|
+
* theme initialization, so it has to win the cascade against them - see `insertLinkTag` for how
|
|
4
|
+
* that order is established.
|
|
5
|
+
*
|
|
6
|
+
* A link applies at its position in the dom rather than at the time it finished loading, so the
|
|
7
|
+
* timeout below only decides how long app start waits - never which styles win.
|
|
8
|
+
*
|
|
9
|
+
* Resolves when the file loaded, when it failed, or when REQUEST_TIMEOUT elapsed - it never
|
|
10
|
+
* rejects, since the file is not guaranteed to exist and must not be able to block app start.
|
|
11
|
+
* @returns A promise that resolves once the file settled.
|
|
12
|
+
*/
|
|
13
|
+
export declare const loadThemeCss: () => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=loadThemeCss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadThemeCss.d.ts","sourceRoot":"","sources":["../../../styles/helpers/loadThemeCss.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,QAAO,OAAO,CAAC,IAAI,CAgF1C,CAAC"}
|