Skip to content

Commit fb185d8

Browse files
committed
code complexity componeent
1 parent b4f7631 commit fb185d8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import { styles } from '../utils/styles';
3+
4+
interface Props {
5+
averageComplexity?: string;
6+
distribution?: Record<string, number>;
7+
totalFunctions?: number;
8+
}
9+
10+
export const ComplexityCard: React.FC<Props> = ({
11+
averageComplexity = 'N/A',
12+
distribution,
13+
totalFunctions,
14+
}) => {
15+
return (
16+
<div style={styles.metricCard} className="metric-card">
17+
<div style={styles.metricHeader}>
18+
<h3 style={styles.metricTitle}>Complexity</h3>
19+
<span style={styles.metricValue}>{averageComplexity}</span>
20+
</div>
21+
22+
<div style={styles.metricDetails}>
23+
{totalFunctions !== undefined && (
24+
<p style={styles.detailLine}>
25+
Functions analysed: {totalFunctions}
26+
</p>
27+
)}
28+
{distribution &&
29+
Object.entries(distribution).map(([bigO, qty]) => (
30+
<p key={bigO} style={styles.detailLine}>
31+
{bigO}: {qty}
32+
</p>
33+
))}
34+
</div>
35+
</div>
36+
);
37+
};

0 commit comments

Comments
 (0)