forked from tsai/budibase
3 changed files with 46 additions and 27 deletions
@ -1,33 +1,42 @@ |
|||||
<script> |
<script> |
||||
export let bounds |
import Indicator from "./Indicator.svelte" |
||||
|
|
||||
|
export let dropInfo |
||||
export let mode |
export let mode |
||||
export let zIndex |
export let zIndex |
||||
|
export let color |
||||
|
export let transition |
||||
|
|
||||
$: x = bounds?.left |
$: dimensions = getDimensions(dropInfo?.bounds, mode) |
||||
$: y = getYPos(bounds, mode) |
$: prefix = mode === "above" ? "Above" : "Below" |
||||
$: width = bounds?.width |
$: text = `${prefix} ${dropInfo?.name}` |
||||
$: valid = bounds != null |
|
||||
|
|
||||
const getYPos = (bounds, mode) => { |
const getDimensions = (bounds, mode) => { |
||||
if (!bounds || !mode) { |
if (!bounds || !mode) { |
||||
return null |
return null |
||||
} |
} |
||||
const { top, height } = bounds |
const { left, top, width, height } = bounds |
||||
return mode === "above" ? top - 2 : top + height |
return { |
||||
|
top: mode === "above" ? top - 4 : top + height, |
||||
|
left: left - 2, |
||||
|
width: width + 4, |
||||
|
} |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
{#if valid} |
{#key mode} |
||||
<div |
{#if dimensions} |
||||
class="indicator" |
<Indicator |
||||
style={`top:${y}px;left:${x}px;width:${width}px;z-index:${zIndex};`} |
left={dimensions.left} |
||||
/> |
top={dimensions.top} |
||||
{/if} |
width={dimensions.width} |
||||
|
height={0} |
||||
<style> |
{text} |
||||
.indicator { |
{zIndex} |
||||
position: absolute; |
{color} |
||||
height: 2px; |
{transition} |
||||
background: var(--spectrum-global-color-static-green-500); |
flip={mode === "below"} |
||||
} |
rounded |
||||
</style> |
/> |
||||
|
{/if} |
||||
|
{/key} |
||||
|
|||||
Loading…
Reference in new issue