-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support setting the heading color as part of the config, fallback wil…
…l be automatic color discovery
- Loading branch information
1 parent
14b140e
commit 5866f29
Showing
2 changed files
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ class BannerCard extends LitElement { | |
static get properties() { | ||
return { | ||
config: Object, | ||
oclor: String, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nervetattoo
Author
Owner
|
||
gridSizes: Array, | ||
entities: Array, | ||
entityValues: Array, | ||
|
@@ -46,6 +47,14 @@ class BannerCard extends LitElement { | |
this.entities = (config.entities || []).map(parseEntity); | ||
this.config = config; | ||
|
||
this.color = | ||
config.color || | ||
readableColor( | ||
config.background, | ||
"var(--bc-heading-color-light)", | ||
"var(--bc-heading-color-dark)" | ||
); | ||
|
||
if (typeof config.row_size !== "undefined") { | ||
if (config.row_size < 1) { | ||
throw new Error("row_size must be at least 1"); | ||
|
@@ -140,15 +149,9 @@ class BannerCard extends LitElement { | |
return null; | ||
} | ||
|
||
const color = readableColor( | ||
this.config.background, | ||
"var(--bc-heading-color-light)", | ||
"var(--bc-heading-color-dark)" | ||
); | ||
|
||
const onClick = () => this.config.link && this.navigate(this.config.link); | ||
return html` | ||
<h2 class="heading" style="color: ${color};" @click=${onClick}> | ||
<h2 class="heading" @click=${onClick} style="color: ${this.color};"> | ||
${this.config.heading} | ||
</h2> | ||
`; | ||
|
A little typo I guess, should be 'color'