Skip to content

Commit

Permalink
Use battery charging symbol when robot is charging
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Dec 17, 2024
1 parent f94d4d3 commit 0827cea
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { tokens } from '@equinor/eds-tokens'
import { Icon, Typography } from '@equinor/eds-core-react'
import styled from 'styled-components'
import { Icons } from 'utils/icons'
import { BatteryStatus } from 'models/Battery'

const BatteryAlignment = styled.div`
display: flex;
Expand All @@ -12,13 +13,15 @@ const StyledTypography = styled(Typography)<{ $fontSize?: 24 | 16 | 18 | 32 | 40
`
interface BatteryStatusDisplayProps {
batteryLevel?: number
batteryState?: BatteryStatus
itemSize?: 24 | 16 | 18 | 32 | 40 | 48 | undefined
batteryWarningLimit?: number
textAlignedBottom?: boolean
}

export const BatteryStatusDisplay = ({
batteryLevel,
batteryState,
itemSize,
batteryWarningLimit,
textAlignedBottom,
Expand All @@ -27,6 +30,8 @@ export const BatteryStatusDisplay = ({

const getBatteryIcon = (batteryLevel?: number) => {
switch (true) {
case batteryState === BatteryStatus.Charging:
return Icons.BatteryCharging
case batteryLevel === null || batteryLevel === undefined:
return Icons.BatteryUnknown
case !batteryWarningLimit || batteryLevel! > batteryWarningLimit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const RobotCard = ({ robot }: { robot: Robot }) => {
<AttributeTitleTypography>{TranslateText('Battery')}</AttributeTitleTypography>
<BatteryStatusDisplay
batteryLevel={robot.batteryLevel}
batteryState={robot.batteryState}
batteryWarningLimit={robot.model.batteryWarningThreshold}
/>
</VerticalContent>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Pages/RobotPage/RobotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const RobotPage = () => {
<BatteryStatusDisplay
itemSize={32}
batteryLevel={selectedRobot.batteryLevel}
batteryState={selectedRobot.batteryState}
batteryWarningLimit={selectedRobot.model.batteryWarningThreshold}
/>
{selectedRobot.pressureLevel !== null &&
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/models/Robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface Robot {
serialNumber?: string
currentInstallation: Installation
batteryLevel?: number
batteryStatus?: BatteryStatus
batteryState?: BatteryStatus
pressureLevel?: number
pose?: Pose
status: RobotStatus
Expand Down

0 comments on commit 0827cea

Please sign in to comment.