Started using TSLint

This commit is contained in:
2019-11-17 18:09:39 +09:00
parent 5394928ea9
commit 62d63740bb
7 changed files with 134 additions and 125 deletions

View File

@ -1,16 +1,32 @@
import { delay } from "./Utils"
export default class StatusMessage {
container: HTMLElement
text: HTMLElement
private container: HTMLElement
private text: HTMLElement
constructor(container: HTMLElement, text: HTMLElement) {
this.container = container
this.text = text
}
show(message: string, duration: number) {
let messageId = String(Date.now())
public showError(message: string | Error, duration?: number) {
this.clearStyle()
this.show(message.toString(), duration || 4000)
this.container.classList.add("error-message")
}
public showInfo(message: string, duration?: number) {
this.clearStyle()
this.show(message, duration || 2000)
this.container.classList.add("info-message")
}
public close() {
this.container.classList.add("fade-out")
}
private show(message: string, duration: number) {
const messageId = String(Date.now())
this.text.textContent = message
@ -31,24 +47,8 @@ export default class StatusMessage {
})
}
clearStyle() {
private clearStyle() {
this.container.classList.remove("info-message")
this.container.classList.remove("error-message")
}
showError(message: string | Error, duration?: number) {
this.clearStyle()
this.show(message.toString(), duration || 4000)
this.container.classList.add("error-message")
}
showInfo(message: string, duration?: number) {
this.clearStyle()
this.show(message, duration || 2000)
this.container.classList.add("info-message")
}
close() {
this.container.classList.add("fade-out")
}
}
}