forked from equinor/flotilla
-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
102 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,46 @@ | ||
import {Battery, BatteryStatus} from 'models/battery' | ||
import { battery, battery_charging, battery_alert, battery_unknown } from '@equinor/eds-icons' | ||
import styles from './robotOverview.module.css' | ||
import { tokens } from '@equinor/eds-tokens' | ||
|
||
import { Icon, Typography } from '@equinor/eds-core-react' | ||
|
||
Icon.add( {battery, battery_charging, battery_unknown, battery_alert} ) | ||
|
||
export interface BatteryStatusViewProps { | ||
battery: Battery | ||
} | ||
|
||
const BatteryStatusView = ({ battery } : BatteryStatusViewProps) : JSX.Element => { | ||
let battery_icon | ||
let icon_color : string = tokens.colors.interactive.primary__resting.hex | ||
let battery_value : string = `${battery.value}%` | ||
|
||
|
||
|
||
if (!(battery.value)) | ||
battery_value = "---%" | ||
|
||
if (battery.status === BatteryStatus.Normal){ | ||
battery_icon = "battery" | ||
} | ||
else if (battery.status === BatteryStatus.Charging){ | ||
battery_icon = "battery_charging" | ||
} | ||
else if (battery.status === BatteryStatus.Critical){ | ||
battery_icon = "battery_alert" | ||
icon_color = tokens.colors.interactive.danger__resting.hex | ||
} | ||
else if (battery.status === BatteryStatus.Error){ | ||
battery_icon = "battery_unknown" | ||
} | ||
|
||
return ( | ||
<div className={styles.batteryStatus}> | ||
<Typography>{battery_value}</Typography> | ||
<Icon name={battery_icon} color={icon_color} size={24} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default BatteryStatusView |
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
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,15 @@ | ||
export enum BatteryStatus { | ||
Normal = 'Normal', | ||
Critical = 'Critical', | ||
Charging = 'Charging', | ||
Error = 'Error', | ||
} | ||
|
||
export class Battery { | ||
status: BatteryStatus = BatteryStatus.Normal | ||
value?: number | ||
constructor(status: BatteryStatus, value?: number) { | ||
this.status = status | ||
this.value = value | ||
} | ||
} |
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