2020-01-18 00:06:42 +01:00
|
|
|
<script>
|
2020-05-29 15:56:21 +02:00
|
|
|
import { goto } from "@sveltech/routify"
|
2020-10-14 17:47:53 +02:00
|
|
|
import { store } from "builderStore"
|
2020-04-17 09:16:03 +02:00
|
|
|
import components from "./temporaryPanelStructure.js"
|
2020-05-04 17:07:04 +02:00
|
|
|
import CategoryTab from "./CategoryTab.svelte"
|
2020-10-21 10:19:26 +02:00
|
|
|
import { Popover } from "@budibase/bbui"
|
|
|
|
import { fade, fly } from "svelte/transition"
|
2020-04-21 15:20:57 +02:00
|
|
|
|
2020-04-22 08:25:59 +02:00
|
|
|
import Tab from "./ItemTab/Tab.svelte"
|
2020-04-17 09:16:03 +02:00
|
|
|
|
|
|
|
const categories = components.categories
|
2020-10-21 10:19:26 +02:00
|
|
|
let selectedIndex
|
|
|
|
let width
|
|
|
|
$: selectedCategory = selectedIndex == null ? null : categories[selectedIndex]
|
|
|
|
|
|
|
|
const close = () => {
|
|
|
|
selectedIndex = null
|
|
|
|
}
|
2020-04-21 15:20:57 +02:00
|
|
|
|
2020-04-22 08:25:59 +02:00
|
|
|
const onComponentChosen = component => {
|
2020-07-26 12:54:55 +02:00
|
|
|
store.addChildComponent(component._component, component.presetProps)
|
2020-05-29 19:32:52 +02:00
|
|
|
|
2020-05-29 15:56:21 +02:00
|
|
|
// Get ID path
|
|
|
|
const path = store.getPathToComponent($store.currentComponentInfo)
|
|
|
|
|
|
|
|
// Go to correct URL
|
|
|
|
$goto(`./:page/:screen/${path}`)
|
2020-10-21 10:19:26 +02:00
|
|
|
close()
|
2020-04-22 08:25:59 +02:00
|
|
|
}
|
2020-01-18 00:06:42 +01:00
|
|
|
</script>
|
|
|
|
|
2020-10-21 10:19:26 +02:00
|
|
|
<div class="wrapper">
|
|
|
|
<div
|
|
|
|
class="container"
|
|
|
|
bind:clientWidth={width}
|
|
|
|
class:border={selectedCategory == null}>
|
|
|
|
{#each categories as category, idx}
|
|
|
|
<div
|
|
|
|
class="category"
|
|
|
|
on:click={() => (selectedIndex = idx)}
|
|
|
|
class:active={selectedCategory === category}>
|
|
|
|
{category.name}
|
|
|
|
<i class="ri-arrow-down-s-line" />
|
|
|
|
</div>
|
|
|
|
{/each}
|
2020-02-19 22:38:21 +01:00
|
|
|
</div>
|
2020-10-21 10:19:26 +02:00
|
|
|
{#if selectedCategory != null}
|
|
|
|
<div class="overlay" on:click={close} />
|
|
|
|
<div class="dropdown" transition:fly={{ y: -120 }}>
|
|
|
|
<Tab
|
|
|
|
list={selectedCategory}
|
|
|
|
on:selectItem={e => onComponentChosen(e.detail)} />
|
|
|
|
</div>
|
|
|
|
{/if}
|
2020-01-18 00:06:42 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2020-10-21 10:19:26 +02:00
|
|
|
.wrapper {
|
|
|
|
position: relative;
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.container {
|
|
|
|
padding: var(--spacing-xl) 40px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
background-color: white;
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
.container.border {
|
|
|
|
border-bottom: 1px solid var(--grey-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
.category {
|
|
|
|
color: var(--ink);
|
|
|
|
cursor: pointer;
|
|
|
|
margin-right: var(--spacing-xl);
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
gap: var(--spacing-xs);
|
|
|
|
font-size: var(--font-size-s);
|
|
|
|
font-weight: 500;
|
|
|
|
}
|
|
|
|
.category.active,
|
|
|
|
.category:hover {
|
|
|
|
color: var(--blue);
|
|
|
|
}
|
|
|
|
|
|
|
|
.overlay {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: -2;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dropdown {
|
|
|
|
position: absolute;
|
|
|
|
z-index: -1;
|
|
|
|
top: calc(100% - var(--spacing-xl));
|
|
|
|
left: 0;
|
|
|
|
width: calc(100% - 80px);
|
|
|
|
background-color: white;
|
|
|
|
padding: var(--spacing-xl) 40px;
|
|
|
|
border-bottom: 1px solid var(--grey-2);
|
|
|
|
box-shadow: 0 0 8px 4px rgba(0, 0, 0, 0.05);
|
2020-04-17 09:16:03 +02:00
|
|
|
}
|
2020-01-18 00:06:42 +01:00
|
|
|
</style>
|