Merge pull request #2 from liyunze-coding/update-colors-automatically-

update colours automatically
This commit is contained in:
RythonDev 2026-08-12 16:14:15 +10:00 committed by GitHub
commit 9917b295ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 52 additions and 0 deletions

View file

@ -95,6 +95,23 @@ class TaskList {
return this;
}
updateUserColor(sectionId, color) {
const section = this.#data.find((s) => s.id === sectionId);
if (!section) return this;
section.color = color;
document
.querySelectorAll(".section")
.forEach((el) => {
if (el.dataset.key !== sectionId) return;
const title = el.querySelector(":scope > .section-title");
if (!title) return;
title.style.setProperty("--user-color", color);
title.classList.add("has-user-color");
});
return this;
}
addTask(sectionId, task, sectionTitle) {
if (!this.#data.find((s) => s.id === sectionId)) {
this.addSection({

View file

@ -46,6 +46,7 @@ async function onChatMessage(data) {
localStorage.setItem(`${key}-color`, userColor);
userColors[`${key}-color`] = userColor;
taskList?.updateUserColor(key, userColor);
}
}

View file

@ -72,6 +72,23 @@ class TaskList {
return this;
}
updateUserColor(sectionId, color) {
const section = this.#data.find((s) => s.id === sectionId);
if (!section) return this;
section.color = color;
document
.querySelectorAll(".section")
.forEach((el) => {
if (el.dataset.key !== sectionId) return;
const title = el.querySelector(":scope > .section-title");
if (!title) return;
title.style.setProperty("--user-color", color);
title.classList.add("has-user-color");
});
return this;
}
addTask(sectionId, task, sectionTitle) {
if (!this.#data.find((s) => s.id === sectionId)) {
this.addSection({

View file

@ -95,6 +95,23 @@ class TaskList {
return this;
}
updateUserColor(sectionId, color) {
const section = this.#data.find((s) => s.id === sectionId);
if (!section) return this;
section.color = color;
document
.querySelectorAll(".section")
.forEach((el) => {
if (el.dataset.key !== sectionId) return;
const title = el.querySelector(":scope > .section-title");
if (!title) return;
title.style.setProperty("--user-color", color);
title.classList.add("has-user-color");
});
return this;
}
addTask(sectionId, task, sectionTitle) {
if (!this.#data.find((s) => s.id === sectionId)) {
this.addSection({