-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from Cycling74/fde/cpu_percentage
cpu meter with permanently shown CPU load in %
- Loading branch information
Showing
3 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.cpuRoot { | ||
border-radius: var(--mantine-radius-sm); | ||
background-color: var(--mantine-color-dark-3); | ||
overflow: hidden; | ||
position: relative; | ||
height: 20px; | ||
width: 40px; | ||
} | ||
|
||
.cpuBar { | ||
background-color: var(--mantine-primary-color-filled); | ||
border-bottom-left-radius: var(--mantine-radius-sm); | ||
border-top-left-radius: var(--mantine-radius-sm); | ||
height: 100%; | ||
left: 0; | ||
top: 0; | ||
position: absolute; | ||
width: 100%; | ||
z-index: 2; | ||
} | ||
|
||
.cpuLabel { | ||
color: var(--mantine-primary-color-contrast); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: var(--mantine-font-size-xs); | ||
font-weight: bold; | ||
left: 0; | ||
padding: 0 var(--mantine-spacing-xs); | ||
position: absolute; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { forwardRef, FunctionComponent, memo } from "react"; | ||
import classes from "./cpu.module.css"; | ||
|
||
export type CPUStatusProps = { | ||
load: number; | ||
}; | ||
|
||
export const CPUStatus: FunctionComponent<CPUStatusProps> = memo(forwardRef<HTMLDivElement, CPUStatusProps>( | ||
function WrappedCPUStatusComponent({ load }, ref) { | ||
return ( | ||
<div className={ classes.cpuRoot } ref={ ref } > | ||
<div className={ classes.cpuBar } style={{ width: `${load}%`}} /> | ||
<label className={ classes.cpuLabel } > | ||
{ `${Math.round(load)}%` } | ||
</label> | ||
</div> | ||
); | ||
} | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters