diff --git a/src/renderer/components/+nodes/nodes.scss b/src/renderer/components/+nodes/nodes.scss index bace3aa726..c2d4aa2bc2 100644 --- a/src/renderer/components/+nodes/nodes.scss +++ b/src/renderer/components/+nodes/nodes.scss @@ -20,6 +20,10 @@ flex: 1.0; align-self: center; + .metrics { + --metric-color: var(--blue); + } + .LineProgress { color: var(--blue); } diff --git a/src/renderer/components/+nodes/route.tsx b/src/renderer/components/+nodes/route.tsx index 2fd494a3ae..02e9b5abfd 100644 --- a/src/renderer/components/+nodes/route.tsx +++ b/src/renderer/components/+nodes/route.tsx @@ -22,6 +22,7 @@ import { eventStore } from "../+events/event.store"; import { makeObservable, observable } from "mobx"; import isEmpty from "lodash/isEmpty"; import { KubeObjectAge } from "../kube-object/age"; +import { MetricBar } from "../metric-bar"; enum columnId { name = "name", @@ -96,7 +97,8 @@ export class NodesRoute extends React.Component { const [usage, capacity] = metrics; return ( - { +interface BarProps extends HTMLAttributes, TooltipDecoratorProps { value: number; max: number; min?: number; - tooltip?: ReactNode; showPercent?: ReactNode; changeColorOnWarning?: boolean; warningPercentage?: number; - metricName?: "cpu" | "memory" | "disk"; // Used for color setting - customColor?: string; } -export function MetricBar(props: BarProps) { - const elem = useRef(); - const { max, min, tooltip, showPercent, changeColorOnWarning = true, warningPercentage = 85, value, metricName, customColor } = props; +export const MetricBar = withTooltip((props: BarProps) => { + const { max, min = 0, showPercent = true, changeColorOnWarning = true, warningPercentage = 85, value } = props; const percents = Math.min(100, value / (max - min) * 100); - const [metricColor, setMetricColor] = useState("var(--colorVague)"); - const color = (percents > warningPercentage && changeColorOnWarning) ? "pink" : customColor || metricColor; - - useEffect(() => { - const cssVars = cssVar(elem.current); - - setMetricColor(cssVars.get(`--color-${metricName}`).toString()); - }); + const percentsRounded = +percents.toFixed(2); + const warning = percents > warningPercentage; return ( -
- - {showPercent && } +
+ + {showPercent && }
); -} +}); + diff --git a/src/renderer/components/vertical-bar/vertical-bar.module.scss b/src/renderer/components/vertical-bar/vertical-bar.module.scss index 039480a166..a4c93bd7bf 100644 --- a/src/renderer/components/vertical-bar/vertical-bar.module.scss +++ b/src/renderer/components/vertical-bar/vertical-bar.module.scss @@ -4,6 +4,8 @@ */ .verticalBar { + --line-color: gray; + display: flex; flex-direction: column; justify-content: flex-end; @@ -15,6 +17,6 @@ } .value { - background-color: gray; + background-color: var(--line-color); transition: all 0.2s ease-in-out; } \ No newline at end of file diff --git a/src/renderer/components/vertical-bar/vertical-bar.tsx b/src/renderer/components/vertical-bar/vertical-bar.tsx index ef9ebd78ee..443da97d17 100644 --- a/src/renderer/components/vertical-bar/vertical-bar.tsx +++ b/src/renderer/components/vertical-bar/vertical-bar.tsx @@ -9,14 +9,13 @@ import React, { HTMLAttributes } from "react"; import { cssNames } from "../../utils"; interface BarProps extends HTMLAttributes { - color: string; value: number; } -export function VerticalBar({ color, className, value }: BarProps) { +export function VerticalBar({ className, value, ...rest }: BarProps) { return ( -
-
+
+
); }