Skip to content

Commit e3837ce

Browse files
committed
create footer component
1 parent 497b998 commit e3837ce

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

web-components/footer/footer.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<link href="web-components/footer/footer.css" rel="stylesheet">
2+
<footer>
3+
<ul>
4+
<li><a href="https://www.ibm.com/contact/us" target="_blank">Contact</a></li>
5+
<li><div></div></li>
6+
<li><a href="http://www.ibm.com/privacy/us/en/" target="_blank">Privacy</a></li>
7+
<li><div></div></li>
8+
<li><a href="https://www.ibm.com/legal?lnk=flg-tous-usen" target="_blank">Terms of use</a></li>
9+
<li><div></div></li>
10+
<li><a href="http://www.ibm.com/accessibility/us/en/" target="_blank">Accessibility</a></li>
11+
</ul>
12+
<p>Copyright IBM Corporation 2023, 2025</p>
13+
</footer>

web-components/footer/footer.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Fetch HTML template
2+
fetch("web-components/footer/footer.html")
3+
.then(stream => stream.text())
4+
.then(text => createComponent(text))
5+
6+
/**
7+
* Creates a web component using a given HTML template.
8+
* @param {string} html - The HTML template.
9+
* @returns {void}
10+
*/
11+
function createComponent(html) {
12+
// Web component class
13+
class Footer extends HTMLElement {
14+
15+
/**
16+
* Called when an attribute is defined or changed.
17+
* @param {string} property - The name of the attribute.
18+
* @param {string} oldValue - The old value of the attribute.
19+
* @param {string} newValue - The new value of the attribute.
20+
*/
21+
attributeChangedCallback(property, oldValue, newValue) {
22+
if (oldValue === newValue) return;
23+
this[property] = newValue;
24+
}
25+
26+
// Invoked when element is added to document
27+
connectedCallback() {
28+
// Create shadow root for element
29+
const shadow = this.attachShadow({mode: 'closed'});
30+
shadow.innerHTML = html;
31+
}
32+
}
33+
34+
// Define new CourseCard element
35+
customElements.define('imscentral-footer', Footer);
36+
}

0 commit comments

Comments
 (0)