Skip to content

Commit

Permalink
Format files
Browse files Browse the repository at this point in the history
  • Loading branch information
HereIsKevin committed Jul 30, 2020
1 parent 730af02 commit 53f6c72
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 29 deletions.
6 changes: 4 additions & 2 deletions examples/dom/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { dom } from "../../dist/esm/index.js";
const { html, render } = dom;

function template(value: number) {
return html(`<div id="display">Value is currently: ${String(value)}</div>
return html(`
<div id="display">Value is currently: ${String(value)}</div>
<button id="increment">Click to increment</button>
${[...Array(value).keys()].map((x) => `<div>${x}</div>`).join("")}`);
${[...Array(value).keys()].map((x) => `<div>${x}</div>`).join("")}
`);
}

function update(node: Element, value: number) {
Expand Down
6 changes: 4 additions & 2 deletions examples/naive_vanilla/naive_vanilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ function render(node: Node, template: DocumentFragment): void {
}

function template(value: number) {
return html`<div id="display">Value is currently: ${String(value)}</div>
return html`
<div id="display">Value is currently: ${String(value)}</div>
<button id="increment">Click to increment</button>
${[...Array(value).keys()].map((x) => `<div>${x}</div>`).join("")}`;
${[...Array(value).keys()].map((x) => `<div>${x}</div>`).join("")}
`;
}

function update(node: Element, value: number) {
Expand Down
12 changes: 7 additions & 5 deletions examples/optimized_vanilla/optimized_vanilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ function initialize() {

const app = document.getElementById("app");

if (app === null) {
if (app === null) {
throw new Error("app missing");
}

app.appendChild(
html`<div id="display">
html`
<div id="display">
Value is currently:
<!--separator-->0
</div>
<button id="increment">Click to increment</button>`
<button id="increment">Click to increment</button>
`
);

const display = document.getElementById("display")?.childNodes[2];
Expand All @@ -42,9 +44,9 @@ function initialize() {
console.time("render");
value++;
display.nodeValue = String(value);
app.appendChild(html`<div>${String(value - 1)}</div>`)
app.appendChild(html`<div>${String(value - 1)}</div>`);
console.timeEnd("render");
})
});

console.timeEnd("render");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/stopwatch/stopwatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ class StopwatchView extends TimedComponent {
@property seconds: number = 0;

render() {
return html` <div>${this.seconds.toFixed(2)}</div> `;
return html`<div>${this.seconds.toFixed(2)}</div>`;
}
}
38 changes: 19 additions & 19 deletions examples/todo/todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class ToDo {
render() {
render(
this.root,
html(
`<div id="todo-controls">
<input type="text" id="todo-controls-content">
<input type="button" value="Add" id="todo-controls-add">
html(`
<div id="todo-controls">
<input type="text" id="todo-controls-content" />
<input type="button" value="Add" id="todo-controls-add" />
</div>
<div id="todo-items">
${Array.from(this.items.entries(), (x) => {
Expand All @@ -77,23 +77,23 @@ class ToDo {
const checked = x[1][1];
return `
<div class="todo-item" data-index="${index}">
<label
${checked ? 'style="text-decoration: line-through;"' : ""}
class="todo-item-label"
<div class="todo-item" data-index="${index}">
<label
${checked ? 'style="text-decoration: line-through;"' : ""}
class="todo-item-label"
>
<input type="checkbox"
class="todo-item-checkbox"
${checked ? "checked" : ""}
>
<input type="checkbox"
class="todo-item-checkbox"
${checked ? "checked" : ""}
>
${content}
</label>
<input type="button" value="Remove" class="todo-item-remove">
</div>
`;
${content}
</label>
<input type="button" value="Remove" class="todo-item-remove">
</div>
`;
}).join("")}
</div>`
)
</div>
`)
);
}
}
Expand Down

0 comments on commit 53f6c72

Please sign in to comment.