mirror of
https://github.com/liyunze-coding/rython-task-bot-v2.git
synced 2026-09-22 07:24:27 +00:00
Merge pull request #2 from liyunze-coding/update-colors-automatically-
update colours automatically
This commit is contained in:
commit
9917b295ff
4 changed files with 52 additions and 0 deletions
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ async function onChatMessage(data) {
|
|||
|
||||
localStorage.setItem(`${key}-color`, userColor);
|
||||
userColors[`${key}-color`] = userColor;
|
||||
taskList?.updateUserColor(key, userColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in a new issue