Skip to content

Commit a4644da

Browse files
committed
refactor: migrate menu-group and menu-item HTML templates to separate JS files and update component initialization
1 parent 5f20687 commit a4644da

File tree

7 files changed

+16
-20
lines changed

7 files changed

+16
-20
lines changed

components/menu/menu-group/menu-group.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/menu/menu-group/menu-group.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import { ComponentModule } from "../../../src/modules/component.js";
2+
import { HTML } from "./menu-group.html.js";
23

34
class MenuGroup extends HTMLElement {
45
static name = Object.freeze("menu-group");
56

67
constructor() {
78
super();
89
this.attachShadow({ mode: "open" });
9-
this.style.display = "none";
10+
this.shadowRoot.innerHTML = HTML;
1011
}
1112

1213
async connectedCallback() {
13-
this.shadowRoot.innerHTML = await ComponentModule.load_html({
14-
url: import.meta.url,
15-
});
16-
1714
await this.#addChevron();
18-
this.style.display = "flex";
1915
}
2016

2117
#addChevron() {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
--menu-item-hover-bg: var(--selected-background-color);
33
--menu-item-hover-fg: var(--selected-color);
44

5+
display: flex;
6+
flex-direction: row;
57
padding: var(--padding);
68
cursor: pointer;
79
width: fit-content;

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

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

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
import { ComponentModule } from "../../../src/modules/component.js";
1+
import { HTML } from "./menu-item.html.js";
22

33
class MenuItem extends HTMLElement {
44
static name = Object.freeze("menu-item");
55

66
constructor() {
77
super();
88
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";
9+
this.shadowRoot.innerHTML = HTML;
1810
}
1911
}
2012

0 commit comments

Comments
 (0)