budibase/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte

76 lines
1.8 KiB
Svelte
Raw Normal View History

<script>
import { onMount } from "svelte"
import { goto, isActive, leftover, url } from "@sveltech/routify"
import { store, currentAsset } from "builderStore"
import { FrontendTypes } from "constants"
import api from "builderStore/api"
2020-11-19 17:41:29 +01:00
import ComponentNavigationTree from "components/userInterface/ComponentNavigationTree/index.svelte"
import Layout from "components/userInterface/Layout.svelte"
import LayoutsList from "components/userInterface/LayoutsList.svelte"
2020-10-08 10:35:11 +02:00
import NewScreenModal from "components/userInterface/NewScreenModal.svelte"
import { Modal, Switcher, Button, Spacer } from "@budibase/bbui"
2020-05-29 19:32:52 +02:00
const tabs = [
{
title: "Screens",
2020-12-02 14:41:00 +01:00
key: "screens",
},
{
title: "Layouts",
2020-12-02 14:41:00 +01:00
key: "layouts",
},
]
let modal
let routes = {}
2020-12-02 14:41:00 +01:00
let tab = "screens"
function navigate({ detail }) {
2020-12-02 14:41:00 +01:00
if (!detail) return
$goto(`./${detail.heading.key}`)
}
onMount(() => {
2020-11-19 22:07:25 +01:00
store.actions.routing.fetch()
})
</script>
<div class="title">
<Switcher headings={tabs} bind:value={tab} on:change={navigate}>
2020-12-02 14:41:00 +01:00
{#if tab === 'screens'}
<i
on:click={modal.show}
data-cy="new-screen"
class="ri-add-circle-fill" />
{#if $currentAsset}
<div class="nav-items-container">
<ComponentNavigationTree />
</div>
{/if}
<Modal bind:this={modal}>
<NewScreenModal />
</Modal>
2020-12-02 14:41:00 +01:00
{:else if tab === 'layouts'}
2020-12-02 15:49:43 +01:00
{#each $store.layouts as layout}
<Layout {layout} />
{/each}
{/if}
</Switcher>
</div>
<style>
.title {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.title i {
font-size: 20px;
}
.title i:hover {
cursor: pointer;
color: var(--blue);
}
</style>