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

97 lines
2.2 KiB
Svelte
Raw Normal View History

2020-05-04 17:07:04 +02:00
<script>
import {onMount} from "svelte"
2020-05-04 17:07:04 +02:00
import PropertyGroup from "./PropertyGroup.svelte"
2020-05-07 15:30:04 +02:00
import FlatButtonGroup from "./FlatButtonGroup.svelte"
2020-05-05 11:02:10 +02:00
2020-05-04 17:07:04 +02:00
export let panelDefinition = {}
export let componentInstance = {}
export let componentDefinition = {}
2020-05-18 17:32:00 +02:00
export let onStyleChanged = () => {}
2020-05-22 16:30:29 +02:00
let selectedCategory = "normal"
let propGroup = null
let currentGroup
2020-05-07 15:30:04 +02:00
2020-05-18 17:32:00 +02:00
const getProperties = name => panelDefinition[name]
2020-05-04 17:07:04 +02:00
onMount(() => {
// if(propGroup) {
// propGroup.addEventListener("scroll", function(e){
// console.log("I SCROLLED", e.target.scrollTop)
// })
// }
})
2020-05-07 15:30:04 +02:00
function onChange(category) {
selectedCategory = category
}
const buttonProps = [
2020-05-22 16:30:29 +02:00
{ value: "normal", text: "Normal" },
2020-05-07 15:30:04 +02:00
{ value: "hover", text: "Hover" },
{ value: "active", text: "Active" },
]
2020-05-18 17:32:00 +02:00
$: propertyGroupNames = Object.keys(panelDefinition)
2020-05-04 17:07:04 +02:00
</script>
2020-05-07 15:30:04 +02:00
<div class="design-view-container">
<div class="design-view-state-categories">
<FlatButtonGroup value={selectedCategory} {buttonProps} {onChange} />
</div>
2020-06-24 16:41:33 +02:00
<div class="positioned-wrapper">
<div bind:this={propGroup} class="design-view-property-groups">
2020-06-24 16:41:33 +02:00
{#if propertyGroupNames.length > 0}
{#each propertyGroupNames as groupName}
<PropertyGroup
name={groupName}
properties={getProperties(groupName)}
styleCategory={selectedCategory}
{onStyleChanged}
{componentDefinition}
{componentInstance}
open={currentGroup === groupName}
on:open={() => currentGroup = groupName} />
2020-06-24 16:41:33 +02:00
{/each}
{:else}
<div class="no-design">
<span>This component does not have any design properties</span>
</div>
{/if}
</div>
2020-05-07 15:30:04 +02:00
</div>
</div>
<style>
.design-view-container {
display: flex;
flex-direction: column;
width: 100%;
2020-05-28 17:24:53 +02:00
height: 100%;
2020-05-07 15:30:04 +02:00
}
.design-view-state-categories {
flex: 0 0 50px;
}
2020-06-24 16:41:33 +02:00
.positioned-wrapper {
2020-06-17 17:46:03 +02:00
position: relative;
display: flex;
min-height: 0;
}
2020-05-07 15:30:04 +02:00
.design-view-property-groups {
flex: 1;
2020-06-01 18:14:54 +02:00
overflow-y: auto;
min-height: 0;
2020-05-07 15:30:04 +02:00
}
2020-05-20 12:55:25 +02:00
.no-design {
text-align: center;
}
2020-05-07 15:30:04 +02:00
</style>