@stlite/browser
Version:
Browser Stlite
2 lines (1 loc) • 1.64 kB
JavaScript
import{c as r,i as h,bT as m,r as p,R as l,j as o,cD as f,b4 as u}from"./index-B3URMCDH.js";const $=r(m,{shouldForwardProp:h,target:"e1se5lgy3"})(({theme:e})=>({fontSize:e.fontSizes.sm,width:e.sizes.spinnerSize,height:e.sizes.spinnerSize,borderWidth:e.sizes.spinnerThickness,justifyContents:"center",padding:e.spacing.none,margin:e.spacing.none,borderColor:e.colors.borderColor,borderTopColor:e.colors.secondary,flexGrow:0,flexShrink:0}),""),x=r("div",{target:"e1se5lgy2"})(({theme:e,cache:t})=>({...t?{paddingBottom:e.spacing.lg,background:`linear-gradient(to bottom, ${e.colors.bgColor} 0%, ${e.colors.bgColor} 80%, transparent 100%)`}:null}),""),S=r("div",{target:"e1se5lgy1"})(({theme:e})=>({opacity:.6,fontSize:e.fontSizes.sm}),""),b=r("div",{target:"e1se5lgy0"})(({theme:e})=>({display:"flex",gap:e.spacing.sm,alignItems:"center",width:"100%"}),""),y=e=>{const t=Math.floor(e/3600),s=Math.floor(e%3600/60),n=e%60;if(t===0&&s===0)return`(${n.toFixed(1)} seconds)`;if(t===0){const d=`${s} minute${s===1?"":"s"}`,g=n===0?"":`, ${n.toFixed(1)} seconds`;return`(${d}${g})`}const i=`${t} hour${t===1?"":"s"}`,a=s===0?"":`, ${s} minute${s===1?"":"s"}`,c=n===0?"":`, ${n.toFixed(1)} seconds`;return`(${i}${a}${c})`};function z({element:e}){const{cache:t,showTime:s}=e,[n,i]=l.useState(0);return l.useEffect(()=>{if(!s)return;const a=setInterval(()=>{i(c=>c+.1)},100);return()=>clearInterval(a)},[s]),o.jsx(x,{className:f({stSpinner:!0,stCacheSpinner:t}),"data-testid":"stSpinner",cache:t,children:o.jsxs(b,{children:[o.jsx($,{}),o.jsx(u,{source:e.text,allowHTML:!1}),s&&o.jsx(S,{children:y(n)})]})})}const j=p.memo(z);export{j as default};