2021-06-11 23:15:40 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
2021-06-12 00:18:50 +02:00
|
|
|
<script lang="ts">
|
2021-06-21 20:24:15 +02:00
|
|
|
import type { DropdownProps } from "components/dropdown";
|
2021-06-30 19:55:56 +02:00
|
|
|
import { dropdownKey } from "components/context-keys";
|
2021-06-21 20:24:15 +02:00
|
|
|
import { onMount, createEventDispatcher, getContext } from "svelte";
|
2021-06-12 00:18:50 +02:00
|
|
|
|
2021-06-12 00:38:56 +02:00
|
|
|
let className = "";
|
|
|
|
export { className as class };
|
2021-06-24 17:19:42 +02:00
|
|
|
export let tooltip: string | undefined = undefined;
|
2021-06-12 00:38:56 +02:00
|
|
|
|
2021-06-12 00:18:50 +02:00
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
let spanRef: HTMLSpanElement;
|
|
|
|
|
2021-06-21 20:24:15 +02:00
|
|
|
const dropdownProps = getContext<DropdownProps>(dropdownKey) ?? { dropdown: false };
|
|
|
|
|
2021-06-12 00:18:50 +02:00
|
|
|
onMount(() => {
|
|
|
|
dispatch("mount", { span: spanRef });
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2021-06-21 20:24:15 +02:00
|
|
|
<span
|
|
|
|
bind:this={spanRef}
|
2021-06-24 16:44:08 +02:00
|
|
|
title={tooltip}
|
2021-06-21 20:24:15 +02:00
|
|
|
class={`badge ${className}`}
|
|
|
|
class:dropdown-toggle={dropdownProps.dropdown}
|
|
|
|
{...dropdownProps}
|
|
|
|
on:click
|
2021-06-24 14:06:57 +02:00
|
|
|
on:mouseenter
|
|
|
|
on:mouseleave
|
2021-06-21 20:24:15 +02:00
|
|
|
>
|
2021-06-11 23:15:40 +02:00
|
|
|
<slot />
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.badge {
|
|
|
|
color: inherit;
|
|
|
|
}
|
|
|
|
|
2021-06-21 20:24:15 +02:00
|
|
|
.dropdown-toggle::after {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2021-06-11 23:15:40 +02:00
|
|
|
span :global(svg) {
|
2021-06-24 01:32:54 +02:00
|
|
|
border-radius: inherit;
|
2021-06-11 23:15:40 +02:00
|
|
|
vertical-align: -0.125rem;
|
|
|
|
}
|
|
|
|
</style>
|