30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import Conquer from '@burguillosinfo/conquer'
|
|
import ConquerInterface from '@burguillosinfo/conquer/interface'
|
|
|
|
export default abstract class AbstractTopBarInterface extends ConquerInterface {
|
|
constructor() {
|
|
super()
|
|
const exitButton = this.getExitButton()
|
|
exitButton.addEventListener('click', () => {
|
|
this.runCallbacks('close')
|
|
})
|
|
}
|
|
protected generateNodes(): HTMLElement[] {
|
|
const newNode = this.getNodeFromTemplateId('conquer-interface-with-top-bar-template')
|
|
return [newNode]
|
|
}
|
|
protected getMainNode(): HTMLElement {
|
|
return this.getNodes()[0]
|
|
}
|
|
protected getExitButton(): HTMLElement {
|
|
const maybeExitButton = this.getMainNode().querySelector('.conquer-exit-button')
|
|
if (maybeExitButton === null || !(maybeExitButton instanceof HTMLElement)) {
|
|
Conquer.fail('No exit button.')
|
|
}
|
|
return maybeExitButton
|
|
}
|
|
public generateInterfaceElementCentered(): HTMLElement {
|
|
return this.getNodeFromTemplateId('conquer-interface-element-padded-template')
|
|
}
|
|
}
|