Compare commits

...

8 Commits

Author SHA1 Message Date
semantic-release-bot 2562b84360 chore(release): 4.1.2 [skip ci]
### [4.1.2](https://github.com/custom-cards/button-card/compare/v4.1.1...v4.1.2) (2024-02-01)

### Bug Fixes

* card would sometimes not be clickable ([56c3f44](56c3f44066)), closes [#738](https://github.com/custom-cards/button-card/issues/738) [#759](https://github.com/custom-cards/button-card/issues/759)
* support for new ha-state-icon in 2024.02 ([ab2b393](ab2b3939bc))
2024-02-01 11:21:38 +00:00
semantic-release-bot 605b096509 chore(release): 4.1.2-dev.2 [skip ci]
### [4.1.2-dev.2](https://github.com/custom-cards/button-card/compare/v4.1.2-dev.1...v4.1.2-dev.2) (2024-02-01)

### Bug Fixes

* support for new ha-state-icon in 2024.02 ([ab2b393](ab2b3939bc))
2024-02-01 10:20:22 +00:00
Jérôme Wiedemann ab2b3939bc fix: support for new ha-state-icon in 2024.02 2024-02-01 10:19:23 +00:00
semantic-release-bot 27877b9f68 chore(release): 4.1.2-dev.1 [skip ci]
### [4.1.2-dev.1](https://github.com/custom-cards/button-card/compare/v4.1.1...v4.1.2-dev.1) (2023-08-20)

### Bug Fixes

* card would sometimes not be clickable ([56c3f44](56c3f44066)), closes [#738](https://github.com/custom-cards/button-card/issues/738) [#759](https://github.com/custom-cards/button-card/issues/759)
2023-08-20 15:46:11 +00:00
Jérôme Wiedemann 56c3f44066 fix: card would sometimes not be clickable
Fix #738, Fix #759
2023-08-20 15:43:25 +00:00
semantic-release-bot 121ae82326 chore(release): 4.1.1 [skip ci]
### [4.1.1](https://github.com/custom-cards/button-card/compare/v4.1.0...v4.1.1) (2023-08-03)

### Bug Fixes

* **color:** color wouldn't follow light color with `color: auto` ([b63f0db](b63f0db220)), closes [#737](https://github.com/custom-cards/button-card/issues/737)
2023-08-03 13:28:22 +00:00
Jérôme Wiedemann b63f0db220 fix(color): color wouldn't follow light color with `color: auto`
Fixes #737
2023-08-03 13:26:32 +00:00
semantic-release-bot 0bf22d5c43 chore(release): 4.1.0 [skip ci]
## [4.1.0](https://github.com/custom-cards/button-card/compare/v4.0.1...v4.1.0) (2023-08-03)

### Features

* **templates:** Support for one time evaluation of js templates in `triggers_update` and `entity` ([#741](https://github.com/custom-cards/button-card/issues/741)) ([b372642](b372642253)), closes [#618](https://github.com/custom-cards/button-card/issues/618) [#558](https://github.com/custom-cards/button-card/issues/558) [#368](https://github.com/custom-cards/button-card/issues/368)

### Bug Fixes

* Keep default background color for color_type: card when off ([41dea3f](41dea3f72a)), closes [#737](https://github.com/custom-cards/button-card/issues/737)
* lock would not display on many browsers ([245441b](245441b69f)), closes [#740](https://github.com/custom-cards/button-card/issues/740)
* remove margin-top on name/label/state introduced with 4.0.0 which broke many cards ([53fee75](53fee75c16)), closes [#742](https://github.com/custom-cards/button-card/issues/742) [#744](https://github.com/custom-cards/button-card/issues/744)
2023-08-03 12:25:27 +00:00
3 changed files with 64 additions and 30 deletions

View File

@ -1,3 +1,46 @@
### [4.1.2](https://github.com/custom-cards/button-card/compare/v4.1.1...v4.1.2) (2024-02-01)
### Bug Fixes
* card would sometimes not be clickable ([56c3f44](https://github.com/custom-cards/button-card/commit/56c3f44066c6bd08fb8a7d8bb8fa679920dc5992)), closes [#738](https://github.com/custom-cards/button-card/issues/738) [#759](https://github.com/custom-cards/button-card/issues/759)
* support for new ha-state-icon in 2024.02 ([ab2b393](https://github.com/custom-cards/button-card/commit/ab2b3939bcce504125853d2ca9312d32f9a3f6d6))
### [4.1.2-dev.2](https://github.com/custom-cards/button-card/compare/v4.1.2-dev.1...v4.1.2-dev.2) (2024-02-01)
### Bug Fixes
* support for new ha-state-icon in 2024.02 ([ab2b393](https://github.com/custom-cards/button-card/commit/ab2b3939bcce504125853d2ca9312d32f9a3f6d6))
### [4.1.2-dev.1](https://github.com/custom-cards/button-card/compare/v4.1.1...v4.1.2-dev.1) (2023-08-20)
### Bug Fixes
* card would sometimes not be clickable ([56c3f44](https://github.com/custom-cards/button-card/commit/56c3f44066c6bd08fb8a7d8bb8fa679920dc5992)), closes [#738](https://github.com/custom-cards/button-card/issues/738) [#759](https://github.com/custom-cards/button-card/issues/759)
### [4.1.1](https://github.com/custom-cards/button-card/compare/v4.1.0...v4.1.1) (2023-08-03)
### Bug Fixes
* **color:** color wouldn't follow light color with `color: auto` ([b63f0db](https://github.com/custom-cards/button-card/commit/b63f0db220b8a9c72383c4288546112625fdff04)), closes [#737](https://github.com/custom-cards/button-card/issues/737)
## [4.1.0](https://github.com/custom-cards/button-card/compare/v4.0.1...v4.1.0) (2023-08-03)
### Features
* **templates:** Support for one time evaluation of js templates in `triggers_update` and `entity` ([#741](https://github.com/custom-cards/button-card/issues/741)) ([b372642](https://github.com/custom-cards/button-card/commit/b372642253c890b08c7de7395d138b01fb90120b)), closes [#618](https://github.com/custom-cards/button-card/issues/618) [#558](https://github.com/custom-cards/button-card/issues/558) [#368](https://github.com/custom-cards/button-card/issues/368)
### Bug Fixes
* Keep default background color for color_type: card when off ([41dea3f](https://github.com/custom-cards/button-card/commit/41dea3f72a607ea0fc1c71269bb0122f27970a6e)), closes [#737](https://github.com/custom-cards/button-card/issues/737)
* lock would not display on many browsers ([245441b](https://github.com/custom-cards/button-card/commit/245441b69fad5f56f43ea1b5d189b4ddbbab2ebb)), closes [#740](https://github.com/custom-cards/button-card/issues/740)
* remove margin-top on name/label/state introduced with 4.0.0 which broke many cards ([53fee75](https://github.com/custom-cards/button-card/commit/53fee75c163b72df42b859705af536c4c7dffac6)), closes [#742](https://github.com/custom-cards/button-card/issues/742) [#744](https://github.com/custom-cards/button-card/issues/744)
## [4.1.0-dev.3](https://github.com/custom-cards/button-card/compare/v4.1.0-dev.2...v4.1.0-dev.3) (2023-08-01)

View File

@ -1,6 +1,6 @@
{
"name": "button-card",
"version": "4.1.0-dev.3",
"version": "4.1.2",
"description": "Button card for lovelace",
"main": "dist/button-card.js",
"scripts": {

View File

@ -20,6 +20,7 @@ import {
ButtonCardEmbeddedCards,
ButtonCardEmbeddedCardsConfig,
ColorType,
CustomFields,
} from './types/types';
import { actionHandler } from './action-handler';
import {
@ -604,7 +605,7 @@ class ButtonCard extends LitElement {
colorValue = this._config!.color;
}
if (AUTO_COLORS.includes(colorValue)) {
if (!state || (state && !(computeDomain(state.entity_id) !== 'light'))) {
if (!state || (state && computeDomain(state.entity_id) !== 'light')) {
colorValue = '';
}
}
@ -868,38 +869,26 @@ class ButtonCard extends LitElement {
return result;
}
private _hasChildCards(customFields: CustomFields | undefined): boolean {
if (!customFields) return false;
return Object.keys(customFields).some((key) => {
const value = customFields![key];
if ((value as CustomFieldCard)!.card) {
return true;
}
return false;
});
}
private _isClickable(state: HassEntity | undefined, configState: StateConfig | undefined): boolean {
let clickable = true;
const tap_action = this._getTemplateOrValue(state, this._config!.tap_action!.action);
const hold_action = this._getTemplateOrValue(state, this._config!.hold_action!.action);
const double_tap_action = this._getTemplateOrValue(state, this._config!.double_tap_action!.action);
let hasChildCards = false;
if (this._config!.custom_fields) {
hasChildCards = Object.keys(this._config!.custom_fields).some((key) => {
const value = this._config!.custom_fields![key];
if ((value as CustomFieldCard)!.card) {
return true;
}
return false;
});
}
if (!hasChildCards && configState) {
if (configState.custom_fields) {
return (hasChildCards = Object.keys(configState.custom_fields).some((key) => {
const value = configState.custom_fields![key];
if ((value as CustomFieldCard)!.card) {
return true;
}
return false;
}));
}
}
if (tap_action != 'none' || hold_action != 'none' || double_tap_action != 'none' || hasChildCards) {
clickable = true;
} else {
clickable = false;
}
return clickable;
const hasChildCards =
this._hasChildCards(this._config!.custom_fields) ||
!!(configState && this._hasChildCards(configState.custom_fields));
return tap_action != 'none' || hold_action != 'none' || double_tap_action != 'none' || hasChildCards;
}
private _rotate(configState: StateConfig | undefined): boolean {
@ -1165,6 +1154,8 @@ class ButtonCard extends LitElement {
? html`
<ha-state-icon
.state=${state}
.stateObj=${state}
.hass=${this._hass}
?data-domain=${domain}
data-state=${ifDefined(state?.state)}
style=${styleMap(haIconStyle)}