From 5ddd0782d838fdb400a3944172d215f1defa0b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Tue, 31 Aug 2021 18:44:15 +0200 Subject: [PATCH] Add: Display card title if set --- dist/plex-meets-homeassistant.js | 17 +++++++++++++++++ src/plex-meets-homeassistant.ts | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index e0dea04..764e839 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -21338,6 +21338,23 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.card.style.overflow = 'hidden'; this.card.style.padding = '16px'; this.card.style.paddingRight = '6px'; + const titleContainer = document.createElement('h1'); + titleContainer.classList.add('card-header'); + titleContainer.style.paddingRight = '0px'; + titleContainer.style.paddingLeft = '0px'; + titleContainer.style.paddingTop = '0px'; + titleContainer.style.paddingBottom = '0px'; + const titleElem = document.createElement('div'); + titleElem.classList.add('name'); + titleElem.textContent = this.config.title; + titleContainer.appendChild(titleElem); + if (!lodash.isNil(this.config.title) && !lodash.isEmpty(this.config.title)) { + titleContainer.style.display = 'block'; + } + else { + titleContainer.style.display = 'none'; + } + this.card.appendChild(titleContainer); this.card.appendChild(this.searchInput()); if (this.showSearch) { this.searchInputElem.style.display = 'block'; diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index ec0d8ba..0cd8700 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -604,6 +604,27 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.card.style.padding = '16px'; this.card.style.paddingRight = '6px'; + const titleContainer = document.createElement('h1'); + titleContainer.classList.add('card-header'); + titleContainer.style.paddingRight = '0px'; + titleContainer.style.paddingLeft = '0px'; + titleContainer.style.paddingTop = '0px'; + titleContainer.style.paddingBottom = '0px'; + + const titleElem = document.createElement('div'); + titleElem.classList.add('name'); + titleElem.textContent = this.config.title; + + titleContainer.appendChild(titleElem); + + if (!_.isNil(this.config.title) && !_.isEmpty(this.config.title)) { + titleContainer.style.display = 'block'; + } else { + titleContainer.style.display = 'none'; + } + + this.card.appendChild(titleContainer); + this.card.appendChild(this.searchInput()); if (this.showSearch) { this.searchInputElem.style.display = 'block';