Skip to content

Commit

Permalink
feat: make reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
mariohamann committed Mar 4, 2024
1 parent 3ad30e7 commit 0011866
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/activity-graph.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,39 @@ class ActivityGraph extends HTMLElement {
if (this.getAttribute("enhanced") === "✨") return;

// Map attributes that they fit to enhance element
const attributes = {};
this.attrs = {};

[
"range-start",
"range-end",
"activity-data",
"activity-levels",
"first-day-of-week",
"lang",
"i18n",
].forEach((attr) => (this.attrs[attr] = this.getAttribute(attr)));

this.innerHTML = ActivityGraphElement({
state: { attrs: this.attrs },
});
}

static get observedAttributes() {
return [
"range-start",
"range-end",
"activity-data",
"activity-levels",
"first-day-of-week",
].forEach((attr) => (attributes[attr] = this.getAttribute(attr)));
"lang",
"i18n",
];
}

attributeChangedCallback(name, oldValue, newValue) {
this.attrs[name] = newValue;
this.innerHTML = ActivityGraphElement({
state: { attrs: attributes },
state: { attrs: this.attrs },
});
}
}
Expand Down

0 comments on commit 0011866

Please sign in to comment.