1
0
Fork 0
mirror of synced 2024-09-14 00:08:25 +12:00
budibase/packages/builder/src/components/common/NavItem.svelte

119 lines
2.2 KiB
Svelte
Raw Normal View History

<script>
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
</script>
<div
2020-10-28 04:26:07 +13:00
class="nav-item"
class:border
class:selected
style={`padding-left: ${indentLevel * 14}px`}
{draggable}
on:dragend
on:dragstart
on:dragover
on:drop
on:click
ondragover="return false"
ondragenter="return false">
<div class="content">
{#if withArrow}
<div class:opened class="icon arrow">
<i class="ri-arrow-right-s-line" />
</div>
{/if}
2021-01-13 05:49:11 +13:00
<slot name="icon" />
{#if icon}
2021-01-16 02:42:55 +13:00
<div class="icon"><i class={icon} /></div>
{/if}
<div class="text">{text}</div>
{#if withActions}
<div class="actions">
<slot />
</div>
{/if}
</div>
</div>
<style>
2020-10-28 04:26:07 +13:00
.nav-item {
cursor: pointer;
color: var(--grey-7);
}
2020-10-28 04:26:07 +13:00
.nav-item.border {
border-top: 1px solid var(--grey-1);
}
2020-10-28 04:26:07 +13:00
.nav-item.selected {
background-color: var(--grey-2);
color: var(--ink);
}
2020-10-28 04:26:07 +13:00
.nav-item:hover {
background-color: var(--grey-1);
}
2020-10-28 04:26:07 +13:00
.nav-item:hover .actions {
display: flex;
2021-02-07 09:32:44 +13:00
visibility: visible;
}
2020-10-30 09:42:34 +13:00
.nav-item:hover,
.nav-item.selected {
border-radius: var(--border-radius-s);
2020-10-30 09:42:34 +13:00
}
.content {
padding: 0 var(--spacing-s);
height: 32px;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: var(--spacing-xs);
}
.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;
font-size: 12px;
}
.icon.arrow.opened {
transform: rotate(90deg);
}
.icon + .icon {
margin-left: -4px;
}
.text {
flex: 1 1 auto;
font-weight: 500;
font-size: var(--font-size-xs);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.actions {
2021-02-07 09:32:44 +13:00
visibility: hidden;
width: 20px;
height: 20px;
cursor: pointer;
position: relative;
flex-direction: row;
justify-content: center;
align-items: center;
}
</style>