budibase/packages/builder/src/userInterface/ComponentsPaneSwitcher.svelte

92 lines
1.9 KiB
Svelte
Raw Normal View History

<script>
import { store } from "../builderStore/"
import ComponentPropertiesPanel from "./ComponentPropertiesPanel.svelte"
import ComponentSelectionList from "./ComponentSelectionList.svelte"
2020-02-25 16:21:23 +01:00
const PROPERTIES_TAB = "properties"
const COMPONENT_SELECTION_TAB = "components"
2020-02-25 00:23:33 +01:00
2020-02-25 16:21:23 +01:00
let selected = PROPERTIES_TAB
2020-02-03 10:50:30 +01:00
const isSelected = tab => selected === tab
2020-02-03 10:50:30 +01:00
const selectTab = tab => (selected = tab)
2020-02-25 00:23:33 +01:00
2020-02-25 16:21:23 +01:00
const toggleTab = () =>
(selected =
selected === PROPERTIES_TAB ? COMPONENT_SELECTION_TAB : PROPERTIES_TAB)
</script>
<div class="root">
{#if $store.currentFrontEndType === 'page' || $store.screens.length}
<div class="switcher">
<button
2020-02-25 00:23:33 +01:00
class:selected={selected === COMPONENT_SELECTION_TAB}
on:click={() => selectTab(COMPONENT_SELECTION_TAB)}>
Components
</button>
2020-02-26 17:36:30 +01:00
<button
class:selected={selected === PROPERTIES_TAB}
on:click={() => selectTab(PROPERTIES_TAB)}>
Properties
</button>
</div>
<div class="panel">
2020-02-25 00:23:33 +01:00
{#if selected === PROPERTIES_TAB}
<ComponentPropertiesPanel {toggleTab} />
{/if}
2020-02-25 00:23:33 +01:00
{#if selected === COMPONENT_SELECTION_TAB}
<ComponentSelectionList {toggleTab} />
{/if}
</div>
{/if}
</div>
<style>
2020-02-03 10:50:30 +01:00
.root {
height: 100%;
display: flex;
flex-direction: column;
2020-03-17 10:57:18 +01:00
padding: 20px 0;
2020-02-03 10:50:30 +01:00
}
2020-02-03 10:50:30 +01:00
.switcher {
display: flex;
justify-content: space-between;
2020-03-17 10:57:18 +01:00
margin-bottom: 20px;
padding: 0 20px 20px;
border-bottom: 1px solid #d8d8d8;
2020-02-03 10:50:30 +01:00
}
2020-02-03 10:50:30 +01:00
.switcher > button {
display: inline-block;
border: none;
2020-01-21 15:50:35 +01:00
margin: 0;
padding: 0;
cursor: pointer;
font-size: 0.85rem;
2020-03-17 10:57:18 +01:00
font-weight: 400;
text-transform: uppercase;
2020-03-17 10:57:18 +01:00
color: var(--secondary60);
2020-02-03 10:50:30 +01:00
}
2020-02-03 10:50:30 +01:00
.switcher > .selected {
2020-03-17 10:57:18 +01:00
color: var(--secondary100);
font-weight: 500;
2020-02-03 10:50:30 +01:00
}
2020-02-03 10:50:30 +01:00
.panel {
flex: 1 1 auto;
height: 0px;
overflow-y: auto;
padding: 0 20px 40px 20px;
2020-02-03 10:50:30 +01:00
}
</style>