Skip to content

Commit 1f6a4fb

Browse files
feat: replace static placeholder with interactive mock sparkline preview in edit mode
1 parent dba11d5 commit 1f6a4fb

1 file changed

Lines changed: 45 additions & 2 deletions

File tree

src/components/dashboard-builder/widgets/SparklineWidget.tsx

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,51 @@ export function SparklineWidget({
126126

127127
<CardContent className="p-0 flex-1 flex flex-col relative h-full">
128128
{isEditMode ? (
129-
<div className="absolute inset-4 flex items-center justify-center bg-muted/30 text-muted-foreground text-sm rounded outline-dashed outline-2 outline-border">
130-
Sparkline Preview
129+
<div className="flex flex-col h-full w-full p-4 relative overflow-hidden group">
130+
{/* Mock Content */}
131+
<div className="flex-1 flex flex-col items-center justify-center mt-7 relative z-10">
132+
<div className="flex items-baseline gap-1 opacity-90">
133+
<span className="text-5xl font-extrabold tracking-tight" style={{ color: strokeColor }}>
134+
42
135+
</span>
136+
<span className="text-lg font-bold text-muted-foreground/80">
137+
{unit || 'unit'}
138+
</span>
139+
</div>
140+
<div className="flex items-center text-xs font-bold px-2 py-0.5 mt-2 text-green-500 opacity-90">
141+
<ArrowUp className="w-3 h-3 mr-1" strokeWidth={3} />
142+
<span>12.5%</span>
143+
</div>
144+
</div>
145+
146+
{/* Bottom Offset for Graph space */}
147+
<div className="h-10" />
148+
149+
{/* Mock Sparkline background */}
150+
<div className="absolute bottom-0 left-0 right-0 h-[50%] pointer-events-none opacity-20 z-0">
151+
<ResponsiveContainer width="100%" height="100%">
152+
<AreaChart data={[
153+
{ v: 30 }, { v: 45 }, { v: 35 }, { v: 60 }, { v: 40 }, { v: 55 }, { v: 50 }
154+
]}>
155+
<Area
156+
type="monotone"
157+
dataKey="v"
158+
stroke={strokeColor}
159+
fill={strokeColor}
160+
strokeWidth={2}
161+
isAnimationActive={false}
162+
/>
163+
</AreaChart>
164+
</ResponsiveContainer>
165+
</div>
166+
167+
{/* Overlay Label
168+
<div className="absolute inset-0 flex items-center justify-center bg-background/40 backdrop-blur-[1px] z-20 opacity-0 group-hover:opacity-100 transition-opacity">
169+
<div className="bg-background border border-border px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2">
170+
<div className="w-2 h-2 rounded-full bg-primary animate-pulse" />
171+
<span className="text-[10px] font-bold uppercase tracking-widest">Sparkline Preview</span>
172+
</div>
173+
</div> */}
131174
</div>
132175
) : isLoading && data.length === 0 ? (
133176
<div className="absolute inset-0 p-4 shrink-0 h-full">

0 commit comments

Comments
 (0)