This commit is contained in:
legop3
2025-11-15 22:35:21 -05:00
parent 0caae506f4
commit 94a1ec1ce8
4 changed files with 9 additions and 5 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -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>
+5 -1
View File
@@ -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>
); );