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

49 lines
1.0 KiB
Svelte
Raw Normal View History

<script>
import { goto } from "@sveltech/routify"
import { store } from "builderStore"
import components from "./temporaryPanelStructure.js"
2020-05-04 17:07:04 +02:00
import CategoryTab from "./CategoryTab.svelte"
import Tab from "./ItemTab/Tab.svelte"
export let toggleTab
const categories = components.categories
let selectedCategory = categories[0]
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
toggleTab("Navigate")
2020-05-29 19:32:52 +02:00
// Get ID path
const path = store.getPathToComponent($store.currentComponentInfo)
// Go to correct URL
$goto(`./:page/:screen/${path}`)
}
</script>
<div class="root">
2020-05-04 17:07:04 +02:00
<CategoryTab
onClick={category => (selectedCategory = category)}
{selectedCategory}
{categories} />
<div class="panel">
<Tab
list={selectedCategory}
on:selectItem={e => onComponentChosen(e.detail)}
{toggleTab} />
2020-02-19 22:38:21 +01:00
</div>
</div>
<style>
.panel {
margin-top: 20px;
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
}
</style>