MapComplete/UI/Base/SubtleButton.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.2 KiB
Svelte
Raw Normal View History

2023-01-17 18:31:51 +01:00
<script lang="ts">
import {createEventDispatcher} from "svelte";
2023-02-11 15:04:20 +01:00
import BaseUIElement from "../BaseUIElement";
import Img from "./Img";
2023-01-17 18:31:51 +01:00
2023-03-09 23:19:49 +01:00
export let imageUrl: string | BaseUIElement = undefined
export let message: string | BaseUIElement = undefined
2023-02-03 16:11:46 +01:00
export let options: {
imgSize?: string
extraClasses?: string
2023-03-09 23:19:49 +01:00
} = {}
2023-01-17 18:31:51 +01:00
2023-02-11 15:04:20 +01:00
let imgClasses = "block justify-center shrink-0 mr-4 " + (options?.imgSize ?? "h-11 w-11");
const dispatch = createEventDispatcher<{click}>()
console.log("Slots:", $$slots)
2023-01-17 18:31:51 +01:00
</script>
<button
class={(options.extraClasses??"") + 'flex hover:shadow-xl transition-[color,background-color,box-shadow] hover:bg-unsubtle cursor-pointer'}
2023-02-03 16:11:46 +01:00
target={options?.newTab ? "_blank" : ""}
on:click={(e) => dispatch("click", e)}
2023-02-03 16:11:46 +01:00
>
<slot name="image">
2023-02-11 15:04:20 +01:00
{#if imageUrl !== undefined}
{#if typeof imageUrl === "string"}
<Img src={imageUrl} class={imgClasses}></Img>
2023-02-09 00:10:59 +01:00
{/if}
2023-02-11 15:04:20 +01:00
{/if}
2023-02-03 16:11:46 +01:00
</slot>
2023-02-11 15:04:20 +01:00
<slot name="message"/>
</button>
2023-01-17 18:31:51 +01:00
<style lang="scss">
span,
a {
2023-02-11 15:04:20 +01:00
@apply flex p-3 my-2 py-4 rounded-lg shrink-0;
2023-02-03 16:11:46 +01:00
@apply items-center w-full no-underline;
2023-02-09 00:10:59 +01:00
@apply bg-subtle text-black;
2023-02-03 16:11:46 +01:00
2023-02-03 22:28:11 +01:00
:global(span) {
2023-02-11 15:04:20 +01:00
@apply block text-ellipsis;
2023-02-03 22:28:11 +01:00
}
2023-01-17 18:31:51 +01:00
}
</style>