[dyad] Added status indicators to tabs - wrote 4 file(s)

This commit is contained in:
[dyad]
2026-01-20 14:37:17 +01:00
parent 41f8c0e5a1
commit e40c494e0a
4 changed files with 147 additions and 12 deletions

30
src/lib/analysis.ts Normal file
View File

@@ -0,0 +1,30 @@
export type IndicatorColor = "green" | "yellow" | "red" | "gray";
const TITLE_THRESHOLDS = {
good: { min: 30, max: 60 },
ok: { min: 15, max: 70 },
};
const DESCRIPTION_THRESHOLDS = {
good: { min: 120, max: 158 },
ok: { min: 50, max: 170 },
};
export function getLengthIndicatorColor(
length: number,
type: "title" | "description"
): IndicatorColor {
const thresholds =
type === "title" ? TITLE_THRESHOLDS : DESCRIPTION_THRESHOLDS;
if (length === 0) {
return "gray";
}
if (length >= thresholds.good.min && length <= thresholds.good.max) {
return "green";
}
if (length >= thresholds.ok.min && length <= thresholds.ok.max) {
return "yellow";
}
return "red";
}