251 files

This commit is contained in:
Home Assistant Version Control
2026-10-16 12:38:25 +00:00
parent 3acf0cdf8d
commit 64eb0c647c
251 changed files with 6380 additions and 14560 deletions
@@ -38,6 +38,14 @@ class TaskMateStreakCard 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 {
@@ -302,7 +310,7 @@ class TaskMateStreakCard extends LitElement {
}
const attrs = (window.__taskmate_attrs && window.__taskmate_attrs(this.hass, this.config.entity)) || entity.attributes || {};
let children = attrs.children || [];
let children = (window.__taskmate_family_children ? window.__taskmate_family_children(attrs.children || [], this.config) : attrs.children || []);
// Use recent_completions (all-time history, last 50) for streak/achievement calculation
const completions = [...(attrs.recent_completions || attrs.todays_completions || [])];
const pointsIcon = attrs.points_icon || "mdi:star";
@@ -342,16 +350,13 @@ class TaskMateStreakCard extends LitElement {
const dayDots = this._buildDayDots(childCompletions, chores, child.id, daysShown);
const achievements = this._getAchievements(child, childCompletions, streak, entity_ref);
// Avatar now included directly in children array from the overview sensor
const avatar = child.avatar || "mdi:account-circle";
const streakClass = streak >= 7 ? "hot" : streak >= 3 ? "warm" : "cold";
const streakEmoji = streak >= 14 ? "🔥🔥" : streak >= 7 ? "🔥" : streak >= 3 ? "⚡" : streak >= 1 ? "✨" : "💤";
return html`
<div class="streak-tile">
<div class="streak-header">
<div class="child-avatar"><ha-icon icon="${avatar}"></ha-icon></div>
<div class="child-avatar">${this._avatarGlyph(child)}</div>
<div class="streak-info">
<div class="child-name">${child.name}</div>
<div class="streak-count-row">
@@ -493,11 +498,11 @@ class TaskMateStreakCard 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>`;
}
@@ -550,7 +555,7 @@ class TaskMateStreakCard extends LitElement {
}
const attrs = (window.__taskmate_attrs && window.__taskmate_attrs(this.hass, this.config.entity)) || entity.attributes || {};
let children = attrs.children || [];
let children = (window.__taskmate_family_children ? window.__taskmate_family_children(attrs.children || [], this.config) : attrs.children || []);
const completions = [...(attrs.recent_completions || attrs.todays_completions || [])];
const chores = attrs.chores || [];
@@ -732,6 +737,7 @@ class TaskMateStreakCardEditor extends LitElement {
_computeLabel = (entry) => {
const labels = {
show_adults: this._t('common.editor.show_adults'),
entity: this._t('common.editor.overview_entity'),
title: this._t('streak.editor.title'),
child_id: this._t('common.editor.filter_by_child'),
@@ -743,6 +749,7 @@ class TaskMateStreakCardEditor extends LitElement {
_computeHelper = (entry) => {
const helpers = {
show_adults: this._t('common.editor.show_adults_helper'),
entity: this._t('common.editor.overview_entity_helper'),
child_id: this._t('streak.editor.child_helper'),
streak_days_shown: this._t('streak.editor.days_shown_helper'),
@@ -762,8 +769,8 @@ class TaskMateStreakCardEditor 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}