@wf-financing/ui 1.4.1 → 1.4.2
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/CHANGELOG.md +6 -0
- package/dist/index.es.js +33665 -34853
- package/package.json +3 -3
- package/src/config/fontParameters.ts +12 -8
- package/src/config/index.ts +3 -2
- package/src/utils/applyFont.ts +2 -5
- package/src/utils/loadFont.ts +13 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/ui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/index.es.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@tanstack/react-query": "5.81.5",
|
|
35
|
-
"@wayflyer/flyui-icons": "1.
|
|
35
|
+
"@wayflyer/flyui-icons": "1.6.0",
|
|
36
36
|
"framer-motion": "^12.23.0",
|
|
37
37
|
"react-aria": "^3.41.1",
|
|
38
38
|
"react-intl": "^6.2.5",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@wf-financing/embedded-types": "0.3.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@wayflyer/flyui": "
|
|
43
|
+
"@wayflyer/flyui": "204.4.1"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
export type FontParamsType = {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
fontUrl: string;
|
|
4
|
+
fallbackFontUrl: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
const dmSansParams = {
|
|
2
8
|
fontFamily: 'DM Sans',
|
|
3
|
-
fontUrl: 'https://
|
|
4
|
-
|
|
5
|
-
const sourceSansParams = {
|
|
6
|
-
fontFamily: 'Source Sans Pro',
|
|
7
|
-
fontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/source-sans/SourceSans3-VariableFont_wght.ttf',
|
|
9
|
+
fontUrl: 'https://static.wayflyer.com/flyui-assets/fonts/dm-sans/DMSans-VariableFont_opsz,wght.ttf',
|
|
10
|
+
fallbackFontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/dm-sans/DMSans-VariableFont_opsz,wght.ttf',
|
|
8
11
|
};
|
|
12
|
+
|
|
9
13
|
const merrionSansParams = {
|
|
10
14
|
fontFamily: 'Merrion Sans',
|
|
11
|
-
fontUrl: 'https://
|
|
15
|
+
fontUrl: 'https://static.wayflyer.com/flyui-assets/fonts/merrion-sans/Merrion_Sans-Medium.woff2',
|
|
16
|
+
fallbackFontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/merrion-sans/Merrion_Sans-Medium.woff2',
|
|
12
17
|
};
|
|
13
18
|
|
|
14
|
-
export const FONT_PARAMS = {
|
|
19
|
+
export const FONT_PARAMS: Record<string, FontParamsType> = {
|
|
15
20
|
dmSansParams,
|
|
16
|
-
sourceSansParams,
|
|
17
21
|
merrionSansParams,
|
|
18
22
|
};
|
package/src/config/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
export { FONT_PARAMS } from './fontParameters';
|
|
2
|
+
export type { FontParamsType } from './fontParameters';
|
|
3
|
+
export { ROOTS_CONFIG } from './rootsParameters';
|
|
1
4
|
export { WAYFLYER_HEADLESS_SDK_ID } from './scriptId';
|
|
2
5
|
export { HEADLESS_SDK_URL } from './url';
|
|
3
|
-
export { ROOTS_CONFIG } from './rootsParameters';
|
|
4
|
-
export { FONT_PARAMS } from './fontParameters';
|
package/src/utils/applyFont.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import type { Themes } from '@wayflyer/flyui';
|
|
2
2
|
|
|
3
|
-
import { loadFont } from './loadFont';
|
|
4
3
|
import { FONT_PARAMS } from '../config';
|
|
4
|
+
import { loadFont } from './loadFont';
|
|
5
5
|
|
|
6
6
|
type ApplyFontsType = (shadow: ShadowRoot, partnerDesignId: Themes) => Promise<void>;
|
|
7
7
|
|
|
8
8
|
export const applyFont: ApplyFontsType = async (shadow, partnerDesignId) => {
|
|
9
|
-
const { dmSansParams,
|
|
9
|
+
const { dmSansParams, merrionSansParams } = FONT_PARAMS;
|
|
10
10
|
|
|
11
11
|
switch (partnerDesignId) {
|
|
12
12
|
case 'whiteLabel':
|
|
13
13
|
await loadFont(shadow, dmSansParams);
|
|
14
14
|
break;
|
|
15
|
-
case 'bigCommerce':
|
|
16
|
-
await loadFont(shadow, sourceSansParams);
|
|
17
|
-
break;
|
|
18
15
|
case 'wayflyer':
|
|
19
16
|
case 'staff':
|
|
20
17
|
case 'defaultTheme':
|
package/src/utils/loadFont.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
fontFamily: string;
|
|
3
|
-
fontUrl: string;
|
|
4
|
-
};
|
|
1
|
+
import { FontParamsType } from 'src/config';
|
|
5
2
|
|
|
6
3
|
type LoadFontType = (shadow: ShadowRoot, fontParams: FontParamsType) => Promise<void>;
|
|
7
4
|
|
|
8
5
|
export const loadFont: LoadFontType = async (shadow, fontParams) => {
|
|
9
|
-
const { fontFamily, fontUrl } = fontParams;
|
|
6
|
+
const { fontFamily, fontUrl, fallbackFontUrl } = fontParams;
|
|
10
7
|
const fontStylesId = 'font-styles';
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
let font: FontFace;
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
try {
|
|
12
|
+
font = new FontFace(fontFamily, `url(${fontUrl})`);
|
|
13
|
+
await font.load();
|
|
14
|
+
} catch {
|
|
15
|
+
font = new FontFace(fontFamily, `url(${fallbackFontUrl})`);
|
|
16
|
+
await font.load();
|
|
17
|
+
} finally {
|
|
18
|
+
document.fonts.add(font!);
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
let fontStyles = shadow.getElementById(fontStylesId);
|
|
22
|
+
|
|
18
23
|
if (!fontStyles) {
|
|
19
24
|
fontStyles = document.createElement('style');
|
|
20
25
|
fontStyles.id = fontStylesId;
|