'use strict' /* Open Rowing Monitor, https://github.com/laberning/openrowingmonitor Component that renders a battery indicator */ import { AppElement, svg, css } from './AppElement.js' import { customElement, property } from 'lit/decorators.js' @customElement('battery-icon') export class DashboardMetric extends AppElement { static styles = css` .icon { height: 1.2em; } .low-battery { color: var(--theme-warning-color) } ` @property({ type: String }) batteryLevel = '' 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` ` } }