forked from MapComplete/MapComplete
		
	Refactoring: move all code files into a src directory
This commit is contained in:
		
							parent
							
								
									de99f56ca8
								
							
						
					
					
						commit
						e75d2789d2
					
				
					 389 changed files with 0 additions and 12 deletions
				
			
		
							
								
								
									
										27
									
								
								src/UI/UIElement.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/UI/UIElement.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| import BaseUIElement from "./BaseUIElement" | ||||
| 
 | ||||
| export abstract class UIElement extends BaseUIElement { | ||||
|     /** | ||||
|      * Should be overridden for specific HTML functionality | ||||
|      */ | ||||
|     protected InnerConstructElement(): HTMLElement { | ||||
|         // Uses the old fashioned way to construct an element using 'InnerRender'
 | ||||
|         const innerRender = this.InnerRender() | ||||
|         if (innerRender === undefined || innerRender === "") { | ||||
|             return undefined | ||||
|         } | ||||
|         const el = document.createElement("span") | ||||
|         if (typeof innerRender === "string") { | ||||
|             el.innerHTML = innerRender | ||||
|         } else { | ||||
|             const subElement = innerRender.ConstructElement() | ||||
|             if (subElement === undefined) { | ||||
|                 return undefined | ||||
|             } | ||||
|             el.appendChild(subElement) | ||||
|         } | ||||
|         return el | ||||
|     } | ||||
| 
 | ||||
|     protected abstract InnerRender(): string | BaseUIElement | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue