mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
battery
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,8 +5,8 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>webui</title>
|
<title>webui</title>
|
||||||
<script type="module" crossorigin src="/assets/index-yT6hjp7B.js"></script>
|
<script type="module" crossorigin src="/assets/index-BGWfgpXK.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-CrWVatgk.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-BLqBO1Eu.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ function BatteryBar({ charge, capacity, config, label, status }) {
|
|||||||
const normalized = (charge - config.warn) / span;
|
const normalized = (charge - config.warn) / span;
|
||||||
const percent = Math.min(1, Math.max(0, normalized));
|
const percent = Math.min(1, Math.max(0, normalized));
|
||||||
const percentDisplay = Math.round(percent * 100);
|
const percentDisplay = Math.round(percent * 100);
|
||||||
|
const percentText = `${percentDisplay}%`;
|
||||||
const depleted = normalized <= 0;
|
const depleted = normalized <= 0;
|
||||||
const urgent = config.urgent != null && charge <= config.urgent;
|
const urgent = config.urgent != null && charge <= config.urgent;
|
||||||
const barClass = depleted ? 'bg-red-500 animate-pulse' : urgent ? 'bg-amber-400' : 'bg-emerald-500';
|
const barClass = depleted ? 'bg-red-500 animate-pulse' : urgent ? 'bg-amber-400' : 'bg-emerald-500';
|
||||||
@@ -173,8 +174,11 @@ function BatteryBar({ charge, capacity, config, label, status }) {
|
|||||||
<span>Battery</span>
|
<span>Battery</span>
|
||||||
<span>{capText} mAh</span>
|
<span>{capText} mAh</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="h-4 w-full rounded-full bg-slate-800">
|
<div className="relative h-4 w-full rounded-full bg-slate-800">
|
||||||
<div className={`h-full rounded-full transition-[width] ${barClass}`} style={{ width: `${percentDisplay}%` }} />
|
<div className={`h-full rounded-full transition-[width] ${barClass}`} style={{ width: `${percentDisplay}%` }} />
|
||||||
|
<span className="absolute inset-0 flex items-center justify-center text-xs font-semibold text-black/80">
|
||||||
|
{percentText}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user