2023-10-06 23:56:50 +02:00
|
|
|
<script lang="ts">
|
2023-12-19 22:08:00 +01:00
|
|
|
import Icon from "./Icon.svelte"
|
2024-06-18 17:55:47 +02:00
|
|
|
import { twMerge } from "tailwind-merge"
|
2023-10-06 23:56:50 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Renders a 'marker', which consists of multiple 'icons'
|
|
|
|
|
*/
|
2024-06-19 01:56:19 +02:00
|
|
|
export let icons: string | { icon: string; color: string }[]
|
|
|
|
|
|
2024-06-19 03:26:29 +02:00
|
|
|
let iconsParsed: { icon: string; color: string }[]
|
2024-06-20 04:21:29 +02:00
|
|
|
if (typeof icons === "string") {
|
|
|
|
|
iconsParsed = icons.split(";").map((subspec) => {
|
|
|
|
|
if (subspec.startsWith("http://") || subspec.startsWith("https://")) {
|
2024-06-19 01:56:19 +02:00
|
|
|
return {
|
2024-06-20 04:21:29 +02:00
|
|
|
icon: subspec,
|
|
|
|
|
color: "black",
|
2024-06-19 01:56:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const [icon, color] = subspec.split(":")
|
|
|
|
|
return {
|
2024-06-20 04:21:29 +02:00
|
|
|
icon,
|
|
|
|
|
color: color ?? "black",
|
2024-06-19 01:56:19 +02:00
|
|
|
}
|
|
|
|
|
})
|
2024-06-20 04:21:29 +02:00
|
|
|
} else {
|
2024-06-19 03:26:29 +02:00
|
|
|
iconsParsed = icons
|
2024-06-19 01:56:19 +02:00
|
|
|
}
|
|
|
|
|
|
2024-06-18 17:55:47 +02:00
|
|
|
/**
|
|
|
|
|
* Class which is applied onto the individual icons
|
|
|
|
|
*/
|
|
|
|
|
export let clss = ""
|
2024-08-23 13:13:41 +02:00
|
|
|
export let emojiHeight: string = "40px"
|
2024-06-19 01:56:19 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class applied onto the entire element
|
|
|
|
|
*/
|
2024-06-18 17:55:47 +02:00
|
|
|
export let size = "w-full h-full"
|
2023-10-07 03:07:32 +02:00
|
|
|
</script>
|
2023-11-09 16:30:26 +01:00
|
|
|
|
2024-06-19 03:26:29 +02:00
|
|
|
{#if iconsParsed !== undefined && iconsParsed.length > 0}
|
2024-06-18 17:55:47 +02:00
|
|
|
<div class={twMerge("relative", size)}>
|
2024-06-19 03:26:29 +02:00
|
|
|
{#each iconsParsed as icon}
|
2024-08-09 16:55:08 +02:00
|
|
|
<div class="absolute top-0 left-0 flex h-full w-full items-center">
|
2024-08-23 03:47:04 +02:00
|
|
|
<Icon icon={icon.icon} color={icon.color} {clss} {emojiHeight} />
|
2023-11-22 19:39:19 +01:00
|
|
|
</div>
|
2023-10-07 03:07:32 +02:00
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|