Skip to content

Commit 6452797

Browse files
committed
refactor: migrate HTML templates to separate JS files for dynamic-columns and dynamic-rows components
1 parent 51a4007 commit 6452797

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

components/dynamic-columns/dynamic-columns.html

Lines changed: 0 additions & 1 deletion
This file was deleted.
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+
<slot></slot>
4+
`.replace("__css__", import.meta.url.replace(".html.js", ".css"));

components/dynamic-columns/dynamic-columns.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {ComponentModule} from "../../src/modules/component.js";
2+
import { HTML } from "./dynamic-columns.html.js";
23

34
class DynamicColumns extends HTMLElement {
45
static name = Object.freeze("dynamic-columns");
@@ -25,13 +26,10 @@ class DynamicColumns extends HTMLElement {
2526
constructor() {
2627
super();
2728
this.attachShadow({ mode: "open" });
29+
this.shadowRoot.innerHTML = HTML;
2830
}
2931

3032
async connectedCallback() {
31-
this.shadowRoot.innerHTML = await ComponentModule.load_html({
32-
url: import.meta.url,
33-
});
34-
3533
const { columns, minWidths } = getGridTemplateColumns(this);
3634
this.#translateX.minWidths = minWidths;
3735

components/dynamic-rows/dynamic-rows.html

Lines changed: 0 additions & 1 deletion
This file was deleted.
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+
<slot></slot>
4+
`.replace("__css__", import.meta.url.replace(".html.js", ".css"));

components/dynamic-rows/dynamic-rows.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {ComponentModule} from "../../src/modules/component.js";
2+
import { HTML } from "./dynamic-rows.html.js";
23

34
class DynamicRows extends HTMLElement {
45
static name = Object.freeze("dynamic-rows");
@@ -24,14 +25,11 @@ class DynamicRows extends HTMLElement {
2425
constructor() {
2526
super();
2627
this.attachShadow({ mode: "open" });
28+
this.shadowRoot.innerHTML = HTML;
29+
this.style.setProperty("--heights", getGridTemplateRows(this).join(" "));
2730
}
2831

2932
async connectedCallback() {
30-
this.shadowRoot.innerHTML = await ComponentModule.load_html({
31-
url: import.meta.url,
32-
});
33-
34-
this.style.setProperty("--heights", getGridTemplateRows(this).join(" "));
3533
this.addEventListener("mousedown", this.#mouseDownHandler);
3634
}
3735

0 commit comments

Comments
 (0)