1 line
2.1 KiB
JavaScript
1 line
2.1 KiB
JavaScript
import{j as e}from"./vendor-react-YMhRUmcb.js";import{C as k}from"./index-D2uzyr9g.js";import{aX as C,aY as M}from"./vendor-icons-DINCNwpk.js";const E=({label:g,value:v,icon:j,trend:t,color:c="cyan",sparklineData:l})=>{const x={cyan:"text-primary",magenta:"text-secondary",lime:"text-success",gold:"text-warning",red:"text-destructive"},y={cyan:"bg-primary/10",magenta:"bg-secondary/10",lime:"bg-success/10",gold:"bg-warning/10",red:"bg-destructive/10"},b=n=>{if(!n||n.length<2)return null;const d=Math.min(...n),$=Math.max(...n)-d||1,h=100,o=40,N=u=>{const r=u.map((s,a)=>({x:a/(u.length-1)*h,y:o-(s-d)/$*o}));let f=`M ${r[0].x},${r[0].y}`;for(let s=0;s<r.length-1;s++){const a=r[s],i=r[s+1],p=(a.x+i.x)/2;f+=` C ${p},${a.y} ${p},${i.y} ${i.x},${i.y}`}return f};return e.jsx("svg",{width:"100%",height:o,viewBox:`0 0 ${h} ${o}`,className:"opacity-60 overflow-visible",children:e.jsx("path",{d:N(n),fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",className:"drop-shadow-[0_0_8px_currentColor]"})})},m=typeof t=="string"?!t.startsWith("-"):(t||0)>=0,w=typeof t=="number"?`${Math.abs(t)}%`:t;return e.jsxs(k,{variant:"surface",className:"flex flex-col justify-between h-full p-6 relative overflow-hidden",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2 relative z-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-mono text-muted-foreground uppercase tracking-widest mb-1",children:g}),e.jsx("h3",{className:"text-2xl font-display font-bold text-foreground",children:v})]}),e.jsx("div",{className:`p-2 rounded-xl ${y[c]} ${x[c]}`,children:j})]}),e.jsx("div",{className:"relative z-10 flex items-end justify-between mt-2",children:t&&e.jsxs("div",{className:`flex items-center gap-1 text-xs font-bold ${m?"text-success":"text-destructive"}`,children:[m?e.jsx(C,{className:"w-3 h-3"}):e.jsx(M,{className:"w-3 h-3"}),w," ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"vs last period"})]})}),l&&e.jsx("div",{className:`absolute bottom-0 left-0 right-0 h-12 ${x[c]} opacity-20 pointer-events-none`,children:b(l)})]})};export{E as S};
|