2021-01-29 03:23:53 +01:00
|
|
|
import Combine from "../Base/Combine";
|
|
|
|
import Translations from "../i18n/Translations";
|
2021-06-12 02:58:32 +02:00
|
|
|
import BaseUIElement from "../BaseUIElement";
|
2021-06-18 01:25:13 +02:00
|
|
|
import {VariableUiElement} from "../Base/VariableUIElement";
|
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
2021-09-29 23:56:59 +02:00
|
|
|
import {LicenseInfo} from "../../Logic/ImageProviders/LicenseInfo";
|
2021-01-29 03:23:53 +01:00
|
|
|
|
2021-06-18 01:25:13 +02:00
|
|
|
export default class Attribution extends VariableUiElement {
|
2021-01-29 03:23:53 +01:00
|
|
|
|
2021-06-18 01:25:13 +02:00
|
|
|
constructor(license: UIEventSource<LicenseInfo>, icon: BaseUIElement) {
|
|
|
|
if (license === undefined) {
|
|
|
|
throw "No license source given in the attribution element"
|
|
|
|
}
|
|
|
|
super(
|
2021-09-09 00:05:51 +02:00
|
|
|
license.map((license: LicenseInfo) => {
|
2021-09-26 17:36:39 +02:00
|
|
|
if(license === undefined){
|
|
|
|
return undefined
|
2021-06-18 01:25:13 +02:00
|
|
|
}
|
2021-09-26 17:36:39 +02:00
|
|
|
|
2021-06-18 01:25:13 +02:00
|
|
|
return new Combine([
|
|
|
|
icon?.SetClass("block left").SetStyle("height: 2em; width: 2em; padding-right: 0.5em;"),
|
|
|
|
|
|
|
|
new Combine([
|
2021-10-07 22:06:47 +02:00
|
|
|
Translations.W(license?.title).SetClass("block"),
|
|
|
|
Translations.W(license?.artist ?? "").SetClass("block font-bold"),
|
2021-09-26 17:36:39 +02:00
|
|
|
Translations.W((license?.license ?? "") === "" ? "CC0" : (license?.license ?? ""))
|
2021-06-18 01:25:13 +02:00
|
|
|
]).SetClass("flex flex-col")
|
2021-10-07 22:06:47 +02:00
|
|
|
]).SetClass("flex flex-row bg-black text-white text-sm absolute bottom-0 left-0 p-0.5 pl-5 pr-3 rounded-lg no-images")
|
2021-06-18 01:25:13 +02:00
|
|
|
|
|
|
|
}));
|
2021-01-29 03:23:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|