251 files
This commit is contained in:
1 parent
3acf0cdf8d
commit
64eb0c647c
251 files changed
+6380
-14560
No files matched your search
@@ -36,6 +36,14 @@ class TaskMateLeaderboardCard extends LitElement {
|
||||
return fn ? fn(this.hass, key, params) : key;
|
||||
}
|
||||
|
||||
/** Avatar: child's photo → MDI avatar → default icon. */
|
||||
_avatarGlyph(source, fallback = "mdi:account-circle", cls = "tm-face-img") {
|
||||
const face = window.__taskmate_child_visual(source);
|
||||
return face.kind === "image"
|
||||
? html`<img class="${cls}" src="${face.url}" alt="" loading="lazy">`
|
||||
: html`<ha-icon icon="${face.kind === "icon" ? face.icon : fallback}"></ha-icon>`;
|
||||
}
|
||||
|
||||
static get styles() {
|
||||
const base = css`
|
||||
:host { display: block; }
|
||||
@@ -320,7 +328,7 @@ class TaskMateLeaderboardCard extends LitElement {
|
||||
if (entity.state === "unavailable" || entity.state === "unknown") return html`<ha-card><div class="error-state"><ha-icon icon="mdi:alert-circle"></ha-icon><div>${this._t('common.unavailable')}</div></div></ha-card>`;
|
||||
|
||||
const attrs = (window.__taskmate_attrs && window.__taskmate_attrs(this.hass, this.config.entity)) || entity.attributes || {};
|
||||
const children = [...(attrs.children || [])].filter(c => !c.is_guest);
|
||||
const children = [...(window.__taskmate_family_children ? window.__taskmate_family_children(attrs.children || [], this.config) : attrs.children || [])].filter(c => !c.is_guest);
|
||||
const pointsIcon = attrs.points_icon || "mdi:star";
|
||||
const pointsName = attrs.points_name || this._t('common.points');
|
||||
|
||||
@@ -424,7 +432,7 @@ class TaskMateLeaderboardCard extends LitElement {
|
||||
: html`<div class="rank-number">${this._t('leaderboard.ordinal_' + rankNum)}</div>`}
|
||||
|
||||
<div class="child-avatar" style="background: linear-gradient(135deg, ${avatarColour} 0%, ${avatarColour}cc 100%);">
|
||||
<ha-icon icon="${child.avatar || 'mdi:account-circle'}"></ha-icon>
|
||||
${this._avatarGlyph(child)}
|
||||
</div>
|
||||
|
||||
<div class="rank-info">
|
||||
@@ -483,7 +491,7 @@ class TaskMateLeaderboardCard extends LitElement {
|
||||
<div class="rank-row first">
|
||||
<div class="rank-badge">🥇</div>
|
||||
<div class="child-avatar" style="background: linear-gradient(135deg, #f1c40f 0%, #e67e22 100%);">
|
||||
<ha-icon icon="${child.avatar || 'mdi:account-circle'}"></ha-icon>
|
||||
${this._avatarGlyph(child)}
|
||||
</div>
|
||||
<div class="rank-info">
|
||||
<div class="rank-name">${child.name}</div>
|
||||
@@ -566,11 +574,11 @@ class TaskMateLeaderboardCard extends LitElement {
|
||||
_designTone(i) { return `var(--tmd-c${(i % 6) + 1})`; }
|
||||
|
||||
_av(child, tone, size) {
|
||||
const a = child.avatar || "";
|
||||
const inner = a.startsWith("mdi:")
|
||||
? html`<ha-icon icon="${a}"></ha-icon>`
|
||||
: a
|
||||
? html`<img src="${a}" alt="${child.name}">`
|
||||
const face = window.__taskmate_child_visual(child);
|
||||
const inner = face.kind === "icon"
|
||||
? html`<ha-icon icon="${face.icon}"></ha-icon>`
|
||||
: face.kind === "image"
|
||||
? html`<img src="${face.url}" alt="${child.name}">`
|
||||
: (child.name || "?").split(" ").map(w => w[0]).slice(0, 2).join("").toUpperCase();
|
||||
return html`<div class="av" style="--av:${size}px;--ac:${tone}">${inner}</div>`;
|
||||
}
|
||||
@@ -593,7 +601,7 @@ class TaskMateLeaderboardCard extends LitElement {
|
||||
}
|
||||
|
||||
const attrs = (window.__taskmate_attrs && window.__taskmate_attrs(this.hass, this.config.entity)) || entity.attributes || {};
|
||||
const children = [...(attrs.children || [])].filter(c => !c.is_guest);
|
||||
const children = [...(window.__taskmate_family_children ? window.__taskmate_family_children(attrs.children || [], this.config) : attrs.children || [])].filter(c => !c.is_guest);
|
||||
const pointsName = attrs.points_name || this._t('common.points');
|
||||
const pointsIcon = attrs.points_icon || "mdi:star";
|
||||
|
||||
@@ -833,6 +841,7 @@ class TaskMateLeaderboardCardEditor extends LitElement {
|
||||
|
||||
_computeLabel = (entry) => {
|
||||
const labels = {
|
||||
show_adults: this._t('common.editor.show_adults'),
|
||||
entity: this._t('leaderboard.editor.entity_label'),
|
||||
title: this._t('leaderboard.editor.title_label'),
|
||||
sort_by: this._t('leaderboard.editor.rank_by_label'),
|
||||
@@ -846,6 +855,7 @@ class TaskMateLeaderboardCardEditor extends LitElement {
|
||||
|
||||
_computeHelper = (entry) => {
|
||||
const helpers = {
|
||||
show_adults: this._t('common.editor.show_adults_helper'),
|
||||
entity: this._t('leaderboard.editor.entity_helper'),
|
||||
sort_by: this._t('leaderboard.editor.rank_by_helper'),
|
||||
};
|
||||
@@ -866,8 +876,8 @@ class TaskMateLeaderboardCardEditor extends LitElement {
|
||||
return html`
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${data}
|
||||
.schema=${this._buildSchema()}
|
||||
.data=${this.config.show_adults === true ? { ...data, show_adults: true } : data}
|
||||
.schema=${this._buildSchema().concat(window.__taskmate_adults_field ? window.__taskmate_adults_field(this.hass, this.config) : [])}
|
||||
.computeLabel=${this._computeLabel}
|
||||
.computeHelper=${this._computeHelper}
|
||||
@value-changed=${this._formChanged}
|
||||
|
||||
Reference in new issue
Block a user