2020-05-04 17:07:04 +02:00
|
|
|
<script>
|
2020-07-02 12:03:15 +02:00
|
|
|
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-05 15:45:52 +02:00
|
|
|
|
2020-05-22 16:30:29 +02:00
|
|
|
let selectedCategory = "normal"
|
2020-06-27 17:56:01 +02:00
|
|
|
let propGroup = null
|
2020-06-29 18:20:35 +02:00
|
|
|
let currentGroup
|
2020-05-07 15:30:04 +02:00
|
|
|
|
2020-10-22 18:47:49 +02:00
|
|
|
const getProperties = (name) => panelDefinition[name]
|
2020-05-04 17:07:04 +02:00
|
|
|
|
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-07-26 12:54:55 +02:00
|
|
|
$: propertyGroupNames = panelDefinition ? 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">
|
2020-06-27 17:56:01 +02:00
|
|
|
<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}
|
2020-06-29 18:20:35 +02:00
|
|
|
{componentInstance}
|
|
|
|
open={currentGroup === groupName}
|
2020-07-02 12:03:15 +02:00
|
|
|
on:open={() => (currentGroup = groupName)} />
|
2020-06-24 16:41:33 +02:00
|
|
|
{/each}
|
|
|
|
{:else}
|
|
|
|
<div class="no-design">
|
2020-10-12 16:12:48 +02:00
|
|
|
This component does not have any design properties.
|
2020-06-24 16:41:33 +02:00
|
|
|
</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-10-22 18:47:49 +02:00
|
|
|
gap: var(--spacing-m);
|
2020-05-07 15:30:04 +02:00
|
|
|
}
|
2020-10-22 21:48:46 +02:00
|
|
|
.design-view-container :global(.property-group-name .name) {
|
|
|
|
font-size: var(--font-size-xs);
|
|
|
|
}
|
|
|
|
.design-view-container :global(.property-group-container) {
|
|
|
|
padding: 4px 0;
|
|
|
|
}
|
2020-05-07 15:30:04 +02:00
|
|
|
|
|
|
|
.design-view-state-categories {
|
|
|
|
}
|
|
|
|
|
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;
|
2020-06-02 13:47:40 +02:00
|
|
|
min-height: 0;
|
2020-10-12 16:12:48 +02:00
|
|
|
margin: 0 -20px;
|
|
|
|
padding: 0 20px;
|
2020-05-07 15:30:04 +02:00
|
|
|
}
|
2020-05-20 12:55:25 +02:00
|
|
|
|
|
|
|
.no-design {
|
2020-10-12 16:12:48 +02:00
|
|
|
font-size: var(--font-size-s);
|
|
|
|
color: var(--grey-6);
|
2020-05-20 12:55:25 +02:00
|
|
|
}
|
2020-05-07 15:30:04 +02:00
|
|
|
</style>
|