2021-09-16 15:28:44 +02:00
|
|
|
<script>
|
2021-09-16 16:08:42 +02:00
|
|
|
import Indicator from "./Indicator.svelte"
|
|
|
|
|
2021-09-16 16:49:58 +02:00
|
|
|
export let componentId
|
2021-09-16 16:08:42 +02:00
|
|
|
export let dropInfo
|
2021-09-16 15:28:44 +02:00
|
|
|
export let mode
|
|
|
|
export let zIndex
|
2021-09-16 16:08:42 +02:00
|
|
|
export let color
|
|
|
|
export let transition
|
2021-09-16 15:28:44 +02:00
|
|
|
|
2021-09-16 16:08:42 +02:00
|
|
|
$: dimensions = getDimensions(dropInfo?.bounds, mode)
|
|
|
|
$: prefix = mode === "above" ? "Above" : "Below"
|
|
|
|
$: text = `${prefix} ${dropInfo?.name}`
|
2021-09-16 15:28:44 +02:00
|
|
|
|
2021-09-16 16:08:42 +02:00
|
|
|
const getDimensions = (bounds, mode) => {
|
2021-09-16 15:28:44 +02:00
|
|
|
if (!bounds || !mode) {
|
|
|
|
return null
|
|
|
|
}
|
2021-09-16 16:08:42 +02:00
|
|
|
const { left, top, width, height } = bounds
|
|
|
|
return {
|
|
|
|
top: mode === "above" ? top - 4 : top + height,
|
|
|
|
left: left - 2,
|
|
|
|
width: width + 4,
|
|
|
|
}
|
2021-09-16 15:28:44 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-09-16 16:49:58 +02:00
|
|
|
{#key `${componentId}-${mode}`}
|
|
|
|
{#if dimensions && mode !== "inside"}
|
2021-09-16 16:08:42 +02:00
|
|
|
<Indicator
|
|
|
|
left={dimensions.left}
|
|
|
|
top={dimensions.top}
|
|
|
|
width={dimensions.width}
|
|
|
|
height={0}
|
|
|
|
{text}
|
|
|
|
{zIndex}
|
|
|
|
{color}
|
|
|
|
{transition}
|
2021-09-16 17:02:45 +02:00
|
|
|
line
|
2021-09-16 16:08:42 +02:00
|
|
|
/>
|
|
|
|
{/if}
|
|
|
|
{/key}
|