forked from MapComplete/MapComplete
Refactoring: move all code files into a src directory
This commit is contained in:
parent
de99f56ca8
commit
e75d2789d2
389 changed files with 0 additions and 12 deletions
25
src/UI/Base/Button.ts
Normal file
25
src/UI/Base/Button.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import Translations from "../i18n/Translations"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
|
||||
export class Button extends BaseUIElement {
|
||||
private _text: BaseUIElement
|
||||
|
||||
constructor(text: string | BaseUIElement, onclick: () => void | Promise<void>) {
|
||||
super()
|
||||
this._text = Translations.W(text)
|
||||
this.onClick(onclick)
|
||||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
const el = this._text.ConstructElement()
|
||||
if (el === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const form = document.createElement("form")
|
||||
const button = document.createElement("button")
|
||||
button.type = "button"
|
||||
button.appendChild(el)
|
||||
form.appendChild(button)
|
||||
return form
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue