|
|
|
@ -2,23 +2,24 @@ |
|
|
|
import { goto } from "@sveltech/routify" |
|
|
|
import { store } from "builderStore" |
|
|
|
import components from "./temporaryPanelStructure.js" |
|
|
|
import CategoryTab from "./CategoryTab.svelte" |
|
|
|
import { Popover } from "@budibase/bbui" |
|
|
|
import { fade, fly } from "svelte/transition" |
|
|
|
|
|
|
|
import { DropdownMenu } from "@budibase/bbui" |
|
|
|
import Tab from "./ItemTab/Tab.svelte" |
|
|
|
|
|
|
|
const categories = components.categories |
|
|
|
let selectedCategory |
|
|
|
let width |
|
|
|
let selectedIndex |
|
|
|
let anchors = [] |
|
|
|
let popover |
|
|
|
$: anchor = selectedIndex === -1 ? null : anchors[selectedIndex] |
|
|
|
|
|
|
|
const close = () => { |
|
|
|
selectedCategory = null |
|
|
|
selectedIndex = null |
|
|
|
popover.hide() |
|
|
|
} |
|
|
|
|
|
|
|
const onCategoryChosen = (category) => { |
|
|
|
const onCategoryChosen = (category, idx) => { |
|
|
|
if (category.isCategory) { |
|
|
|
selectedCategory = selectedCategory === category ? null : category |
|
|
|
selectedIndex = idx |
|
|
|
popover.show() |
|
|
|
} else { |
|
|
|
onComponentChosen(category) |
|
|
|
} |
|
|
|
@ -26,60 +27,38 @@ |
|
|
|
|
|
|
|
const onComponentChosen = (component) => { |
|
|
|
store.addChildComponent(component._component, component.presetProps) |
|
|
|
|
|
|
|
// Get ID path |
|
|
|
const path = store.getPathToComponent($store.currentComponentInfo) |
|
|
|
|
|
|
|
// Go to correct URL |
|
|
|
$goto(`./:page/:screen/${path}`) |
|
|
|
close() |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<div class="wrapper"> |
|
|
|
<div |
|
|
|
class="container" |
|
|
|
bind:clientWidth={width} |
|
|
|
class:open={selectedCategory != null}> |
|
|
|
{#each categories as category, idx} |
|
|
|
<div |
|
|
|
class="category" |
|
|
|
on:click={() => onCategoryChosen(category)} |
|
|
|
class:active={selectedCategory === category}> |
|
|
|
{#if category.icon}<i class={category.icon} />{/if} |
|
|
|
<span>{category.name}</span> |
|
|
|
{#if category.isCategory}<i class="ri-arrow-down-s-line arrow" />{/if} |
|
|
|
</div> |
|
|
|
{/each} |
|
|
|
</div> |
|
|
|
{#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 class="container"> |
|
|
|
{#each categories as category, idx} |
|
|
|
<div |
|
|
|
bind:this={anchors[idx]} |
|
|
|
class="category" |
|
|
|
on:click={() => onCategoryChosen(category, idx)}> |
|
|
|
{#if category.icon}<i class={category.icon} />{/if} |
|
|
|
<span>{category.name}</span> |
|
|
|
{#if category.isCategory}<i class="ri-arrow-down-s-line arrow" />{/if} |
|
|
|
</div> |
|
|
|
{/if} |
|
|
|
{/each} |
|
|
|
</div> |
|
|
|
<DropdownMenu bind:this={popover} {anchor} align="left"> |
|
|
|
<Tab |
|
|
|
list={categories[selectedIndex]} |
|
|
|
on:selectItem={(e) => onComponentChosen(e.detail)} /> |
|
|
|
</DropdownMenu> |
|
|
|
|
|
|
|
<style> |
|
|
|
.wrapper { |
|
|
|
position: relative; |
|
|
|
z-index: 1; |
|
|
|
} |
|
|
|
|
|
|
|
.container { |
|
|
|
padding: var(--spacing-l) 40px; |
|
|
|
display: flex; |
|
|
|
flex-direction: row; |
|
|
|
justify-content: flex-start; |
|
|
|
align-items: center; |
|
|
|
background-color: white; |
|
|
|
z-index: 1; |
|
|
|
width: calc(100% - 80px); |
|
|
|
overflow: hidden; |
|
|
|
} |
|
|
|
.container.open { |
|
|
|
height: 24px; |
|
|
|
} |
|
|
|
|
|
|
|
.category { |
|
|
|
@ -97,31 +76,10 @@ |
|
|
|
font-weight: 500; |
|
|
|
user-select: none; |
|
|
|
} |
|
|
|
.category.active, |
|
|
|
.category:hover { |
|
|
|
color: var(--ink); |
|
|
|
} |
|
|
|
.category i:not(:last-child) { |
|
|
|
font-size: 16px; |
|
|
|
} |
|
|
|
|
|
|
|
.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; |
|
|
|
box-shadow: 0 0 8px 4px rgba(0, 0, 0, 0.05); |
|
|
|
} |
|
|
|
</style> |
|
|
|
|