@stokr/components-library 3.1.0-alpha.1 → 3.1.0

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.
@@ -1,11 +1,10 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { createGlobalStyle } from "styled-components";
1
+ import { useEffect, useLayoutEffect } from "react";
4
2
  import IoniconsWOFF2 from "../static/fonts/Ionicons/Ionicons.woff2.js";
5
3
  import IoniconsWOFF from "../static/fonts/Ionicons/Ionicons.woff.js";
6
4
  import IoniconsTTF from "../static/fonts/Ionicons/Ionicons.ttf.js";
7
5
  import ioniconsCss from "../static/fonts/Ionicons/ionicons.min.css.js";
8
- const IoniconsGlobalStyle = createGlobalStyle`
6
+ const IONICONS_STYLE_ID = "stokr-ionicons";
7
+ const ioniconsStyleText = `
9
8
  @font-face {
10
9
  font-family: 'Ionicons';
11
10
  src:
@@ -18,13 +17,17 @@ const IoniconsGlobalStyle = createGlobalStyle`
18
17
 
19
18
  ${ioniconsCss}
20
19
  `;
21
- let injected = false;
20
+ function injectIonicons() {
21
+ if (document.getElementById(IONICONS_STYLE_ID)) return;
22
+ const style = document.createElement("style");
23
+ style.id = IONICONS_STYLE_ID;
24
+ style.textContent = ioniconsStyleText;
25
+ document.head.appendChild(style);
26
+ }
27
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
22
28
  function IoniconsStyles() {
23
- const [shouldRender] = useState(() => !injected);
24
- useEffect(() => {
25
- if (shouldRender) injected = true;
26
- }, [shouldRender]);
27
- return shouldRender ? /* @__PURE__ */ jsx(IoniconsGlobalStyle, {}) : null;
29
+ useIsomorphicLayoutEffect(injectIonicons, []);
30
+ return null;
28
31
  }
29
32
  export {
30
33
  IoniconsStyles
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.1.0-alpha.1",
3
+ "version": "3.1.0",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",