Data Stream
thegridcn/data-streamFreeComponent
thegridcn publishes no description for this item.
See it running
Open the demo on thegridcn
thegridcn.com/r/data-streamInstall it
npx shadcn@latest add https://thegridcn.com/r/data-stream.jsonSource
1"use client";23import * as React from "react";4import { cn } from "@/lib/utils";56interface DataStreamEntry {7 text: string;8 timestamp?: string;9 type?: "info" | "warning" | "error" | "success";10}1112interface DataStreamProps extends React.HTMLAttributes<HTMLDivElement> {13 entries: DataStreamEntry[];14 maxVisible?: number;15 streaming?: boolean;16 title?: string;17}1819const typeColor: Record<string, string> = {20 error: "text-red-500",21 info: "text-primary",22 success: "text-green-500",23 warning: "text-amber-500",24};2526const typeDot: Record<string, string> = {27 error: "bg-red-500",28 info: "bg-primary",29 success: "bg-green-500",30 warning: "bg-amber-500",31};3233export function DataStream({34 entries,35 title = "DATA STREAM",36 maxVisible = 8,37 streaming = true,38 className,39 ...props40}: DataStreamProps) {41 const scrollRef = React.useRef<HTMLDivElement>(null);42 const [visibleCount, setVisibleCount] = React.useState(0);43 const entriesRef = React.useRef(entries);44 entriesRef.current = entries;4546 // Staggered entry reveal using count instead of copying array47 React.useEffect(() => {48 setVisibleCount(0);49 let count = 0;50 const interval = setInterval(() => {51 count++;52 if (count > entriesRef.current.length) {53 clearInterval(interval);54 return;55 }56 setVisibleCount(count);57 }, 300);58 return () => clearInterval(interval);59 }, []);6061 React.useEffect(() => {62 if (scrollRef.current) {63 scrollRef.current.scrollTop = scrollRef.current.scrollHeight;64 }65 }, []);6667 return (68 <div69 data-slot="tron-data-stream"70 className={cn(71 "relative overflow-hidden rounded border border-primary/30 bg-card/80 backdrop-blur-sm",72 className73 )}74 {...props}75 >76 {/* Scanline overlay */}77 <div className="pointer-events-none absolute inset-0 bg-[repeating-linear-gradient(0deg,transparent,transparent_2px,rgba(0,0,0,0.03)_2px,rgba(0,0,0,0.03)_4px)]" />7879 {/* Header */}80 <div className="flex items-center gap-2 border-border/50 border-b px-4 py-2">81 {streaming ? (82 <div className="h-1.5 w-1.5 animate-pulse rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.6)]" />83 ) : null}84 <span className="text-[10px] text-foreground/80 uppercase tracking-widest">85 {title}86 </span>87 <span className="ml-auto font-mono text-[10px] text-foreground/40">88 {visibleCount}/{entries.length}89 </span>90 </div>91// … truncated
Files it writes
More from thegridcn
All 139 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | thegridcn | Components | Free | 2 deps | |
| Agent Avataragent-avatar | thegridcn | Components | Free | no deps | |
| Alertalert | thegridcn | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | thegridcn | Components | Free | 1 dep | |
| Announcement Barannouncement-bar | thegridcn | Components | Free | no deps | |
| Anomaly Banneranomaly-banner | thegridcn | Components | Free | no deps | |
| Arrival Panelarrival-panel | thegridcn | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | thegridcn | Components | Free | 1 dep |
