Battery indicators (#1714)

This commit is contained in:
sctanf authored and GitHub committed 2026-01-23 03:13:36 +04:00
1 parent e25d3201c2
commit e0838cce6c
1 file changed
+17 -8
@@ -11,6 +11,9 @@ export function BatteryIcon({
charging: boolean;
}) {
const col = useMemo(() => {
if (disabled) return 'fill-background-40';
else if (charging) return 'fill-status-success';
const colorsMap: { [key: number]: string } = {
0.4: 'fill-status-success',
0.2: 'fill-status-warning',
@@ -20,10 +23,8 @@ export function BatteryIcon({
const val = Object.keys(colorsMap)
.filter((key) => +key < value)
.sort((a, b) => +b - +a)[0];
return disabled
? 'fill-background-40'
: colorsMap[+val] || 'fill-background-10';
}, [value, disabled]);
return colorsMap[+val] || 'fill-background-10';
}, [value, disabled, charging]);
return (
<svg
@@ -59,13 +60,21 @@ export function BatteryIcon({
/>
</mask>
<g mask="url(#mask0_4_39)" className={classNames(col, 'opacity-100')}>
<rect width={value * 18} height="9" />
<rect width={charging ? 18 : value * 18} height="9" />
</g>
{charging && (
{charging && value <= 1 && (
<path
d="M 0.93561138,11.744353 2.4349252,6.1488377 H 0.0312815 L 3.5761014,0.00903018 2.2061799,5.1216451 h 2.4534885 z"
d="M 7.7638355,8.4189633 8.0112251,4.9834646 5.7712838,4.9834645 8.5644084,0.07977871 8.3170195,3.5152773 H 10.55696 Z"
fill="#081e30"
transform="translate(5,-1)"
/>
)}
{charging && value > 1 && (
<path
d="M 5.5342464,4.6225095 C 6.1777799,5.0106205 6.6131537,5.2516456 7.5253371,6.545223 8.4340868,4.4016445 8.7809738,3.661475 10.605195,1.5520288"
fill="none"
stroke="#081e30"
strokeWidth={1.5}
strokeLinecap="square"
/>
)}
</svg>