MapComplete/src/UI/Base/SubtleButton.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-06-10 01:36:20 +02:00
import BaseUIElement from "../BaseUIElement"
2021-06-12 02:58:32 +02:00
import { UIElement } from "../UIElement"
import Translations from "../i18n/Translations"
import Combine from "./Combine"
import Img from "./Img"
/**
* @deprecated
*/
2021-06-12 02:58:32 +02:00
export class SubtleButton extends UIElement {
private readonly imageUrl: string | BaseUIElement
private readonly message: string | BaseUIElement
2021-05-30 00:17:31 +02:00
2022-04-24 01:32:19 +02:00
constructor(
imageUrl: string | BaseUIElement,
message: string | BaseUIElement
2022-04-24 01:32:19 +02:00
) {
2021-06-12 02:58:32 +02:00
super()
this.imageUrl = imageUrl
this.message = message
2021-05-30 00:17:31 +02:00
}
protected InnerRender(): string | BaseUIElement {
const classes = "button"
const message = Translations.W(this.message)?.SetClass(
"block overflow-ellipsis no-images flex-shrink"
)
let img
const imgClasses =
"block justify-center flex-none mr-4 h-11 w-11"
if ((this.imageUrl ?? "") === "") {
img = undefined
} else if (typeof this.imageUrl === "string") {
img = new Img(this.imageUrl)?.SetClass(imgClasses)
} else {
img = this.imageUrl?.SetClass(imgClasses)
}
const button = new Combine([img, message]).SetClass("flex items-center group w-full")
this.SetClass(classes)
return button
}
}