/* Open Rowing Monitor, https://github.com/laberning/openrowingmonitor Component that renders a battery indicator */ import { customElement, property } from 'lit/decorators.js' import { AppElement, css, svg } from './AppElement' @customElement('battery-icon') export class DashboardMetric extends AppElement { static get styles () { return css` .icon { height: 1.2em; } .low-battery { color: var(--theme-warning-color) } ` } @property({ type: Number }) batteryLevel = 0 render () { // 416 is the max width value of the battery bar in the SVG graphic const batteryWidth = this.batteryLevel * 416 / 100 // if battery level is low, highlight the battery icon const iconClass = this.batteryLevel > 25 ? 'icon' : 'icon low-battery' return svg` ` } }