UNPKG

react-global-loading

Version:
7 lines 1.23 kB
import e,{useEffect as C,useState as x}from"react";var o=()=>{},y=()=>{o&&o(!0)},S=()=>{o&&o(!1)},z={show:y,hide:S},P=a=>{let{children:r,WrapperComponent:t,loadingSize:i=70,loadingColor:s="#eee",loadingBackgroundColor:n="#000",loadingSpeed:d=1,loadingThickness:g=7,backgroundColor:p="rgba(0, 0, 0, 0.6)",zIndex:c=999,blur:b=0,...u}=a||{},[f,m]=x(!1);C(()=>{o=m},[]);let l=()=>e.createElement(e.Fragment,null,e.createElement("style",null,` @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } `),e.createElement("div",{style:{position:"relative",animation:`spin ${d}s linear infinite`}},e.createElement("div",{style:{width:i,height:i,borderRadius:"50%",border:`${g}px solid`,borderColor:`${s} ${n} ${n} ${n}`}}))),h={...v,zIndex:c,backgroundColor:p,backdropFilter:`blur(${b}px)`};return f?t?e.createElement(t,{...u},r||l()):e.createElement("div",{style:h},r||l()):null},v={position:"fixed",top:0,left:0,right:0,bottom:0,width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center"};export{P as GlobalLoading,z as globalLoading,S as hide,y as show,o as showLoading}; //# sourceMappingURL=index.mjs.map