mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
feat(ui): add AnimatedStream component
This commit is contained in:
parent
13b37f634f
commit
b39733dca9
1 changed files with 48 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
"use client";
|
||||
import React from "react";
|
||||
|
||||
interface AnimatedStreamProps {
|
||||
/** SVG path d string */
|
||||
path: string;
|
||||
color: string;
|
||||
/** stroke-width in px */
|
||||
thickness: number;
|
||||
animated?: boolean;
|
||||
}
|
||||
|
||||
export default function AnimatedStream({ path, color, thickness, animated = true }: AnimatedStreamProps) {
|
||||
const dashLen = Math.max(8, thickness * 3);
|
||||
const gapLen = Math.max(4, thickness * 2);
|
||||
|
||||
return (
|
||||
<g>
|
||||
{/* Dim base */}
|
||||
<path d={path} fill="none" stroke={color} strokeWidth={thickness} strokeOpacity={0.12} />
|
||||
{/* Glow */}
|
||||
<path d={path} fill="none" stroke={color} strokeWidth={thickness + 6} strokeOpacity={0.06} />
|
||||
{/* Animated dashes */}
|
||||
<path
|
||||
d={path}
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={thickness}
|
||||
strokeOpacity={0.7}
|
||||
strokeDasharray={`${dashLen} ${gapLen}`}
|
||||
style={
|
||||
animated
|
||||
? {
|
||||
animation: `routingFlow 0.9s linear infinite`,
|
||||
strokeDashoffset: 0,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<style>{`
|
||||
@keyframes routingFlow {
|
||||
from { stroke-dashoffset: ${dashLen + gapLen}; }
|
||||
to { stroke-dashoffset: 0; }
|
||||
}
|
||||
`}</style>
|
||||
</g>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue