| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import Combine from "../Base/Combine" | 
					
						
							|  |  |  | import Translations from "../i18n/Translations" | 
					
						
							|  |  |  | import BaseUIElement from "../BaseUIElement" | 
					
						
							|  |  |  | import { VariableUiElement } from "../Base/VariableUIElement" | 
					
						
							|  |  |  | import { Store } from "../../Logic/UIEventSource" | 
					
						
							|  |  |  | import { LicenseInfo } from "../../Logic/ImageProviders/LicenseInfo" | 
					
						
							|  |  |  | import { FixedUiElement } from "../Base/FixedUiElement" | 
					
						
							|  |  |  | import Link from "../Base/Link" | 
					
						
							| 
									
										
										
										
											2021-01-29 03:23:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-30 20:29:49 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Small box in the bottom left of an image, e.g. the image in a popup | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  | export default class Attribution extends VariableUiElement { | 
					
						
							| 
									
										
										
										
											2022-06-05 02:24:14 +02:00
										 |  |  |     constructor(license: Store<LicenseInfo>, icon: BaseUIElement, date?: Date) { | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |         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-11-07 16:34:51 +01:00
										 |  |  |                 if (license === undefined) { | 
					
						
							| 
									
										
										
										
											2021-09-26 17:36:39 +02:00
										 |  |  |                     return undefined | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 let title = undefined | 
					
						
							| 
									
										
										
										
											2022-08-30 20:29:49 +02:00
										 |  |  |                 if (license?.title) { | 
					
						
							|  |  |  |                     title = Translations.W(license?.title).SetClass("block") | 
					
						
							|  |  |  |                     if (license.informationLocation) { | 
					
						
							|  |  |  |                         title = new Link(title, license.informationLocation.href, true) | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |                 return new Combine([ | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                     icon | 
					
						
							|  |  |  |                         ?.SetClass("block left") | 
					
						
							|  |  |  |                         .SetStyle("height: 2em; width: 2em; padding-right: 0.5em;"), | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     new Combine([ | 
					
						
							| 
									
										
										
										
											2022-08-30 20:29:49 +02:00
										 |  |  |                         title, | 
					
						
							| 
									
										
										
										
											2021-10-07 22:06:47 +02:00
										 |  |  |                         Translations.W(license?.artist ?? "").SetClass("block font-bold"), | 
					
						
							| 
									
										
										
										
											2022-06-13 00:51:53 +02:00
										 |  |  |                         Translations.W(license?.license ?? license?.licenseShortName), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                         date === undefined | 
					
						
							|  |  |  |                             ? undefined | 
					
						
							|  |  |  |                             : new FixedUiElement(date.toLocaleDateString()), | 
					
						
							|  |  |  |                     ]).SetClass("flex flex-col"), | 
					
						
							|  |  |  |                 ]).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-01-29 03:23:53 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |