[dyad] Added status indicators to tabs - wrote 4 file(s)
This commit is contained in:
30
src/lib/analysis.ts
Normal file
30
src/lib/analysis.ts
Normal 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";
|
||||
}
|
||||
Reference in New Issue
Block a user