1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Moved label align and button size into styles section of form block. Added tagged component settings section to the style section. General settings and sections now have a tag property for filtering.

This commit is contained in:
Dean 2023-10-19 12:00:47 +01:00
parent 1ab52f3304
commit ad54b31667
4 changed files with 70 additions and 38 deletions

View file

@ -65,7 +65,12 @@
/>
{/if}
{#if section == "styles"}
<DesignSection {componentInstance} {componentDefinition} {bindings} />
<DesignSection
{componentInstance}
{componentBindings}
{componentDefinition}
{bindings}
/>
<CustomStylesSection
{componentInstance}
{componentDefinition}

View file

@ -17,13 +17,23 @@
export let onUpdateSetting
export let showSectionTitle = true
export let showInstanceName = true
export let tag
$: sections = getSections(componentInstance, componentDefinition, isScreen)
$: sections = getSections(
componentInstance,
componentDefinition,
isScreen,
tag
)
const getSections = (instance, definition, isScreen) => {
const settings = definition?.settings ?? []
const generalSettings = settings.filter(setting => !setting.section)
const customSections = settings.filter(setting => setting.section)
const generalSettings = settings.filter(
setting => !setting.section && setting.tag === tag
)
const customSections = settings.filter(
setting => setting.section && setting.tag === tag
)
let sections = [
{
name: "General",
@ -131,7 +141,7 @@
<div class="section-info">
<InfoDisplay body={section.info} />
</div>
{:else if idx === 0 && section.name === "General" && componentDefinition.info}
{:else if idx === 0 && section.name === "General" && componentDefinition.info && !tag}
<InfoDisplay
title={componentDefinition.name}
body={componentDefinition.info}
@ -189,7 +199,7 @@
</DetailSummary>
{/if}
{/each}
{#if componentDefinition?.block}
{#if componentDefinition?.block && !tag}
<DetailSummary name="Eject" collapsible={false}>
<EjectBlockButton />
</DetailSummary>

View file

@ -1,10 +1,12 @@
<script>
import StyleSection from "./StyleSection.svelte"
import * as ComponentStyles from "./componentStyles"
import ComponentSettingsSection from "./ComponentSettingsSection.svelte"
export let componentDefinition
export let componentInstance
export let bindings
export let componentBindings
const getStyles = def => {
if (!def?.styles?.length) {
@ -22,6 +24,19 @@
$: styles = getStyles(componentDefinition)
</script>
<!--
Load any general settings or sections tagged as "style"
-->
<ComponentSettingsSection
{componentInstance}
{componentDefinition}
isScreen={false}
showInstanceName={false}
{bindings}
{componentBindings}
tag="style"
/>
{#if styles?.length > 0}
{#each styles as style}
<StyleSection

View file

@ -5385,38 +5385,6 @@
"section": true,
"name": "Fields",
"settings": [
{
"type": "select",
"label": "Align labels",
"key": "labelPosition",
"defaultValue": "left",
"options": [
{
"label": "Left",
"value": "left"
},
{
"label": "Above",
"value": "above"
}
]
},
{
"type": "select",
"label": "Size",
"key": "size",
"options": [
{
"label": "Medium",
"value": "spectrum--medium"
},
{
"label": "Large",
"value": "spectrum--large"
}
],
"defaultValue": "spectrum--medium"
},
{
"type": "fieldConfiguration",
"key": "fields",
@ -5436,6 +5404,40 @@
}
}
]
},
{
"tag": "style",
"type": "select",
"label": "Align labels",
"key": "labelPosition",
"defaultValue": "left",
"options": [
{
"label": "Left",
"value": "left"
},
{
"label": "Above",
"value": "above"
}
]
},
{
"tag": "style",
"type": "select",
"label": "Size",
"key": "size",
"options": [
{
"label": "Medium",
"value": "spectrum--medium"
},
{
"label": "Large",
"value": "spectrum--large"
}
],
"defaultValue": "spectrum--medium"
}
],
"context": [