Skip to content

Commit 24e93ee

Browse files
Update indexedDB to use latest version of wc
1 parent 91aaa01 commit 24e93ee

File tree

18 files changed

+170
-169
lines changed

18 files changed

+170
-169
lines changed

experimental/javascript-wc-indexeddb/dist/components/todo-app/todo-app.component.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ class TodoApp extends HTMLElement {
5050
}
5151

5252
toggleItem(event) {
53-
if (event.detail.completed) {
53+
if (event.detail.completed)
5454
this.#numberOfCompletedItems++;
55-
} else {
55+
else
5656
this.#numberOfCompletedItems--;
57-
}
57+
5858
this.list.toggleItem(event.detail.itemNumber, event.detail.completed);
5959
this.update("toggle-item", event.detail.id);
6060
}
6161

6262
removeItem(event) {
63-
if (event.detail.completed) {
63+
if (event.detail.completed)
6464
this.#numberOfCompletedItems--;
65-
}
65+
6666
this.#numberOfItems--;
6767
this.update("remove-item", event.detail.id);
6868
this.list.removeItem(event.detail.itemNumber);
@@ -87,7 +87,6 @@ class TodoApp extends HTMLElement {
8787
moveToPreviousPage() {
8888
// Skeleton implementation of previous page navigation
8989
this.list.moveToPreviousPage().then(() => {
90-
console.log("Moving to previous page");
9190
this.bottombar.reenablePreviousPageButton();
9291
window.dispatchEvent(new CustomEvent("previous-page-loaded", {}));
9392
});

experimental/javascript-wc-indexeddb/dist/components/todo-bottombar/todo-bottombar.component.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import template from "./todo-bottombar.template.js";
33
import globalStyles from "../../styles/global.constructable.js";
44
import bottombarStyles from "../../styles/bottombar.constructable.js";
55

6-
const additionalStyles = new CSSStyleSheet();
7-
additionalStyles.replaceSync(`
6+
const customStyles = new CSSStyleSheet();
7+
customStyles.replaceSync(`
88
99
.clear-completed-button, .clear-completed-button:active,
1010
.todo-status,
@@ -29,12 +29,11 @@ additionalStyles.replaceSync(`
2929
grid-column: span 3;
3030
}
3131
32-
.bottombar.display-none {
32+
:host([total-items="0"]) > .bottombar {
3333
display: none;
3434
}
3535
`);
3636

37-
3837
class TodoBottombar extends HTMLElement {
3938
static get observedAttributes() {
4039
return ["total-items", "active-items"];
@@ -52,7 +51,7 @@ class TodoBottombar extends HTMLElement {
5251
this.shadow = this.attachShadow({ mode: "open" });
5352
this.htmlDirection = document.dir || "ltr";
5453
this.setAttribute("dir", this.htmlDirection);
55-
this.shadow.adoptedStyleSheets = [globalStyles, bottombarStyles, additionalStyles];
54+
this.shadow.adoptedStyleSheets = [globalStyles, bottombarStyles, customStyles];
5655
this.shadow.append(node);
5756

5857
this.clearCompletedItems = this.clearCompletedItems.bind(this);
@@ -61,11 +60,6 @@ class TodoBottombar extends HTMLElement {
6160
}
6261

6362
updateDisplay() {
64-
if (parseInt(this["total-items"]) !== 0)
65-
this.element.classList.remove("display-none");
66-
else
67-
this.element.classList.add("display-none");
68-
6963
this.todoStatus.textContent = `${this["active-items"]} ${this["active-items"] === "1" ? "item" : "items"} left!`;
7064
}
7165

@@ -81,14 +75,12 @@ class TodoBottombar extends HTMLElement {
8175
clearCompletedItems() {
8276
this.dispatchEvent(new CustomEvent("clear-completed-items"));
8377
}
84-
78+
8579
MoveToNextPage() {
86-
console.log("Moving to next page");
8780
this.dispatchEvent(new CustomEvent("next-page"));
8881
}
8982

9083
MoveToPreviousPage() {
91-
console.log("Moving to previous page button clicked");
9284
this.element.querySelector(".previous-page-button").disabled = true;
9385
this.dispatchEvent(new CustomEvent("previous-page"));
9486
}

experimental/javascript-wc-indexeddb/dist/components/todo-bottombar/todo-bottombar.template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const template = document.createElement("template");
22

33
template.id = "todo-bottombar-template";
44
template.innerHTML = `
5-
<footer class="bottombar display-none">
5+
<footer class="bottombar">
66
<div class="todo-status"><span class="todo-count">0</span> item left</div>
77
<ul class="filter-list">
88
<li class="filter-item">

experimental/javascript-wc-indexeddb/dist/components/todo-item/todo-item.component.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class TodoItem extends HTMLElement {
6666
}
6767
break;
6868
case "itemcompleted":
69-
this.toggleInput.checked = this.itemcompleted === "true" ? true : false;
69+
this.toggleInput.checked = this.itemcompleted === "true";
7070
break;
7171
}
7272
});
@@ -111,11 +111,10 @@ class TodoItem extends HTMLElement {
111111

112112
updateItem(event) {
113113
if (event.target.value !== this.itemtitle) {
114-
if (!event.target.value.length) {
114+
if (!event.target.value.length)
115115
this.removeItem();
116-
} else {
116+
else
117117
this.setAttribute("itemtitle", event.target.value);
118-
}
119118
}
120119

121120
this.cancelEdit();

0 commit comments

Comments
 (0)