1 export class InfoSection
extends HTMLElement
{
2 constructor(header
, subheaders
) {
5 <div id='infoSectionContainer'>
6 <div id=${this.formatHeader(header)} class='infoSectionHeader'>
9 <div id='expand-collapse' class='expand-collapse'>
14 <div id='subheaders' class='hidden'>
15 <div id='generalDescription'></div>
17 <div class='section-break'></div>
21 this.subheaders
= subheaders
;
22 this.sectionDivs
= {};
23 this.expanded
= false;
27 this.initializeHeader();
28 this.createSubHeaders();
32 const header
= this.querySelector('#header');
33 const expandCollapse
= this.querySelector('#expand-collapse');
35 header
.onclick
= () => {
37 this.contractSection();
42 header
.onmouseover
= () => {
43 expandCollapse
.classList
.add('hover');
45 header
.onmouseout
= () => {
46 expandCollapse
.classList
.remove('hover');
51 const subsections
= this.querySelector('#subheaders');
52 const expandCollapse
= this.querySelector('#expand-collapse');
54 subsections
.classList
.remove('hidden');
55 expandCollapse
.innerHTML
= '[-]';
60 const subsections
= this.querySelector('#subheaders');
61 const expandCollapse
= this.querySelector('#expand-collapse');
63 subsections
.classList
.add('hidden');
64 expandCollapse
.innerHTML
= '[+]';
65 this.expanded
= false;
69 const subsections
= this.querySelector('#subheaders');
70 this.sectionDivs
[this.header
] = this.querySelector('#generalDescription');
71 for (let subheader
of this.subheaders
) {
72 let div
= document
.createElement('div');
73 div
.id
= this.formatHeader(subheader
);
74 let h4
= document
.createElement('h4');
75 h4
.innerHTML
= subheader
;
77 subsections
.appendChild(div
);
78 this.sectionDivs
[subheader
] = div
;
82 formatHeader(header
) {
83 return header
.replace(' ', '-');
86 updateDescription(subheader
, description
) {
87 const subSection
= this.sectionDivs
[subheader
];
88 if (subSection
== null) {
91 let p
= document
.createElement('p');
92 p
.innerHTML
= description
;
93 subSection
.appendChild(p
);
97 window
.customElements
.define('info-section', InfoSection
);