forked from MapComplete/MapComplete
		
	Refactoring: overhaul of the visual style with CSS
This commit is contained in:
		
							parent
							
								
									a1f5032232
								
							
						
					
					
						commit
						7f1e8d3f9c
					
				
					 37 changed files with 1280 additions and 741 deletions
				
			
		|  | @ -1,73 +1,35 @@ | |||
| <script lang="ts"> | ||||
|   import { createEventDispatcher, onMount } from "svelte"; | ||||
|   import { Store } from "../../Logic/UIEventSource"; | ||||
|   import {createEventDispatcher} from "svelte"; | ||||
|   import BaseUIElement from "../BaseUIElement"; | ||||
|   import Img from "./Img"; | ||||
|   import Translations from "../i18n/Translations"; | ||||
|   import { ImmutableStore } from "../../Logic/UIEventSource.js"; | ||||
| 
 | ||||
|   export let imageUrl: string | BaseUIElement = undefined | ||||
|   export let message: string | BaseUIElement = undefined | ||||
|   export let options: { | ||||
|     url?: string | Store<string> | ||||
|     newTab?: boolean | ||||
|     imgSize?: string | ||||
|     extraClasses?: string | ||||
|   } = {} | ||||
| 
 | ||||
|   // Website to open when clicked | ||||
|   let href: Store<string> = undefined | ||||
|   if (options?.url) { | ||||
|     href = typeof options?.url == "string" ? new ImmutableStore(options.url) : options.url | ||||
|   } | ||||
| 
 | ||||
|   let imgElem: HTMLElement; | ||||
|   let msgElem: HTMLElement; | ||||
|   let imgClasses = "block justify-center shrink-0 mr-4 " + (options?.imgSize ?? "h-11 w-11"); | ||||
|   const dispatch = createEventDispatcher<{click}>() | ||||
| 
 | ||||
|   onMount(() => { | ||||
|     // Image | ||||
|     if (imgElem && imageUrl) { | ||||
|       let img: BaseUIElement | ||||
| 
 | ||||
|       if ((imageUrl ?? "") === "") { | ||||
|         img = undefined | ||||
|       } else if (typeof imageUrl !== "string") { | ||||
|         img = imageUrl?.SetClass(imgClasses) | ||||
|       } | ||||
|       if (img) imgElem.replaceWith(img.ConstructElement()) | ||||
|     } | ||||
| 
 | ||||
|     // Message | ||||
|     if (msgElem && message) { | ||||
|       let msg = Translations.W(message)?.SetClass("block text-ellipsis no-images flex-shrink") | ||||
|       msgElem.replaceWith(msg.ConstructElement()) | ||||
|     } | ||||
|   }) | ||||
|   console.log("Slots:", $$slots) | ||||
| </script> | ||||
| 
 | ||||
| <svelte:element | ||||
| <button | ||||
|   class={(options.extraClasses??"") + 'flex hover:shadow-xl transition-[color,background-color,box-shadow] hover:bg-unsubtle cursor-pointer'} | ||||
|   href={$href} | ||||
|   target={options?.newTab ? "_blank" : ""} | ||||
|   this={href === undefined ? "span" : "a"} | ||||
|   on:click={(e) => dispatch("click", e)} | ||||
| > | ||||
|   <slot name="image"> | ||||
|     {#if imageUrl !== undefined} | ||||
|       {#if typeof imageUrl === "string"} | ||||
|         <Img src={imageUrl} class={imgClasses}></Img> | ||||
|       {:else } | ||||
|         <template bind:this={imgElem} /> | ||||
|       {/if} | ||||
|     {/if} | ||||
|   </slot> | ||||
| 
 | ||||
|   <slot name="message"> | ||||
|     <template bind:this={msgElem} /> | ||||
|   </slot> | ||||
| </svelte:element> | ||||
|   <slot name="message"/> | ||||
| </button> | ||||
| 
 | ||||
| <style lang="scss"> | ||||
|   span, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue