Skip to content

Commit 3ef2015

Browse files
authored
CSS fixes and shadow fix (#58)
Using class instead of id in css shadow_height now not visible if not configured. Could fix some of the problems in #34
1 parent 35ea56c commit 3ef2015

File tree

6 files changed

+78
-14
lines changed

6 files changed

+78
-14
lines changed

.devcontainer/HA/config/ui-lovelace.yaml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ views:
55
card_height: 220
66
entity: sensor.processor_use
77
# dropshadow: false
8+
# shadow_height: "20%"
9+
# name: Hello
810
gauge:
911
# colorValueBoxBackground: "#000"
1012
borderShadowWidth: 0
@@ -18,7 +20,7 @@ views:
1820
# data-width: 400
1921
# data-height: 400
2022
height: 400
21-
# width: 100%
23+
# width: 120
2224
highlights:
2325
- color: "rgba(200, 50, 50, .75)"
2426
from: 80
@@ -49,6 +51,61 @@ views:
4951
type: radial-gauge
5052
valueBox: false
5153

54+
style:
55+
left: 4.2%
56+
top: 9.6%
57+
transform: none
58+
59+
- type: "custom:canvas-gauge-card"
60+
card_height: 420
61+
entity: sensor.processor_use
62+
# dropshadow: false
63+
shadow_height: "20%"
64+
name: Hello
65+
gauge:
66+
# colorValueBoxBackground: "#000"
67+
borderShadowWidth: 0
68+
borderOuterWidth: 0
69+
borderMiddleWidth: 0
70+
borderInnerWidth: 0
71+
animationDuration: 1500
72+
animationRule: linear
73+
borders: false
74+
colorPlate: "#ddd"
75+
# data-width: 400
76+
# data-height: 400
77+
height: 600
78+
# width: 100%
79+
highlights:
80+
- color: "rgba(200, 220, 50, .75)"
81+
from: 80
82+
to: 100
83+
majorTicks:
84+
- "0"
85+
- "10"
86+
- "20"
87+
- "30"
88+
- "40"
89+
- "50"
90+
- "60"
91+
- "70"
92+
- "80"
93+
- "90"
94+
- "100"
95+
maxValue: 100
96+
minValue: 0
97+
minorTicks: 2
98+
needleCircleInner: false
99+
needleCircleOuter: true
100+
needleCircleSize: 7
101+
needleType: arrow
102+
needleWidth: 2
103+
startAngle: 90
104+
strokeTicks: true
105+
ticksAngle: 180
106+
type: radial-gauge
107+
valueBox: false
108+
52109
style:
53110
left: 4.2%
54111
top: 9.6%

RELEASENOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ Update to latest guage-card package to 2.1.7
2323
Fix animation issues
2424

2525
# 0.8.0
26+
2627
- Dropshadow is now optional
2728
- Removed dependency on custom-card-helpers
2829
- Added devconainer that let you run HA and debug card
30+
31+
# 0.9.0
32+
33+
- Using class instead of id in css
34+
- shadow_height now not visible if not configured.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.0
1+
0.9.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "canvas-gauge-card",
3-
"version": "0.8.0",
3+
"version": "0.9.0",
44
"description": "Lovelace canvas-gauge-card",
55
"keywords": [
66
"home-assistant",

src/canvas-gauge-card.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class CanvasGaugeCard extends LitElement {
132132
? config.card_height
133133
: config.gauge["height"];
134134

135-
this._shadowHeight = config.shadow_height ? config.shadow_height : "10%";
135+
this._shadowHeight = config.shadow_height ? config.shadow_height : "0%";
136136
this._useDropshadow = config.dropshadow ? config.dropshadow : false;
137137

138138
this._fontSize = config.font_size
@@ -204,7 +204,7 @@ export class CanvasGaugeCard extends LitElement {
204204
? this._config.background_color
205205
: "transparent"} !important;
206206
}
207-
#cardroot {
207+
.cardroot {
208208
width: ${this._gaugeWidth}px;
209209
height: calc(
210210
${this._gaugeHeight}px +
@@ -213,28 +213,29 @@ export class CanvasGaugeCard extends LitElement {
213213
position: relative;
214214
margin: auto;
215215
}
216-
#container {
216+
.container {
217217
width: ${this._gaugeWidth}px;
218218
height: ${this._gaugeHeight}px;
219219
position: relative;
220220
top: 0px;
221221
overflow: hidden;
222222
text-align: center;
223223
}
224-
#innercontainer {
224+
.innercontainer {
225225
position: relative;
226226
top: ${this._config.card_top ? this._config.card_top : 0};
227227
left: ${this._config.card_left ? this._config.card_left : 0};
228228
}
229229
.shadow {
230+
visible: ${this._shadowHeight == "0%" ? `none` : `block`};
230231
width: 100%;
231232
height: ${this._shadowHeight};
232233
left: 0px;
233234
bottom: 0px;
234235
background: rgba(0, 0, 0, 0.5);
235236
position: absolute;
236237
}
237-
#state {
238+
.state {
238239
position: relative;
239240
float: left;
240241
top: 50%;
@@ -244,23 +245,23 @@ export class CanvasGaugeCard extends LitElement {
244245
transform: translate(-50%, -50%);
245246
}
246247
</style>
247-
<div id="cardroot">
248+
<div class="cardroot">
248249
<div
249-
id="container"
250+
class="container"
250251
width=${this._gaugeWidth}
251252
height=${this._gaugeHeight}
252253
>
253254
<div
254-
id="innercontainer"
255+
class="innercontainer"
255256
width=${this._gaugeWidth}
256257
height=${this._gaugeHeight}
257258
@click=${this.clickHandler}
258259
>
259260
<canvas id="canvaselement"> </canvas>
260261
</div>
261262
</div>
262-
<div id="shadow">
263-
<div id="state" style="font-size: ${this._fontSize}">
263+
<div class="shadow">
264+
<div class="state" style="font-size: ${this._fontSize}">
264265
${this._config.name}
265266
</div>
266267
</div>

src/const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const CARD_VERSION = "0.8.0";
1+
export const CARD_VERSION = "0.9.0";

0 commit comments

Comments
 (0)