From 6fdd1444de4adebafc14b6cbca19822e61f30cef Mon Sep 17 00:00:00 2001 From: Christiaan de Die le Clercq Date: Sun, 5 Sep 2021 17:38:47 +0200 Subject: [PATCH 1/2] Make it possible to change font size on text labels Pull request for: #45 --- dual-gauge-card.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dual-gauge-card.js b/dual-gauge-card.js index d64ddb3..74da0f8 100644 --- a/dual-gauge-card.js +++ b/dual-gauge-card.js @@ -24,6 +24,16 @@ class DualGaugeCard extends HTMLElement { if (!this.config.max) { this.config.max = 100; } + + if (!this.config.fontsize) { + this.config.fontsize = 20; + } + if (!this.config.outer.fontsize) { + this.config.outer.fontsize = this.config.fontsize; + } + if (!this.config.inner.fontsize) { + this.config.inner.fontsize = this.config.fontsize; + } if (!this.config.inner.min) { this.config.inner.min = this.config.min; @@ -234,6 +244,13 @@ class DualGaugeCard extends HTMLElement { if (this.config.background_color) { this._setCssVariable(this.nodes.content, 'gauge-background-color', this.config.background_color); } + + if (this.config.outer.fontsize) { + this._setCssVariable(this.nodes.content, 'outer-font-size', this.config.outer.fontsize + 'px'); + } + if (this.config.inner.fontsize) { + this._setCssVariable(this.nodes.content, 'inner-font-size', this.config.inner.fontsize + 'px'); + } this._initStyles(); } @@ -258,6 +275,9 @@ class DualGaugeCard extends HTMLElement { --value-font-size: calc(var(--gauge-card-width) / 17); --title-font-size: calc(var(--gauge-card-width) / 14); --label-font-size: calc(var(--gauge-card-width) / 20); + + --outer-font-size: var(--outer-font-size); + --inner-font-size: var(--inner-font-size); width: var(--gauge-card-width); padding: 16px; @@ -350,11 +370,13 @@ class DualGaugeCard extends HTMLElement { .gauge-value-inner, .gauge-label-inner { right: 0; color: var(--inner-color); + font-size: var(--inner-font-size); } .outer-gauge { transform: rotate(var(--outer-angle)); + font-size: var(--outer-font-size); } .outer-gauge .circle { From b5fe90484382a49d51186fb30b8f1582a2f556bb Mon Sep 17 00:00:00 2001 From: Christiaan de Die le Clercq Date: Sun, 5 Sep 2021 17:48:57 +0200 Subject: [PATCH 2/2] Small fix for font on outer --- dual-gauge-card.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dual-gauge-card.js b/dual-gauge-card.js index 74da0f8..7347666 100644 --- a/dual-gauge-card.js +++ b/dual-gauge-card.js @@ -364,6 +364,7 @@ class DualGaugeCard extends HTMLElement { .gauge-value-outer, .gauge-label-outer { color: var(--outer-color); + font-size: var(--outer-font-size); } @@ -376,7 +377,6 @@ class DualGaugeCard extends HTMLElement { .outer-gauge { transform: rotate(var(--outer-angle)); - font-size: var(--outer-font-size); } .outer-gauge .circle {