Fix battery icon
This commit is contained in:
parent
1db94740ed
commit
8b02610d97
|
@ -151,18 +151,21 @@ function Right() : JSX.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
function BatteryIcon(): JSX.Element {
|
function BatteryIcon(): JSX.Element {
|
||||||
if (!battery.online) return <box />;
|
if (!battery) return <box />;
|
||||||
return <box> {
|
return <button className="battery-item" onClicked={() => execAsync(['gnome-power-manager'])}>
|
||||||
bind(battery, "percentage").as((percentage) => {
|
<box>
|
||||||
const thresholds = [...Array(11).keys()].map( i => i * 10);
|
{
|
||||||
const icon = thresholds.find(threshold => threshold >= percentage * 100)
|
bind(battery, "percentage").as((percentage) => {
|
||||||
const charging_name = battery.percentage >= 0.99 ? "charged" : "charging"
|
const thresholds = [...Array(11).keys()].map( i => i * 10);
|
||||||
return <box className="battery-item" tooltip_text={`Battery ${battery.percentage * 100}%`}>
|
const icon = thresholds.find(threshold => threshold >= percentage * 100)
|
||||||
<icon icon={battery.charging? `battery-level-${icon}-${charging_name}-symbolic` : `battery-level-${icon}-symbolic`} />
|
const charging_name = battery.percentage >= 0.99 ? "charged" : "charging"
|
||||||
</box>
|
return <icon
|
||||||
})
|
icon={battery.charging? `battery-level-${icon}-${charging_name}-symbolic` : `battery-level-${icon}-symbolic`}
|
||||||
}
|
/>
|
||||||
</box>
|
})
|
||||||
|
}
|
||||||
|
</box>
|
||||||
|
</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
function Icons() {
|
function Icons() {
|
||||||
|
|
Loading…
Reference in New Issue