@bbki.ng/site 5.5.26 → 5.5.28

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.5.28
4
+
5
+ ### Patch Changes
6
+
7
+ - a1c157f: icon font preloading
8
+
9
+ ## 5.5.27
10
+
11
+ ### Patch Changes
12
+
13
+ - 1da1967: fix cls
14
+
3
15
  ## 5.5.26
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "5.5.26",
3
+ "version": "5.5.28",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,6 +22,7 @@ export const FontRules: Array<FontRule> = [
22
22
  src: '/fonts/yao-icons.woff2',
23
23
  format: 'woff2',
24
24
  hideGlyphOnLoading: true,
25
+ preload: true,
25
26
  },
26
27
  },
27
28
  ];
@@ -63,9 +63,10 @@ class XwyPlugin implements IPlugin {
63
63
 
64
64
  private initFontLoadingListener() {
65
65
  // listen font loading status and add class to body for styling
66
- document.documentElement.classList.add(LOADING_CLASS);
66
+ console.log('Initializing font loading listener');
67
+ document.body.classList.add(LOADING_CLASS);
67
68
  document.fonts.ready.then(() => {
68
- document.documentElement.classList.remove(LOADING_CLASS);
69
+ document.body.classList.remove(LOADING_CLASS);
69
70
  });
70
71
  }
71
72
 
@@ -5,6 +5,7 @@ export interface FontConfig {
5
5
  fontWeight?: string;
6
6
  fontStyle?: string;
7
7
  hideGlyphOnLoading?: boolean;
8
+ preload?: boolean;
8
9
  }
9
10
 
10
11
  export interface FontRule {
@@ -13,6 +13,17 @@ export const loadFont = (config: FontConfig) => {
13
13
  `
14
14
  : '';
15
15
 
16
+ const existingLink = document.querySelector(`link[rel="preload"][href="${config.src}"]`);
17
+ if (config.preload && !existingLink) {
18
+ const link = document.createElement('link');
19
+ link.rel = 'preload';
20
+ link.as = 'font';
21
+ link.href = config.src;
22
+ link.type = `font/${config.format}`;
23
+ link.crossOrigin = 'anonymous';
24
+ document.head.appendChild(link);
25
+ }
26
+
16
27
  const style = document.createElement('style');
17
28
  style.id = styleId;
18
29
  style.textContent = `