"use client"; import React from 'react'; import { ComponentShareButton } from './ComponentShareButton'; import { Reveal } from './Reveal'; interface WaterfallEvent { name: string; start: number; duration: number; } interface WaterfallChartProps { title?: string; events: WaterfallEvent[]; totalDuration?: number; showShare?: boolean; } export const WaterfallChart: React.FC = ({ title = 'Resource Waterfall', events, totalDuration }) => { const maxTime = totalDuration || Math.max(...events.map(e => e.start + e.duration)); const getDefaultColor = (name: string) => { const n = name.toLowerCase(); if (n.includes('html') || n.includes('document')) return 'bg-slate-800'; if (n.includes('js') || n.includes('script')) return 'bg-amber-400'; if (n.includes('css') || n.includes('style')) return 'bg-blue-400'; if (n.includes('img') || n.includes('image')) return 'bg-emerald-400'; if (n.includes('font')) return 'bg-pink-400'; return 'bg-slate-300'; }; // Generate stable hash for share button const shareId = `waterfall-${title.toLowerCase().replace(/[^a-z0-9]/g, '-')}`; return (
{/* Ambient Background Glow matching the homepage feel */}
{/* Subtle top shine */}
{/* Share Button top right */}

{title}

Total Time: {maxTime}ms
{/* Elegant Grid Lines */}
{[0, 0.25, 0.5, 0.75, 1].map((tick) => (
{Math.round(maxTime * tick)}
))}
{events.map((event, i) => { const left = (event.start / maxTime) * 100; const width = Math.max((event.duration / maxTime) * 100, 0.5); return (
{event.name}
{event.duration}ms
); })}
); };