-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 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
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,48 @@ | ||
import React from 'react'; | ||
|
||
interface UptimeDisplayProps { | ||
uptime: number; | ||
} | ||
|
||
const UptimeDisplay: React.FC<UptimeDisplayProps> = ({ uptime }) => { | ||
// Function to get color based on uptime percentage | ||
const getColor = (): string => { | ||
if (uptime >= 99) return '#4caf50'; // Green for high uptime | ||
if (uptime >= 95) return '#ff9800'; // Orange for moderate uptime | ||
return '#f44336'; // Red for low uptime | ||
}; | ||
|
||
return ( | ||
<div style={styles.container}> | ||
<div | ||
style={{ | ||
...styles.progressBar, | ||
backgroundColor: getColor(), | ||
width: `${uptime}%`, | ||
}} | ||
/> | ||
<p>{Math.round(uptime)}%</p> | ||
</div> | ||
); | ||
}; | ||
|
||
// Styles object with type annotation | ||
const styles: { [key: string]: React.CSSProperties } = { | ||
container: { | ||
width: '100%', | ||
maxWidth: '400px', | ||
margin: '2px auto', | ||
textAlign: 'center', | ||
display: 'flex', | ||
flexDirection: 'row', | ||
gap: '6px', | ||
paddingRight: '8px' | ||
}, | ||
progressBar: { | ||
height: '20px', | ||
borderRadius: '5px', | ||
transition: 'width 0.5s ease', | ||
}, | ||
}; | ||
|
||
export default UptimeDisplay; |
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