forked from MapComplete/MapComplete
		
	More refactoring, stuff kindoff works
This commit is contained in:
		
							parent
							
								
									62f471df1e
								
							
						
					
					
						commit
						3943100e54
					
				
					 52 changed files with 635 additions and 1010 deletions
				
			
		|  | @ -4,18 +4,21 @@ import BaseUIElement from "../BaseUIElement"; | |||
| import Link from "./Link"; | ||||
| import Img from "./Img"; | ||||
| import {UIEventSource} from "../../Logic/UIEventSource"; | ||||
| import {UIElement} from "../UIElement"; | ||||
| 
 | ||||
| 
 | ||||
| export class SubtleButton extends Combine { | ||||
| export class SubtleButton extends UIElement { | ||||
| 
 | ||||
|     private readonly _element: BaseUIElement | ||||
| 
 | ||||
|     constructor(imageUrl: string | BaseUIElement, message: string | BaseUIElement, linkTo: { url: string | UIEventSource<string>, newTab?: boolean } = undefined) { | ||||
|         super(SubtleButton.generateContent(imageUrl, message, linkTo)); | ||||
| 
 | ||||
|         super(); | ||||
|         this._element = SubtleButton.generateContent(imageUrl, message, linkTo) | ||||
|         this.SetClass("block flex p-3 my-2 bg-blue-100 rounded-lg hover:shadow-xl hover:bg-blue-200 link-no-underline") | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private static generateContent(imageUrl: string | BaseUIElement, messageT: string | BaseUIElement, linkTo: { url: string | UIEventSource<string>, newTab?: boolean } = undefined): (BaseUIElement   )[] { | ||||
|     private static generateContent(imageUrl: string | BaseUIElement, messageT: string | BaseUIElement, linkTo: { url: string | UIEventSource<string>, newTab?: boolean } = undefined): BaseUIElement { | ||||
|         const message = Translations.W(messageT); | ||||
|         let img; | ||||
|         if ((imageUrl ?? "") === "") { | ||||
|  | @ -28,26 +31,27 @@ export class SubtleButton extends Combine { | |||
|         img?.SetClass("block flex items-center justify-center h-11 w-11 flex-shrink0") | ||||
|         const image = new Combine([img]) | ||||
|             .SetClass("flex-shrink-0"); | ||||
|          | ||||
| 
 | ||||
|         if (linkTo == undefined) { | ||||
|             return [ | ||||
|             return new Combine([ | ||||
|                 image, | ||||
|                 message, | ||||
|             ]; | ||||
|             ]); | ||||
|         } | ||||
|          | ||||
|          | ||||
|         return [ | ||||
|             new Link( | ||||
|                 new Combine([ | ||||
|                     image, | ||||
|                     message?.SetClass("block ml-4 overflow-ellipsis") | ||||
|                 ]).SetClass("flex group"), | ||||
|                 linkTo.url, | ||||
|                 linkTo.newTab ?? false | ||||
|             ) | ||||
|         ]; | ||||
| 
 | ||||
| 
 | ||||
|         return new Link( | ||||
|             new Combine([ | ||||
|                 image, | ||||
|                 message?.SetClass("block ml-4 overflow-ellipsis") | ||||
|             ]).SetClass("flex group"), | ||||
|             linkTo.url, | ||||
|             linkTo.newTab ?? false | ||||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     protected InnerRender(): string | BaseUIElement { | ||||
|         return this._element; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue