2020-10-22 18:42:03 +02:00
|
|
|
<script>
|
2021-04-23 11:18:34 +02:00
|
|
|
import { Icon } from "@budibase/bbui"
|
2021-07-29 11:22:45 +02:00
|
|
|
import { createEventDispatcher } from "svelte"
|
2021-04-23 11:18:34 +02:00
|
|
|
|
2020-10-22 18:42:03 +02:00
|
|
|
export let icon
|
|
|
|
export let withArrow = false
|
|
|
|
export let withActions = true
|
|
|
|
export let indentLevel = 0
|
|
|
|
export let text
|
|
|
|
export let border = true
|
|
|
|
export let selected = false
|
|
|
|
export let opened = false
|
|
|
|
export let draggable = false
|
2021-12-09 14:08:16 +01:00
|
|
|
export let iconText
|
|
|
|
export let iconColor
|
2021-07-29 11:22:45 +02:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
2022-03-18 20:52:11 +01:00
|
|
|
let textRef
|
2021-07-29 11:22:45 +02:00
|
|
|
|
|
|
|
function onIconClick(event) {
|
|
|
|
event.stopPropagation()
|
|
|
|
dispatch("iconClick")
|
|
|
|
}
|
2020-10-22 18:42:03 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div
|
2020-10-27 16:26:07 +01:00
|
|
|
class="nav-item"
|
2020-10-22 18:42:03 +02:00
|
|
|
class:border
|
|
|
|
class:selected
|
2022-03-18 20:52:11 +01:00
|
|
|
style={`padding-left: ${20 + indentLevel * 14}px`}
|
2020-10-22 18:42:03 +02:00
|
|
|
{draggable}
|
|
|
|
on:dragend
|
|
|
|
on:dragstart
|
|
|
|
on:dragover
|
|
|
|
on:drop
|
|
|
|
on:click
|
2022-03-18 20:52:11 +01:00
|
|
|
on:mouseover={() => {
|
|
|
|
const size = textRef.getBoundingClientRect()
|
|
|
|
dispatch("mouseover", size.width)
|
|
|
|
}}
|
2020-10-22 18:42:03 +02:00
|
|
|
ondragover="return false"
|
2021-04-23 11:18:34 +02:00
|
|
|
ondragenter="return false"
|
|
|
|
>
|
2022-03-18 20:52:11 +01:00
|
|
|
{#if withArrow}
|
|
|
|
<div class:opened class="icon arrow" on:click={onIconClick}>
|
|
|
|
<Icon size="S" name="ChevronRight" />
|
|
|
|
</div>
|
|
|
|
{/if}
|
2021-01-12 17:49:11 +01:00
|
|
|
|
2022-03-18 20:52:11 +01:00
|
|
|
<slot name="icon" />
|
|
|
|
{#if iconText}
|
|
|
|
<div class="iconText" style={iconColor ? `color: ${iconColor};` : ""}>
|
|
|
|
{iconText}
|
|
|
|
</div>
|
|
|
|
{:else if icon}
|
|
|
|
<div class="icon">
|
|
|
|
<Icon color={iconColor} size="S" name={icon} />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
<div class="text" bind:this={textRef}>{text}</div>
|
|
|
|
{#if withActions}
|
|
|
|
<div class="actions">
|
|
|
|
<slot />
|
|
|
|
</div>
|
|
|
|
{/if}
|
2020-10-22 18:42:03 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2020-10-27 16:26:07 +01:00
|
|
|
.nav-item {
|
2020-10-22 18:42:03 +02:00
|
|
|
cursor: pointer;
|
|
|
|
color: var(--grey-7);
|
2021-04-13 19:07:45 +02:00
|
|
|
transition: background-color
|
|
|
|
var(--spectrum-global-animation-duration-100, 130ms) ease-in-out;
|
2022-03-18 20:52:11 +01:00
|
|
|
padding: 0 var(--spacing-m) 0 var(--spacing-xl);
|
|
|
|
height: 32px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
gap: var(--spacing-xs);
|
|
|
|
width: calc(max-content - 64px);
|
2020-10-22 18:42:03 +02:00
|
|
|
}
|
2020-10-27 16:26:07 +01:00
|
|
|
.nav-item.selected {
|
2020-10-22 18:42:03 +02:00
|
|
|
background-color: var(--grey-2);
|
|
|
|
color: var(--ink);
|
|
|
|
}
|
2020-10-27 16:26:07 +01:00
|
|
|
.nav-item:hover {
|
2021-04-13 19:07:45 +02:00
|
|
|
background-color: var(--grey-3);
|
2020-10-22 18:42:03 +02:00
|
|
|
}
|
2020-10-27 16:26:07 +01:00
|
|
|
.nav-item:hover .actions {
|
2021-02-06 21:32:44 +01:00
|
|
|
visibility: visible;
|
2020-10-22 18:42:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
font-size: 16px;
|
|
|
|
flex: 0 0 20px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
.icon.arrow {
|
|
|
|
margin: 0 -2px 0 -6px;
|
2020-10-22 21:22:09 +02:00
|
|
|
font-size: 12px;
|
2020-10-22 18:42:03 +02:00
|
|
|
}
|
|
|
|
.icon.arrow.opened {
|
|
|
|
transform: rotate(90deg);
|
|
|
|
}
|
|
|
|
.icon + .icon {
|
|
|
|
margin-left: -4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text {
|
2021-05-25 11:11:41 +02:00
|
|
|
font-weight: 600;
|
2021-04-23 11:48:19 +02:00
|
|
|
font-size: var(--spectrum-global-dimension-font-size-75);
|
2022-03-18 20:52:11 +01:00
|
|
|
white-space: nowrap;
|
|
|
|
max-width: 180px;
|
2020-11-05 12:48:49 +01:00
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2020-10-22 18:42:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.actions {
|
2021-02-06 21:32:44 +01:00
|
|
|
visibility: hidden;
|
2020-10-22 18:42:03 +02:00
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
cursor: pointer;
|
|
|
|
position: relative;
|
2022-03-21 10:57:55 +01:00
|
|
|
display: grid;
|
2022-03-18 20:52:11 +01:00
|
|
|
margin-left: var(--spacing-s);
|
2022-03-21 10:57:55 +01:00
|
|
|
place-items: center;
|
2020-10-22 18:42:03 +02:00
|
|
|
}
|
2021-12-09 14:08:16 +01:00
|
|
|
|
|
|
|
.iconText {
|
|
|
|
margin-top: 1px;
|
|
|
|
font-size: var(--spectrum-global-dimension-font-size-50);
|
2021-12-16 12:56:14 +01:00
|
|
|
flex: 0 0 34px;
|
2021-12-09 14:08:16 +01:00
|
|
|
}
|
2020-10-22 18:42:03 +02:00
|
|
|
</style>
|