UNPKG

react-adobe-fonts

Version:
2 lines 1.09 kB
import s,{useEffect as A}from"react";var I=({kitId:t,onLoading:r,onActive:f,onInactive:l,onFontLoading:v,onFontActive:g,onFontInactive:m})=>{A(()=>{let e={kitId:t,scriptTimeout:3e3,async:!0,loading:r,active:f,inactive:l,fontloading:v,fontactive:g,fontinactive:m},i=window.document,a=i.documentElement,c=i.getElementsByTagName("script")[0],u=setTimeout(function(){a.className=a.className.replace(/\bwf-loading\b/g,"")+" wf-inactive"},e.scriptTimeout),n=i.createElement("script"),o,d=!1;a.className+=" wf-loading",n.src="https://use.typekit.net/"+e.kitId+".js",n.async=!0,n.onload=n.onreadystatechange=function(){if(o=this.readyState,!(d||o&&o!="complete"&&o!="loaded")){d=!0,clearTimeout(u);try{window.Typekit.load(e)}catch{}}},c.parentNode!=null&&c.parentNode.insertBefore(n,c)},[])},k=t=>(I({kitId:t.kitId,onLoading:t.onLoading,onActive:t.onActive,onInactive:t.onInactive,onFontLoading:t.onFontLoading,onFontActive:t.onFontActive,onFontInactive:t.onFontInactive}),s.createElement(s.Fragment,null,t.children));export{k as AdobeFonts,I as useAdobeFonts}; //# sourceMappingURL=index.mjs.map