Skip to content

Commit 0289d28

Browse files
committed
refactor: migrate HTML templates to separate JS files for app-header, highlight-memo, and kanban components; update styles for divider-item
1 parent 6452797 commit 0289d28

File tree

10 files changed

+24
-41
lines changed

10 files changed

+24
-41
lines changed

components/app-header/app-header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {ComponentModule} from "../../src/modules/component.js";
21
import {EventsManager} from "../../src/system/events-manager.js";
32
import {HTML} from "./app-header.html.js"
43

@@ -11,6 +10,7 @@ class AppHeader extends HTMLElement {
1110
super();
1211
this.attachShadow({ mode: "open" });
1312
this.shadowRoot.innerHTML = HTML;
13+
this.style.display = "flex";
1414
}
1515

1616
async connectedCallback() {

components/highlight-memo/highlight-memo.html

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const HTML = `
2+
<link rel="stylesheet" href="__css__" />
3+
`.replace("__css__", import.meta.url.replace(".html.js", ".css"));

components/highlight-memo/highlight-memo.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {ComponentModule} from "../../src/modules/component.js";
22
import {MarkdownModule} from "../../src/modules/markdown.js";
3+
import { HTML } from "./highlight-memo.html.js";
34

45
export class HighlightMemo extends HTMLElement {
56
static name = Object.freeze("highlight-memo");
@@ -9,12 +10,7 @@ export class HighlightMemo extends HTMLElement {
910
constructor() {
1011
super();
1112
this.attachShadow({ mode: "open" });
12-
}
13-
14-
async connectedCallback() {
15-
this.shadowRoot.innerHTML = await ComponentModule.load_html({
16-
url: import.meta.url,
17-
});
13+
this.shadowRoot.innerHTML = HTML;
1814
}
1915

2016
async disconnectedCallback() {

components/kanban/kanban.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/kanban/kanban.html.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const HTML = `
2+
<link rel="stylesheet" href="__css__" />
3+
<canvas></canvas>
4+
`.replace("__css__", import.meta.url.replace(".html.js", ".css"));

components/kanban/kanban.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {ComponentModule} from "../../src/modules/component.js";
22
import {CanvasModule} from "../../src/modules/canvas.js";
33
import {groupData} from "./data-processor.js";
4+
import { HTML } from "./kanban.html.js";
45

56
export class Kanban extends HTMLElement {
67
static name = Object.freeze("kanban-component");
@@ -12,22 +13,17 @@ export class Kanban extends HTMLElement {
1213
constructor() {
1314
super();
1415
this.attachShadow({mode: "open"});
16+
this.shadowRoot.innerHTML = HTML;
1517
}
1618

1719
async connectedCallback() {
18-
this.shadowRoot.innerHTML = await ComponentModule.load_html({
19-
url: import.meta.url,
20-
});
21-
22-
requestAnimationFrame(async () => {
23-
this.#canvasWorker = await CanvasModule.initialize({
24-
canvasElement: this.shadowRoot.querySelector("canvas"),
25-
workerSource: new URL("./kanban-worker.js", import.meta.url).href
26-
})
27-
28-
this.#canvasWorker.call("clear");
29-
await ComponentModule.ready({element: this});
20+
this.#canvasWorker = await CanvasModule.initialize({
21+
canvasElement: this.shadowRoot.querySelector("canvas"),
22+
workerSource: new URL("./kanban-worker.js", import.meta.url).href
3023
})
24+
25+
this.#canvasWorker.call("clear");
26+
await ComponentModule.ready({element: this});
3127
}
3228

3329
async disconnectedCallback() {

components/menu/divider-item/divider-item.css

Lines changed: 0 additions & 10 deletions
This file was deleted.

components/menu/divider-item/divider-item.html

Whitespace-only changes.

components/menu/divider-item/divider-item.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import { ComponentModule } from "../../../src/modules/component.js";
2-
31
class DividerItem extends HTMLElement {
42
static name = Object.freeze("divider-item");
53

64
constructor() {
75
super();
86
this.attachShadow({ mode: "open" });
9-
this.style.display = "none";
10-
}
11-
12-
async connectedCallback() {
13-
this.shadowRoot.innerHTML = await ComponentModule.load_html({
14-
url: import.meta.url,
15-
});
16-
17-
this.style.display = "flex";
7+
this.style.display = "block";
8+
this.style.height = "1px";
9+
this.style.backgroundColor = "var(--cl-border)";
10+
this.style.padding = 0;
11+
this.style.border = "none";
12+
this.boxSizing = "border-box";
1813
}
1914
}
2015

0 commit comments

Comments
 (0)