MCPcopy Create free account
hub / github.com/OpenPipe/OpenPipe / ColoredPercent

Function ColoredPercent

app/src/components/ColoredPercent.tsx:5–19  ·  view source on GitHub ↗
({ value, ...props }: { value?: number | null } & TextProps)

Source from the content-addressed store, hash-verified

3import { isNumber } from "lodash-es";
4
5const ColoredPercent = ({ value, ...props }: { value?: number | null } & TextProps) => {
6 const [passColor, neutralColor, failColor] = useToken("colors", [
7 "green.600",
8 "gray.600",
9 "red.600",
10 ]);
11
12 const scale = chroma.scale([failColor, neutralColor, passColor]).domain([0, 0.5, 1]);
13
14 return isNumber(value) ? (
15 <Text color={scale(value).hex()} fontWeight="bold" {...props}>
16 {(value * 100).toFixed(1)}%
17 </Text>
18 ) : null;
19};
20
21export default ColoredPercent;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected