Skip to content

Commit f1eddfe

Browse files
PostMessage Cleanup - TodoMVC example (experimental) (#509)
1 parent deba93c commit f1eddfe

33 files changed

+1573
-106
lines changed

resources/shared/todomvc-utils.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const numberOfItemsToAdd = 100;

resources/translations.mjs renamed to resources/shared/translations.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,3 +724,11 @@ export const defaultTodoText = {
724724
ru: "Кое-что сделать",
725725
emoji: "Something to do 😊",
726726
};
727+
728+
export const defaultLanguage = "en";
729+
730+
export function getTodoText(lang = "en", index) {
731+
const todosSelection = todos[lang];
732+
const currentIndex = index % todosSelection.length;
733+
return todosSelection[currentIndex];
734+
}

resources/tests.mjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import { BenchmarkTestStep } from "./benchmark-runner.mjs";
2-
import { todos } from "./translations.mjs";
3-
4-
const numberOfItemsToAdd = 100;
5-
const defaultLanguage = "en";
6-
7-
function getTodoText(lang, index) {
8-
const todosSelection = todos[lang] ?? todos[defaultLanguage];
9-
const currentIndex = index % todosSelection.length;
10-
return todosSelection[currentIndex];
11-
}
2+
import { getTodoText, defaultLanguage } from "./shared/translations.mjs";
3+
import { numberOfItemsToAdd } from "./shared/todomvc-utils.mjs";
124

135
export const Suites = [];
146

@@ -267,6 +259,18 @@ Suites.push({
267259
],
268260
});
269261

262+
Suites.push({
263+
name: "TodoMVC-WebComponents-PostMessage",
264+
url: "resources/todomvc/vanilla-examples/javascript-web-components/dist/index.html",
265+
tags: ["experimental", "todomvc", "webcomponents"],
266+
disabled: true,
267+
async prepare() {},
268+
type: "remote",
269+
/* config: {
270+
name: "default", // optional param to target non-default tests locally
271+
}, */
272+
});
273+
270274
Suites.push({
271275
name: "TodoMVC-WebComponents-Complex-DOM",
272276
url: "resources/todomvc/vanilla-examples/javascript-web-components-complex/dist/index.html",

resources/todomvc/vanilla-examples/javascript-web-components/dist/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<link rel="stylesheet" href="styles/header.css" />
1010
<link rel="stylesheet" href="styles/footer.css" />
1111
<!-- load these first, so that they are registered by the time the app components needs them -->
12-
<script type="module" src="components/todo-topbar/todo-topbar.component.js"></script>
13-
<script type="module" src="components/todo-list/todo-list.component.js"></script>
14-
<script type="module" src="components/todo-bottombar/todo-bottombar.component.js"></script>
15-
<script type="module" src="components/todo-app/todo-app.component.js"></script>
12+
<script type="module" src="src/components/todo-topbar/todo-topbar.component.js"></script>
13+
<script type="module" src="src/components/todo-list/todo-list.component.js"></script>
14+
<script type="module" src="src/components/todo-bottombar/todo-bottombar.component.js"></script>
15+
<script type="module" src="src/components/todo-app/todo-app.component.js"></script>
1616
</head>
1717

1818
<body>
@@ -26,5 +26,6 @@
2626
<p class="footer-text">Press 'enter' to add the todo.</p>
2727
<p class="footer-text">Double-click to edit a todo</p>
2828
</footer>
29+
<script type="module" src="src/index.mjs"></script>
2930
</body>
3031
</html>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import template from "./todo-app.template.js";
22
import { useRouter } from "../../hooks/useRouter.js";
33

4-
import globalStyles from "../../styles/global.constructable.js";
5-
import appStyles from "../../styles/app.constructable.js";
6-
import mainStyles from "../../styles/main.constructable.js";
4+
import globalStyles from "../../../styles/global.constructable.js";
5+
import appStyles from "../../../styles/app.constructable.js";
6+
import mainStyles from "../../../styles/main.constructable.js";
77
class TodoApp extends HTMLElement {
88
#isReady = false;
99
#data = [];
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import template from "./todo-bottombar.template.js";
22

3-
import globalStyles from "../../styles/global.constructable.js";
4-
import bottombarStyles from "../../styles/bottombar.constructable.js";
3+
import globalStyles from "../../../styles/global.constructable.js";
4+
import bottombarStyles from "../../../styles/bottombar.constructable.js";
55

66
class TodoBottombar extends HTMLElement {
77
static get observedAttributes() {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import template from "./todo-item.template.js";
22
import { useDoubleClick } from "../../hooks/useDoubleClick.js";
33
import { useKeyListener } from "../../hooks/useKeyListener.js";
44

5-
import globalStyles from "../../styles/global.constructable.js";
6-
import itemStyles from "../../styles/todo-item.constructable.js";
5+
import globalStyles from "../../../styles/global.constructable.js";
6+
import itemStyles from "../../../styles/todo-item.constructable.js";
77

88
class TodoItem extends HTMLElement {
99
static get observedAttributes() {

0 commit comments

Comments
 (0)