2020-05-04 17:07:04 +02:00
|
|
|
<script>
|
2020-05-05 15:45:52 +02:00
|
|
|
import { excludeProps } from "./propertyCategories.js"
|
2020-05-05 11:02:10 +02:00
|
|
|
export let name = ""
|
|
|
|
export let properties = {}
|
2020-05-04 17:07:04 +02:00
|
|
|
export let componentInstance = {}
|
|
|
|
export let componentDefinition = {}
|
2020-05-05 15:45:52 +02:00
|
|
|
export let onPropChanged = () => {}
|
2020-05-04 17:07:04 +02:00
|
|
|
|
2020-05-05 15:45:52 +02:00
|
|
|
let show = true
|
2020-05-04 17:07:04 +02:00
|
|
|
|
|
|
|
const propExistsOnComponentDef = prop => prop in componentDefinition.props
|
2020-05-05 11:02:10 +02:00
|
|
|
const capitalize = name => name[0].toUpperCase() + name.slice(1)
|
2020-05-04 17:07:04 +02:00
|
|
|
|
2020-05-05 15:45:52 +02:00
|
|
|
function onChange(v) {
|
|
|
|
!!v.target ? onPropChanged(v.target.value) : onPropChanged(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
$: propertyDefinition = Object.entries(properties)
|
|
|
|
$: console.log("props group", properties)
|
2020-05-04 17:07:04 +02:00
|
|
|
$: icon = show ? "ri-arrow-down-s-fill" : "ri-arrow-right-s-fill"
|
|
|
|
</script>
|
|
|
|
|
2020-05-05 15:45:52 +02:00
|
|
|
<!-- () => (show = !show) -->
|
|
|
|
<div class="property-group-container" on:click={() => {}}>
|
2020-05-05 11:02:10 +02:00
|
|
|
<div class="property-group-name">
|
2020-05-04 17:07:04 +02:00
|
|
|
<div class="icon">
|
|
|
|
<i class={icon} />
|
|
|
|
</div>
|
2020-05-05 11:02:10 +02:00
|
|
|
<div class="name">{capitalize(name)}</div>
|
2020-05-04 17:07:04 +02:00
|
|
|
</div>
|
|
|
|
<div class="property-panel" class:show>
|
2020-05-05 15:45:52 +02:00
|
|
|
|
|
|
|
{#each propertyDefinition as [key, definition]}
|
|
|
|
<div class="property-control">
|
|
|
|
{#if propExistsOnComponentDef(key)}
|
|
|
|
<span>{definition.label || capitalize(key)}</span>
|
|
|
|
<svelte:component
|
|
|
|
this={definition.control}
|
|
|
|
value={componentInstance[key]}
|
|
|
|
on:change={onChange}
|
|
|
|
{onChange}
|
|
|
|
{...excludeProps(definition, ['control'])} />
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
{/each}
|
2020-05-04 17:07:04 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.property-group-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
height: auto;
|
|
|
|
background: #fbfbfb;
|
|
|
|
margin: 5px;
|
|
|
|
padding: 5px;
|
|
|
|
}
|
|
|
|
|
2020-05-05 11:02:10 +02:00
|
|
|
.property-group-name {
|
2020-05-04 17:07:04 +02:00
|
|
|
cursor: pointer;
|
|
|
|
flex: 0 0 20px;
|
|
|
|
display: flex;
|
|
|
|
flex-flow: row nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
flex: 0 0 20px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
2020-05-05 11:02:10 +02:00
|
|
|
.name {
|
2020-05-04 17:07:04 +02:00
|
|
|
flex: 1;
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
|
|
|
|
.property-panel {
|
|
|
|
height: 0px;
|
|
|
|
overflow: hidden;
|
2020-05-05 15:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.property-control {
|
|
|
|
display: flex;
|
|
|
|
flex-flow: row nowrap;
|
2020-05-04 17:07:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.show {
|
|
|
|
overflow: auto;
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
</style>
|