-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcomponents.js
More file actions
65 lines (51 loc) · 1.37 KB
/
components.js
File metadata and controls
65 lines (51 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Create a class for the element
class Submodule extends HTMLElement {
constructor() {
// Always call super first in constructor
super();
// attribute content
let title = this.getAttribute('title');
let url = this.getAttribute('url');
let icon = this.getAttribute('icon');
if (!title) {
title = 'No Title'
}
if (icon) {
icon = `<i class="${icon}"></i>`
}
else{
icon = '<i class="fa-solid fa-file"></i>';
}
if (!url) {
title = 'No-URL';
}
this.innerHTML = `
<a href="${url}" class="text-decoration-none"> ${icon} ${title}</a><br />
`;
}
}
// Define the new element
customElements.define('mit-submodule', Submodule);
// Create a class for the element
class Module extends HTMLElement {
constructor() {
// Always call super first in constructor
super();
// attribute content
let title = this.getAttribute('title');
let background = this.getAttribute('background');
if (!background) {
background = 'text-bg-secondary'
}
this.innerHTML = `
<div class="card">
<h5 class="card-header ${background}">${title}</h5>
<div class="card-body">
${this.innerHTML}
</div>
</div>
`;
}
}
// Define the new element
customElements.define('mit-module', Module);