mirror of
https://github.com/stfrigerio/sqliteDB.git
synced 2026-07-22 05:38:02 +00:00
fixed emoji
This commit is contained in:
parent
944afbd61b
commit
6ced6f6cca
2 changed files with 25 additions and 18 deletions
|
|
@ -75,20 +75,29 @@ export class HabitCounter extends HTMLElement {
|
|||
this.initialDate = this.getAttribute("date") ?? "@date";
|
||||
this.emoji = this.getAttribute("emoji") ?? "❓";
|
||||
this.table = this.getAttribute("table") ?? "";
|
||||
|
||||
// --- Defer UI update and load trigger slightly ---
|
||||
requestAnimationFrame(() => {
|
||||
//& console.log(`[HabitCounter Component ${this.habitKey}] Deferred execution starting.`);
|
||||
//? Now access uiElements, which should be reliably assigned.
|
||||
console.log(`[HabitCounter Component ${this.habitKey}] DEBUG: Inspecting this.uiElements within deferred call:`, this.uiElements);
|
||||
|
||||
updateStaticUI(this.uiElements, this.emoji, this.habitKey); //~ Update static parts of UI
|
||||
updateStaticUI(this.uiElements, this.emoji, this.habitKey); //~ Update static parts of UI
|
||||
|
||||
if (!this.table) {
|
||||
console.warn(`[HabitCounter Component ${this.habitKey}] Table attribute missing.`);
|
||||
this.showErrorState("No table");
|
||||
return;
|
||||
}
|
||||
if (!this.table) {
|
||||
console.warn(`[HabitCounter Component ${this.habitKey}] Table attribute missing.`);
|
||||
this.showErrorState("No table");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._initialLoadTriggered) {
|
||||
this._initialLoadTriggered = true;
|
||||
//& console.log(`[HabitCounter Component ${this.habitKey}] Triggering initial loadHabitData...`);
|
||||
loadHabitData(this).catch(err => console.error("Unhandled error during initial load:", err)); //~ Load data via helper
|
||||
}
|
||||
if (!this._initialLoadTriggered) {
|
||||
this._initialLoadTriggered = true;
|
||||
//& console.log(`[HabitCounter Component ${this.habitKey}] Triggering initial loadHabitData...`);
|
||||
loadHabitData(this).catch(err => console.error("Unhandled error during initial load:", err)); //~ Load data via helper
|
||||
} else {
|
||||
console.log(`[HabitCounter Component ${this.habitKey}] Initial load already triggered.`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//? Public method called by click handlers via instance reference
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// src/webcomponents/habitCounter/dom/uiUpdaters.ts
|
||||
|
||||
//? Interface defining the elements needed by UI updaters.
|
||||
export interface HabitCounterUIElements {
|
||||
wrapper: HTMLElement | null;
|
||||
|
|
@ -19,12 +17,13 @@ export function updateDisplayValue(elements: HabitCounterUIElements, newValue: n
|
|||
}
|
||||
}
|
||||
|
||||
/** Updates label text and button aria-labels based on component state. */
|
||||
export function updateStaticUI(elements: HabitCounterUIElements, emoji: string, habitKey: string): void {
|
||||
//& console.log(`[HabitCounterUI] updateStaticUI called for: ${habitKey}`);
|
||||
if (elements.labelElement) {
|
||||
elements.labelElement.textContent = `${emoji} ${habitKey}:`;
|
||||
//& console.log(`[HabitCounterUI] Set label text to: "${elements.labelElement.textContent}"`);
|
||||
const newLabelText = `${emoji} ${habitKey}:`;
|
||||
console.log(`[HabitCounterUI] DEBUG: Attempting to set label textContent to: "${newLabelText}"`);
|
||||
elements.labelElement.textContent = newLabelText;
|
||||
} else {
|
||||
console.error("[HabitCounterUI] updateStaticUI: labelElement was null.");
|
||||
}
|
||||
if (elements.minusButton) {
|
||||
elements.minusButton.setAttribute("aria-label", `Decrease ${habitKey} value`);
|
||||
|
|
@ -34,7 +33,6 @@ export function updateStaticUI(elements: HabitCounterUIElements, emoji: string,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/** Sets the component to visually indicate an error state. */
|
||||
export function setComponentErrorState(elements: HabitCounterUIElements, message: string = "Error"): void {
|
||||
//& console.warn(`[HabitCounterUI] setComponentErrorState called with message: "${message}"`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue