2020-07-29 16:46:45 +02:00
|
|
|
import {UIElement} from "../UIElement";
|
|
|
|
import Translations from "../i18n/Translations";
|
|
|
|
import Combine from "./Combine";
|
|
|
|
|
|
|
|
|
|
|
|
export class SubtleButton extends UIElement{
|
2020-09-02 11:37:34 +02:00
|
|
|
private readonly imageUrl: string;
|
|
|
|
private readonly message: UIElement;
|
|
|
|
private readonly linkTo: { url: string, newTab?: boolean } = undefined;
|
2020-07-29 16:46:45 +02:00
|
|
|
|
2020-07-29 21:32:51 +02:00
|
|
|
constructor(imageUrl: string, message: string | UIElement, linkTo: { url: string, newTab?: boolean } = undefined) {
|
2020-07-29 16:46:45 +02:00
|
|
|
super(undefined);
|
2020-07-29 19:02:36 +02:00
|
|
|
this.linkTo = linkTo;
|
2020-07-29 16:46:45 +02:00
|
|
|
this.message = Translations.W(message);
|
|
|
|
this.imageUrl = imageUrl;
|
2020-07-29 21:32:51 +02:00
|
|
|
|
2020-07-29 16:46:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
InnerRender(): string {
|
2020-08-31 02:59:47 +02:00
|
|
|
|
2020-09-02 11:37:34 +02:00
|
|
|
if(this.message !== null && this.message.IsEmpty()){
|
2020-08-31 02:59:47 +02:00
|
|
|
return "";
|
|
|
|
}
|
2020-07-29 19:02:36 +02:00
|
|
|
|
|
|
|
if(this.linkTo != undefined){
|
|
|
|
return new Combine([
|
2020-07-29 21:32:51 +02:00
|
|
|
`<a class="subtle-button" href="${this.linkTo.url}" ${this.linkTo.newTab ? 'target="_blank"' : ""}>`,
|
2020-07-29 19:02:36 +02:00
|
|
|
this.imageUrl !== undefined ? `<img src='${this.imageUrl}'>` : "",
|
2020-09-02 11:37:34 +02:00
|
|
|
this.message ?? "",
|
2020-07-29 19:02:36 +02:00
|
|
|
'</a>'
|
|
|
|
]).Render();
|
|
|
|
}
|
|
|
|
|
2020-07-29 16:46:45 +02:00
|
|
|
return new Combine([
|
|
|
|
'<span class="subtle-button">',
|
2020-07-29 18:35:46 +02:00
|
|
|
this.imageUrl !== undefined ? `<img src='${this.imageUrl}'>` : "",
|
2020-09-02 11:37:34 +02:00
|
|
|
this.message ?? "",
|
2020-07-29 16:46:45 +02:00
|
|
|
'</span>'
|
|
|
|
]).Render();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|