From 1050b0fbb3db9f758735892835ae38019922f01d Mon Sep 17 00:00:00 2001 From: Viet Ngoc Date: Mon, 10 Jun 2024 03:18:26 +0200 Subject: [PATCH] update map-card.js and vehicle-info-card.ts --- src/components/map-card.js | 3 --- src/vehicle-info-card.ts | 37 ++++++++++++------------------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/components/map-card.js b/src/components/map-card.js index 0b3e594..15ef835 100644 --- a/src/components/map-card.js +++ b/src/components/map-card.js @@ -89,9 +89,6 @@ export class VehicleMap extends LitElement { height: 100%; width: 100%; background: transparent !important; - /* mask-image: radial-gradient(circle at 70%, black 20%, transparent 90%), - linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%), - linear-gradient(to left, transparent 0%, black 30%); */ mask-image: linear-gradient(to right, transparent 0%, black 25%, black 90%, transparent 100%), linear-gradient(to bottom, transparent 20%, black 35%, black 90%, transparent 100%); mask-composite: intersect; diff --git a/src/vehicle-info-card.ts b/src/vehicle-info-card.ts index a084238..42386a2 100644 --- a/src/vehicle-info-card.ts +++ b/src/vehicle-info-card.ts @@ -91,20 +91,6 @@ export class VehicleCard extends LitElement { ...config, }; - // // Helper function to handle creating cards based on config property names - // const createConfigCards = (configProperty: keyof VehicleCardConfig, target: string) => { - // const cardConfig = this.config[configProperty]; - // if (cardConfig) { - // this.createCards(cardConfig, target); - // } - // }; - - // // Create cards for each specific config property - // createConfigCards('trip_card', 'tripCards'); - // createConfigCards('vehicle_card', 'vehicleCards'); - // createConfigCards('eco_card', 'ecoCards'); - // createConfigCards('tyre_card', 'tyreCards'); - for (const cardType of cardTypes) { if (this.config[cardType.config]) { this.createCards(this.config[cardType.config], cardType.type); @@ -260,20 +246,20 @@ export class VehicleCard extends LitElement {

${name}

- ${this.activeCardType ? this._renderAdditionalCard() : this._renderMainCard()} + ${this.activeCardType ? this._renderCustomCard() : this._renderMainCard()} `; } - private _renderHeaderBackground(): TemplateResult | void { - if (!this.config.show_background) return; + private _renderHeaderBackground(): TemplateResult { + if (!this.config.show_background) return html``; const isDark = this.isDark(); const background = isDark ? amgWhite : amgBlack; return html`
`; } - private _renderMainCard(): TemplateResult | void { + private _renderMainCard(): TemplateResult { return html`
${this._renderWarnings()} ${this._renderRangeInfo()}
@@ -362,19 +348,20 @@ export class VehicleCard extends LitElement { } private _renderMap(): TemplateResult | void { - if (!this.config.show_map) { + const { config, hass } = this; + if (!config.show_map) { return; } - if (!this.config.device_tracker && this.config.show_map) { + if (!config.device_tracker && config.show_map) { return this._showWarning('No device_tracker entity provided.'); } return html`
`; @@ -402,7 +389,7 @@ export class VehicleCard extends LitElement { `; } - private _renderAdditionalCard(): TemplateResult | LovelaceCard | void { + private _renderCustomCard(): TemplateResult | LovelaceCard | void { if (!this.activeCardType) return html``; const cardConfigMap = {