forked from MapComplete/MapComplete
		
	Fixes to the personal theme
This commit is contained in:
		
							parent
							
								
									ce1568f2bb
								
							
						
					
					
						commit
						9e6460030b
					
				
					 11 changed files with 126 additions and 102 deletions
				
			
		|  | @ -1,40 +1,51 @@ | |||
| import {UIElement} from "../UIElement"; | ||||
| import Translations from "../i18n/Translations"; | ||||
| import Combine from "./Combine"; | ||||
| import {FixedUiElement} from "./FixedUiElement"; | ||||
| 
 | ||||
| 
 | ||||
| export class SubtleButton extends UIElement{ | ||||
|     private readonly imageUrl: string; | ||||
|     private readonly image: UIElement; | ||||
|     private readonly message: UIElement; | ||||
|     private readonly linkTo: { url: string, newTab?: boolean } = undefined; | ||||
| 
 | ||||
|     constructor(imageUrl: string, message: string | UIElement, linkTo: { url: string, newTab?: boolean } = undefined) { | ||||
|     constructor(imageUrl: string | UIElement, message: string | UIElement, linkTo: { url: string, newTab?: boolean } = undefined) { | ||||
|         super(undefined); | ||||
|         this.linkTo = linkTo; | ||||
|         this.message = Translations.W(message); | ||||
|         this.imageUrl = imageUrl; | ||||
|         if(this.message !== null){ | ||||
|         this.message.dumbMode = false; | ||||
|         } | ||||
|         if ((imageUrl ?? "") === "") { | ||||
|             this.image = new FixedUiElement(""); | ||||
|         } else if (typeof (imageUrl) === "string") { | ||||
|             this.image = new FixedUiElement(`<img src="${imageUrl}">`); | ||||
|         } else { | ||||
|             this.image = imageUrl; | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     InnerRender(): string { | ||||
|          | ||||
|         if(this.message !== null && this.message.IsEmpty()){ | ||||
|             // Message == null: special case to force empty text
 | ||||
|             return ""; | ||||
|         } | ||||
| 
 | ||||
|         if(this.linkTo != undefined){ | ||||
|             return new Combine([ | ||||
|                 `<a class="subtle-button" href="${this.linkTo.url}" ${this.linkTo.newTab ? 'target="_blank"' : ""}>`, | ||||
|                 this.imageUrl !== undefined ? `<img src='${this.imageUrl}'>` : "", | ||||
|                 this.message ?? "", | ||||
|                 this.image, | ||||
|                 this.message, | ||||
|                 '</a>' | ||||
|             ]).Render(); | ||||
|         } | ||||
|          | ||||
|         return new Combine([ | ||||
|             '<span class="subtle-button">', | ||||
|             this.imageUrl !== undefined ? `<img src='${this.imageUrl}'>` : "", | ||||
|             this.message ?? "", | ||||
|             this.image, | ||||
|             this.message, | ||||
|             '</span>' | ||||
|         ]).Render(); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue