2020-01-24 12:32:13 +01:00
|
|
|
<script>
|
2020-05-04 10:32:25 +02:00
|
|
|
import { goto } from "@sveltech/routify"
|
2020-05-01 17:39:50 +02:00
|
|
|
import { store } from "builderStore"
|
2020-05-02 16:29:10 +02:00
|
|
|
import { last } from "lodash/fp"
|
2020-05-07 11:53:34 +02:00
|
|
|
import { pipe } from "components/common/core"
|
2020-06-01 11:18:45 +02:00
|
|
|
import ComponentDropdownMenu from "./ComponentDropdownMenu.svelte"
|
2020-02-20 18:11:41 +01:00
|
|
|
import {
|
|
|
|
XCircleIcon,
|
|
|
|
ChevronUpIcon,
|
|
|
|
ChevronDownIcon,
|
|
|
|
CopyIcon,
|
|
|
|
} from "../common/Icons"
|
2020-02-10 16:51:09 +01:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
export let components = []
|
|
|
|
export let currentComponent
|
|
|
|
export let onSelect = () => {}
|
|
|
|
export let level = 0
|
2020-06-01 11:25:12 +02:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
|
2020-02-20 18:11:41 +01:00
|
|
|
const get_name = s => (!s ? "" : last(s.split("/")))
|
2020-02-10 16:51:09 +01:00
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
const get_capitalised_name = name => pipe(name, [get_name, capitalise])
|
2020-02-18 17:51:28 +01:00
|
|
|
|
2020-05-04 10:32:25 +02:00
|
|
|
const selectComponent = component => {
|
|
|
|
// Set current component
|
2020-05-01 17:39:50 +02:00
|
|
|
store.selectComponent(component)
|
2020-05-04 10:32:25 +02:00
|
|
|
|
|
|
|
// Get ID path
|
|
|
|
const path = store.getPathToComponent(component)
|
|
|
|
|
|
|
|
// Go to correct URL
|
|
|
|
$goto(`./:page/:screen/${path}`)
|
2020-05-01 17:39:50 +02:00
|
|
|
}
|
2020-01-24 12:32:13 +01:00
|
|
|
</script>
|
|
|
|
|
2020-01-28 22:17:04 +01:00
|
|
|
<ul>
|
2020-02-19 11:17:31 +01:00
|
|
|
{#each components as component, index (component._id)}
|
2020-05-04 10:32:25 +02:00
|
|
|
<li on:click|stopPropagation={() => selectComponent(component)}>
|
2020-02-19 11:17:31 +01:00
|
|
|
<div
|
2020-02-24 16:00:48 +01:00
|
|
|
class="budibase__nav-item item"
|
2020-02-03 10:50:30 +01:00
|
|
|
class:selected={currentComponent === component}
|
2020-02-21 12:09:37 +01:00
|
|
|
style="padding-left: {level * 20 + 53}px">
|
2020-06-01 22:34:03 +02:00
|
|
|
<div class="nav-item">
|
|
|
|
<i class="icon ri-arrow-right-circle-fill" />
|
|
|
|
{get_capitalised_name(component._component)}
|
|
|
|
</div>
|
2020-06-01 11:18:45 +02:00
|
|
|
<div class="actions">
|
2020-06-01 13:15:44 +02:00
|
|
|
<ComponentDropdownMenu {component} />
|
2020-02-19 11:17:31 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-24 12:32:13 +01:00
|
|
|
|
|
|
|
{#if component._children}
|
2020-02-03 10:50:30 +01:00
|
|
|
<svelte:self
|
|
|
|
components={component._children}
|
|
|
|
{currentComponent}
|
|
|
|
{onSelect}
|
2020-06-01 11:25:12 +02:00
|
|
|
level={level + 1} />
|
2020-01-24 12:32:13 +01:00
|
|
|
{/if}
|
|
|
|
</li>
|
2020-01-28 22:17:04 +01:00
|
|
|
{/each}
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
ul {
|
|
|
|
list-style: none;
|
|
|
|
padding-left: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
2020-02-19 11:17:31 +01:00
|
|
|
|
2020-01-28 22:17:04 +01:00
|
|
|
.item {
|
2020-02-19 15:12:24 +01:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr auto auto auto;
|
2020-02-20 18:09:35 +01:00
|
|
|
padding: 0px 5px 0px 15px;
|
2020-02-19 11:17:31 +01:00
|
|
|
margin: auto 0px;
|
2020-01-28 22:17:04 +01:00
|
|
|
border-radius: 3px;
|
2020-02-20 18:11:41 +01:00
|
|
|
height: 35px;
|
2020-02-19 11:17:31 +01:00
|
|
|
align-items: center;
|
2020-01-28 22:17:04 +01:00
|
|
|
}
|
2020-02-18 17:51:28 +01:00
|
|
|
|
2020-06-01 11:18:45 +02:00
|
|
|
.actions {
|
2020-02-18 17:51:28 +01:00
|
|
|
display: none;
|
2020-06-01 16:31:55 +02:00
|
|
|
height: 24px;
|
|
|
|
width: 24px;
|
|
|
|
color: var(--ink);
|
2020-02-19 11:17:31 +01:00
|
|
|
padding: 0px 5px;
|
2020-02-21 12:09:37 +01:00
|
|
|
border-style: none;
|
|
|
|
background: rgba(0, 0, 0, 0);
|
|
|
|
cursor: pointer;
|
2020-06-01 11:18:45 +02:00
|
|
|
position: relative;
|
2020-02-18 17:51:28 +01:00
|
|
|
}
|
|
|
|
|
2020-01-28 22:17:04 +01:00
|
|
|
.item:hover {
|
2020-06-01 16:31:55 +02:00
|
|
|
background: var(--grey-light);
|
2020-01-28 22:17:04 +01:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
2020-06-01 11:18:45 +02:00
|
|
|
.item:hover .actions {
|
2020-02-18 17:51:28 +01:00
|
|
|
display: block;
|
|
|
|
}
|
2020-06-01 22:18:25 +02:00
|
|
|
|
|
|
|
.nav-item {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 14px;
|
|
|
|
color: var(--ink);
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
color: var(--ink-light);
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
2020-01-28 22:17:04 +01:00
|
|
|
</style>
|