45 lines
1.2 KiB
Svelte
45 lines
1.2 KiB
Svelte
<script lang="ts">
|
|
import {createEventDispatcher} from "svelte";
|
|
import BaseUIElement from "../BaseUIElement";
|
|
import Img from "./Img";
|
|
|
|
export let imageUrl: string | BaseUIElement = undefined
|
|
export let message: string | BaseUIElement = undefined
|
|
export let options: {
|
|
imgSize?: string
|
|
extraClasses?: string
|
|
} = {}
|
|
|
|
let imgClasses = "block justify-center shrink-0 mr-4 " + (options?.imgSize ?? "h-11 w-11");
|
|
const dispatch = createEventDispatcher<{click}>()
|
|
console.log("Slots:", $$slots)
|
|
</script>
|
|
|
|
<button
|
|
class={(options.extraClasses??"") + 'flex hover:shadow-xl transition-[color,background-color,box-shadow] hover:bg-unsubtle cursor-pointer'}
|
|
target={options?.newTab ? "_blank" : ""}
|
|
on:click={(e) => dispatch("click", e)}
|
|
>
|
|
<slot name="image">
|
|
{#if imageUrl !== undefined}
|
|
{#if typeof imageUrl === "string"}
|
|
<Img src={imageUrl} class={imgClasses}></Img>
|
|
{/if}
|
|
{/if}
|
|
</slot>
|
|
|
|
<slot name="message"/>
|
|
</button>
|
|
|
|
<style lang="scss">
|
|
span,
|
|
a {
|
|
@apply flex p-3 my-2 py-4 rounded-lg shrink-0;
|
|
@apply items-center w-full no-underline;
|
|
@apply bg-subtle text-black;
|
|
|
|
:global(span) {
|
|
@apply block text-ellipsis;
|
|
}
|
|
}
|
|
</style>
|