Skip to content

Commit 6208979

Browse files
committed
TrackerBattery battery level tooltip if not shown
1 parent c9783d0 commit 6208979

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed

gui/src/components/tracker/TrackerBattery.tsx

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useConfig } from '@/hooks/config';
22
import { useLocaleConfig } from '@/i18n/config';
33
import { BatteryIcon } from '@/components/commons/icon/BatteryIcon';
44
import { Typography } from '@/components/commons/Typography';
5+
import { Tooltip } from '@/components/commons/Tooltip';
56

67
export function TrackerBattery({
78
value,
@@ -36,36 +37,49 @@ export function TrackerBattery({
3637
const showVoltage = moreInfo && voltage && debug;
3738

3839
return (
39-
<div className="flex gap-2">
40-
<div className="flex flex-col justify-around">
41-
<BatteryIcon value={value} disabled={disabled} charging={charging} />
42-
</div>
43-
{((!charging || showVoltage) && (
44-
<div className="w-15">
45-
{!charging && runtime != null && runtime > 0 && (
46-
<Typography color={textColor}>
47-
{(runtime / BigInt(3600000000)).toString() +
48-
'h ' +
49-
((runtime % BigInt(3600000000)) / BigInt(60000000)).toString() +
50-
'min'}
51-
</Typography>
52-
)}
53-
{!charging && (!runtime || debug) && (
54-
<Typography color={textColor}>
55-
{percentFormatter.format(value)}
56-
</Typography>
57-
)}
58-
{showVoltage && (
59-
<Typography color={textColor}>
60-
{voltageFormatter.format(voltage)}V
61-
</Typography>
62-
)}
40+
<Tooltip
41+
disabled={!charging && (!runtime || debug)}
42+
preferedDirection="left"
43+
content={
44+
<div className="flex gap-1 items-center">
45+
<Typography>{percentFormatter.format(value)}</Typography>
6346
</div>
64-
)) || (
65-
<div className="flex flex-col justify-center w-15">
66-
<div className="w-5 h-1 bg-background-30 rounded-full" />
47+
}
48+
>
49+
<div className="flex gap-2">
50+
<div className="flex flex-col justify-around">
51+
<BatteryIcon value={value} disabled={disabled} charging={charging} />
6752
</div>
68-
)}
69-
</div>
53+
{((!charging || showVoltage) && (
54+
<div className="w-15">
55+
{!charging && runtime != null && runtime > 0 && (
56+
<Typography color={textColor}>
57+
{(runtime / BigInt(3600000000)).toString() +
58+
'h ' +
59+
(
60+
(runtime % BigInt(3600000000)) /
61+
BigInt(60000000)
62+
).toString() +
63+
'min'}
64+
</Typography>
65+
)}
66+
{!charging && (!runtime || debug) && (
67+
<Typography color={textColor}>
68+
{percentFormatter.format(value)}
69+
</Typography>
70+
)}
71+
{showVoltage && (
72+
<Typography color={textColor}>
73+
{voltageFormatter.format(voltage)}V
74+
</Typography>
75+
)}
76+
</div>
77+
)) || (
78+
<div className="flex flex-col justify-center w-15">
79+
<div className="w-5 h-1 bg-background-30 rounded-full" />
80+
</div>
81+
)}
82+
</div>
83+
</Tooltip>
7084
);
7185
}

0 commit comments

Comments
 (0)