+
+ {/* Background glow */}
+
+
- const data = opportunities.map(op => ({ name: op.title || 'Untitled', size: parseSavings(op.estimatedSavings) }));
-
- return (
-
-
Opportunities Tree Map
-
-
-
- {
- if (!payload || payload.length === 0) return null;
- const item = payload[0].payload;
- return (
-
-
{item.name}
-
{item.size} ms estimated savings
-
- );
- }} />
-
-
-
-
- );
- };
-
- const renderDiagnostics = (diagnostics: any = {}) => (
-
-
Diagnostics
- {Object.keys(diagnostics).length === 0 &&
No diagnostics available.
}
-
- {Object.entries(diagnostics).map(([key, value]) => (
-
-
-
- {key.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase())}
-
- {key === 'http2' && (
-
- All resources should be served via HTTP/2 for better performance.
-
- )}
-
-
- {value ? 'Pass' : 'Fail'}
-
-
- ))}
-
-
- );
-
- return (
-
- {/* Tabs with your flex-col style */}
-
-
-
-
-
-
- {
- loading ? (
-
-

-
-
-
-
- ) : (
- < div className="w-full mt-4 border p-5">
- {/* Top Scores */}
-
Diagnose performance issues
-
- {['performance', 'accessibility', 'bestPractices', 'seo', 'pwa'].map((key) => {
- const score = currentReport.scores?.[key];
- if (score === undefined || score === null) return null;
- return (
-
- {renderScoreCircle(score)}
-
{key.charAt(0).toUpperCase() + key.slice(1)}
-
- );
- })}
-
-
- {/* Metrics */}
- {renderMetrics(currentReport.metrics)}
-
- {/* Opportunities */}
- {renderOpportunities(currentReport.opportunities)}
-
- {/* Tree Map */}
- {renderTreeMap(currentReport.opportunities)}
-
- {/* Diagnostics */}
- {renderDiagnostics(currentReport.diagnostics)}
-
- {/* Screenshot */}
- {currentReport.screenshot && (
-
-

+ {/* Central Score */}
+
+ {hoveredMetric ? (
+
+
{hoveredMetric}
+
s.label === hoveredMetric)?.value)
+ }}>
+ {segments.find(s => s.label === hoveredMetric)?.value?.split(' ')[0]}
+
+
+ ) : (
+
+
+ {score}
+
)}
- )
- }
-
+ {/* Metric Labels (SI, FCP, LCP...) */}
+
+ {segments.map((seg, idx) => {
+ // Manual angle positioning for exact match to image
+ const angles = { SI: -140, FCP: -50, LCP: 20, TBT: 90, CLS: 180 };
+ const angle = angles[seg.id as keyof typeof angles];
+ const labelRadius = radius + 35;
+ const x = radius + labelRadius * Math.cos((angle * Math.PI) / 180);
+ const y = radius + labelRadius * Math.sin((angle * Math.PI) / 180);
+
+ return (
+
+ {seg.label}
+
+ );
+ })}
+
+
+
+
+
Performance
+
+ Values are estimated and may vary. The performance score is calculated directly from these metrics.
+
+
+
+
+ );
+ };
+
+ const renderMiniScore = (score: number, title: string) => {
+ const color = getScoreColor(score);
+ return (
+
+
+ {score}
+
+
{title}
+
+ );
+ };
+
+ const renderMetricPSI = (label: string, value: string) => {
+ let statusColor = "#10b981";
+ const num = parseFloat(value || "0");
+ if (label.includes('Paint') || label.includes('Interactive')) {
+ const limit = label.includes('Largest') ? 2.5 : 1.5;
+ if (num > limit) statusColor = "#f59e0b";
+ if (num > limit * 2) statusColor = "#ef4444";
+ }
+
+ return (
+
+ );
+ };
+
+ if (loading) {
+ return (
+
+
+
Quantifying speed...
+
Simulated device runs are operating in parallel to provide instant feedback.
+
+
+ );
+ }
+
+ if (!reports) return null;
+
+ return (
+
+ {/* Environment Control */}
+
+
+
+
+
+
+
+ {/* Core Section: Large Score and Summary */}
+
+
+
+ {renderScoreCircleLarge(currentReport?.scores?.performance, currentReport?.metrics)}
+
+
+ {renderMiniScore(currentReport?.scores?.accessibility, "Accessibility")}
+ {renderMiniScore(currentReport?.scores?.bestPractices, "Best Practices")}
+ {renderMiniScore(currentReport?.scores?.seo, "SEO")}
+ {currentReport?.scores?.pwa !== null && renderMiniScore(currentReport?.scores?.pwa, "PWA")}
+
+
+
+
+
+

+
+
+
+
Device: {activeTab.toUpperCase()}
+
Status: AUDIT COMPLETE
+
+
+
+
+
+ {/* Metrics Section */}
+
+
+
+ {renderMetricPSI("First Contentful Paint", currentReport?.metrics?.firstContentfulPaint)}
+ {renderMetricPSI("Speed Index", currentReport?.metrics?.speedIndex)}
+ {renderMetricPSI("Largest Contentful Paint", currentReport?.metrics?.largestContentfulPaint)}
+ {renderMetricPSI("Time to Interactive", currentReport?.metrics?.timeToInteractive)}
+ {renderMetricPSI("Total Blocking Time", currentReport?.metrics?.totalBlockingTime)}
+ {renderMetricPSI("Cumulative Layout Shift", currentReport?.metrics?.cumulativeLayoutShift)}
+
+
+
+ {/* Timeline Filmstrip */}
+ {currentReport?.thumbnails?.length > 0 && (
+
+
+
Filmstrip
+
+
Visual Loading sequence
+
+
+ {currentReport.thumbnails.map((thumb: any, i: number) => (
+
+
+

+
+
{(thumb.timing / 1000).toFixed(1)}s
+
+ ))}
+
+
+ )}
+
+ {/* Detailed Audits Grid */}
+
+ {/* Opportunities */}
+
+
+ ⚡
+
Performance Opportunities
+
+
+ {currentReport?.opportunities?.length > 0 ? (
+ currentReport.opportunities.map((op: any, i: number) => (
+
+
+
{op.title}
+ -{op.estimatedSavings}
+
+
{op.description.split('[')[0]}
+
+ ))
+ ) : (
+
+ No performance bottlenecks identified! ✨
+
+ )}
+
+
+
+ {/* Diagnostics */}
+
+
+ 🛡️
+
Security & Best Practices
+
+
+ {Object.entries(currentReport?.diagnostics || {}).map(([key, pass]: any, i: number) => (
+
+
+
+ {pass ? "✓" : "!"}
+
+
+ {key.replace(/([A-Z])/g, ' $1').replace(/^./, (str: string) => str.toUpperCase())}
+
+
+
+ {pass ? "Secure" : "Warning"}
+
+
+ ))}
+
+
+
+
+ {/* Passed Audits Recap */}
+
+
+
Passed Checks
+
+
All successful audits
+
+
+ {currentReport?.passedAudits?.map((title: string, i: number) => (
+
+ ✓
+ {title}
+
+ ))}
+
+
+
+ {/* Treemap Final CTA */}
+ {currentReport?.treemapPath && (
+
+
+ {/* Abstract background shape */}
+
+
+
In-Depth Resource Treemap Analysis
+
Uncover hidden third-party scripts and Bloated assets that are stealing your performance. Interactive visual report awaits.
+
+
+ Explore Treemap
+
+
+
+ )}
+
);
};