Skip to content

Commit 3dbfe3e

Browse files
authored
Update fast-search-card.js
1 parent d9453f5 commit 3dbfe3e

File tree

1 file changed

+54
-17
lines changed

1 file changed

+54
-17
lines changed

dist/fast-search-card.js

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4515,6 +4515,45 @@ class FastSearchCard extends HTMLElement {
45154515
.star-button.starred:hover {
45164516
background: rgba(255, 215, 0, 0.15);
45174517
}
4518+
4519+
4520+
.favorite-button {
4521+
width: 39px;
4522+
height: 39px;
4523+
border: none;
4524+
background: rgba(255, 255, 255, 0.1);
4525+
border-radius: 50%;
4526+
cursor: pointer;
4527+
display: flex;
4528+
align-items: center;
4529+
justify-content: center;
4530+
transition: all 0.2s ease;
4531+
flex-shrink: 0;
4532+
color: var(--text-secondary);
4533+
padding: 0;
4534+
position: absolute;
4535+
right: 0;
4536+
}
4537+
4538+
.favorite-button:hover {
4539+
background: rgba(255, 255, 255, 0.2);
4540+
transform: scale(1.1);
4541+
}
4542+
4543+
.favorite-button.active {
4544+
color: #ff4757;
4545+
background: rgba(255, 71, 87, 0.2);
4546+
}
4547+
4548+
.favorite-button.active svg {
4549+
fill: #ff4757;
4550+
}
4551+
4552+
.favorite-button svg {
4553+
width: 24px;
4554+
height: 24px;
4555+
transition: all 0.2s ease;
4556+
}
45184557

45194558
</style>
45204559

@@ -7994,10 +8033,10 @@ class FastSearchCard extends HTMLElement {
79948033

79958034
this.setupDetailTabs(item);
79968035

7997-
// NEU: Star Button Event Listener
7998-
const starButton = this.shadowRoot.querySelector('.star-button');
7999-
if (starButton) {
8000-
starButton.addEventListener('click', (e) => {
8036+
// NEU: Favorite Button Event Listener
8037+
const favoriteButton = this.shadowRoot.querySelector('.favorite-button');
8038+
if (favoriteButton) {
8039+
favoriteButton.addEventListener('click', (e) => {
80018040
const entityId = e.currentTarget.dataset.entityId;
80028041
this.toggleStarLabel(entityId);
80038042
});
@@ -8254,9 +8293,9 @@ class FastSearchCard extends HTMLElement {
82548293
<h3 class="detail-name">${item.name}</h3>
82558294
<p class="detail-area">${item.area}</p>
82568295
</div>
8257-
<button class="star-button" data-entity-id="${item.id}">
8258-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
8259-
<path d="M8.58737 8.23597L11.1849 3.00376C11.5183 2.33208 12.4817 2.33208 12.8151 3.00376L15.4126 8.23597L21.2215 9.08017C21.9668 9.18848 22.2638 10.0994 21.7243 10.6219L17.5217 14.6918L18.5135 20.4414C18.6409 21.1798 17.8614 21.7428 17.1945 21.3941L12 18.678L6.80547 21.3941C6.1386 21.7428 5.35909 21.1798 5.48645 20.4414L6.47825 14.6918L2.27575 10.6219C1.73617 10.0994 2.03322 9.18848 2.77852 9.08017L8.58737 8.23597Z"/>
8296+
<button class="favorite-button" data-entity-id="${item.id}">
8297+
<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linejoin="round">
8298+
<path d="M22 8.86222C22 10.4087 21.4062 11.8941 20.3458 12.9929C17.9049 15.523 15.5374 18.1613 13.0053 20.5997C12.4249 21.1505 11.5042 21.1304 10.9488 20.5547L3.65376 12.9929C1.44875 10.7072 1.44875 7.01723 3.65376 4.73157C5.88044 2.42345 9.50794 2.42345 11.7346 4.73157L11.9998 5.00642L12.2648 4.73173C13.3324 3.6245 14.7864 3 16.3053 3C17.8242 3 19.2781 3.62444 20.3458 4.73157C21.4063 5.83045 22 7.31577 22 8.86222Z"/>
82608299
</svg>
82618300
</button>
82628301
</div>
@@ -11275,8 +11314,8 @@ class FastSearchCard extends HTMLElement {
1127511314
}
1127611315

1127711316
updateStarButtonState(entityId) {
11278-
const starButton = this.shadowRoot.querySelector('.star-button');
11279-
if (!starButton) return;
11317+
const favoriteButton = this.shadowRoot.querySelector('.favorite-button');
11318+
if (!favoriteButton) return;
1128011319

1128111320
try {
1128211321
const userId = this._hass.user?.id || 'unknown_user';
@@ -11295,19 +11334,17 @@ class FastSearchCard extends HTMLElement {
1129511334
const userStars = allUserStars[userId] || [];
1129611335
const isStarred = userStars.includes(entityId);
1129711336

11298-
// SVG Fill ändern
11299-
const svg = starButton.querySelector('svg');
11337+
// CSS-Klasse und SVG fill ändern
11338+
favoriteButton.classList.toggle('active', isStarred);
11339+
const svg = favoriteButton.querySelector('svg');
1130011340
if (svg) {
11301-
svg.setAttribute('fill', isStarred ? 'currentColor' : 'none');
11341+
svg.setAttribute('fill', isStarred ? '#ff4757' : 'none');
1130211342
}
1130311343

11304-
// CSS-Klasse für visuellen Zustand
11305-
starButton.classList.toggle('starred', isStarred);
11306-
11307-
starButton.title = isStarred ? 'Favorit entfernen' : 'Als Favorit markieren';
11344+
favoriteButton.title = isStarred ? 'Favorit entfernen' : 'Als Favorit markieren';
1130811345

1130911346
} catch (error) {
11310-
console.error('❌ Fehler beim Aktualisieren des Star-Button:', error);
11347+
console.error('❌ Fehler beim Aktualisieren des Favorite-Button:', error);
1131111348
}
1131211349
}
1131311350

0 commit comments

Comments
 (0)