Update front end column structure layout and width to increase preview space
This commit is contained in:
parent
8390a8704e
commit
3a70a62cf5
|
@ -20,7 +20,7 @@
|
||||||
$: componentPropDefinition =
|
$: componentPropDefinition =
|
||||||
flattenedPanel.find(
|
flattenedPanel.find(
|
||||||
//use for getting controls for each component property
|
//use for getting controls for each component property
|
||||||
c => c._component === componentInstance._component
|
(c) => c._component === componentInstance._component
|
||||||
) || {}
|
) || {}
|
||||||
|
|
||||||
$: panelDefinition =
|
$: panelDefinition =
|
||||||
|
@ -48,8 +48,8 @@
|
||||||
|
|
||||||
function flattenComponents(props) {
|
function flattenComponents(props) {
|
||||||
const components = []
|
const components = []
|
||||||
props.forEach(comp =>
|
props.forEach((comp) =>
|
||||||
walkProps(comp, c => {
|
walkProps(comp, (c) => {
|
||||||
if ("_component" in c) {
|
if ("_component" in c) {
|
||||||
components.push(c)
|
components.push(c)
|
||||||
}
|
}
|
||||||
|
@ -63,41 +63,31 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<CategoryTab
|
||||||
<CategoryTab
|
onClick={(category) => (selectedCategory = category)}
|
||||||
onClick={category => (selectedCategory = category)}
|
{categories}
|
||||||
{categories}
|
{selectedCategory} />
|
||||||
{selectedCategory} />
|
|
||||||
|
|
||||||
{#if displayName}
|
{#if displayName}
|
||||||
<div class="instance-name">{componentInstance._instanceName}</div>
|
<div class="instance-name">{componentInstance._instanceName}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="component-props-container">
|
||||||
|
{#if selectedCategory.value === 'design'}
|
||||||
|
<DesignView {panelDefinition} {componentInstance} {onStyleChanged} />
|
||||||
|
{:else if selectedCategory.value === 'settings'}
|
||||||
|
<SettingsView
|
||||||
|
{componentInstance}
|
||||||
|
{componentDefinition}
|
||||||
|
{panelDefinition}
|
||||||
|
displayNameField={displayName}
|
||||||
|
onChange={store.setComponentProp}
|
||||||
|
onScreenPropChange={store.setPageOrScreenProp}
|
||||||
|
screenOrPageInstance={$store.currentView !== 'component' && $store.currentPreviewItem} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="component-props-container">
|
|
||||||
{#if selectedCategory.value === 'design'}
|
|
||||||
<DesignView {panelDefinition} {componentInstance} {onStyleChanged} />
|
|
||||||
{:else if selectedCategory.value === 'settings'}
|
|
||||||
<SettingsView
|
|
||||||
{componentInstance}
|
|
||||||
{componentDefinition}
|
|
||||||
{panelDefinition}
|
|
||||||
displayNameField={displayName}
|
|
||||||
onChange={store.setComponentProp}
|
|
||||||
onScreenPropChange={store.setPageOrScreenProp}
|
|
||||||
screenOrPageInstance={$store.currentView !== 'component' && $store.currentPreviewItem} />
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.root {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: 20px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title > div:nth-child(1) {
|
.title > div:nth-child(1) {
|
||||||
grid-column-start: name;
|
grid-column-start: name;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
|
@ -108,7 +98,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.component-props-container {
|
.component-props-container {
|
||||||
margin-top: 16px;
|
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
@ -118,7 +107,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.instance-name {
|
.instance-name {
|
||||||
margin-top: 20px;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--grey-7);
|
color: var(--grey-7);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
let propGroup = null
|
let propGroup = null
|
||||||
let currentGroup
|
let currentGroup
|
||||||
|
|
||||||
const getProperties = name => panelDefinition[name]
|
const getProperties = (name) => panelDefinition[name]
|
||||||
|
|
||||||
function onChange(category) {
|
function onChange(category) {
|
||||||
selectedCategory = category
|
selectedCategory = category
|
||||||
|
@ -61,10 +61,10 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
gap: var(--spacing-m);
|
||||||
}
|
}
|
||||||
|
|
||||||
.design-view-state-categories {
|
.design-view-state-categories {
|
||||||
flex: 0 0 50px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.positioned-wrapper {
|
.positioned-wrapper {
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
//Incase the component has a different value key name
|
//Incase the component has a different value key name
|
||||||
const handlevalueKey = value =>
|
const handlevalueKey = (value) =>
|
||||||
props.valueKey ? { [props.valueKey]: safeValue() } : { value: safeValue() }
|
props.valueKey ? { [props.valueKey]: safeValue() } : { value: safeValue() }
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@
|
||||||
this={control}
|
this={control}
|
||||||
{componentInstance}
|
{componentInstance}
|
||||||
{...handlevalueKey(value)}
|
{...handlevalueKey(value)}
|
||||||
on:change={val => handleChange(key, val)}
|
on:change={(val) => handleChange(key, val)}
|
||||||
onChange={val => handleChange(key, val)}
|
onChange={(val) => handleChange(key, val)}
|
||||||
{...props}
|
{...props}
|
||||||
name={key} />
|
name={key} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
<BindingDropdown
|
<BindingDropdown
|
||||||
{...handlevalueKey(value)}
|
{...handlevalueKey(value)}
|
||||||
close={dropdown.hide}
|
close={dropdown.hide}
|
||||||
on:update={e => (temporaryBindableValue = e.detail)}
|
on:update={(e) => (temporaryBindableValue = e.detail)}
|
||||||
{bindableProperties} />
|
{bindableProperties} />
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -119,16 +119,14 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: row;
|
flex-flow: row;
|
||||||
margin: 8px 0;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
flex: 0 0 100px;
|
flex: 0 0 80px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
|
@ -14,13 +14,26 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DetailSummary {name} on:open show={open}>
|
<DetailSummary {name} on:open show={open}>
|
||||||
{#each properties as props}
|
<div>
|
||||||
<PropertyControl
|
{#each properties as props}
|
||||||
label={props.label}
|
<PropertyControl
|
||||||
control={props.control}
|
label={props.label}
|
||||||
key={props.key}
|
control={props.control}
|
||||||
value={style[props.key]}
|
key={props.key}
|
||||||
onChange={(key, value) => onStyleChanged(styleCategory, key, value)}
|
value={style[props.key]}
|
||||||
props={{ ...excludeProps(props, ['control', 'label']) }} />
|
onChange={(key, value) => onStyleChanged(styleCategory, key, value)}
|
||||||
{/each}
|
props={{ ...excludeProps(props, ['control', 'label']) }} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
</DetailSummary>
|
</DetailSummary>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: var(--spacing-s);
|
||||||
|
margin-top: var(--spacing-m);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
let pageScreenProps = ["title", "favicon", "description", "route"]
|
let pageScreenProps = ["title", "favicon", "description", "route"]
|
||||||
let duplicateName = false
|
let duplicateName = false
|
||||||
|
|
||||||
const propExistsOnComponentDef = prop =>
|
const propExistsOnComponentDef = (prop) =>
|
||||||
pageScreenProps.includes(prop) || prop in componentDefinition.props
|
pageScreenProps.includes(prop) || prop in componentDefinition.props
|
||||||
|
|
||||||
function handleChange(key, data) {
|
function handleChange(key, data) {
|
||||||
|
@ -47,10 +47,10 @@
|
||||||
$: isPage = screenOrPageInstance && screenOrPageInstance.favicon
|
$: isPage = screenOrPageInstance && screenOrPageInstance.favicon
|
||||||
$: screenOrPageDefinition = isPage ? pageDefinition : screenDefinition
|
$: screenOrPageDefinition = isPage ? pageDefinition : screenDefinition
|
||||||
|
|
||||||
const isDuplicateName = name => {
|
const isDuplicateName = (name) => {
|
||||||
let duplicate = false
|
let duplicate = false
|
||||||
|
|
||||||
const lookForDuplicate = rootPops => {
|
const lookForDuplicate = (rootPops) => {
|
||||||
walkProps(rootPops, (inst, cancel) => {
|
walkProps(rootPops, (inst, cancel) => {
|
||||||
if (inst._instanceName === name && inst._id !== componentInstance._id) {
|
if (inst._instanceName === name && inst._id !== componentInstance._id) {
|
||||||
duplicate = true
|
duplicate = true
|
||||||
|
@ -85,50 +85,60 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if screenOrPageInstance}
|
<div class="settings-view-container">
|
||||||
{#each screenOrPageDefinition as def}
|
{#if screenOrPageInstance}
|
||||||
<PropertyControl
|
{#each screenOrPageDefinition as def}
|
||||||
bindable={false}
|
|
||||||
control={def.control}
|
|
||||||
label={def.label}
|
|
||||||
key={def.key}
|
|
||||||
value={screenOrPageInstance[def.key]}
|
|
||||||
onChange={onScreenPropChange}
|
|
||||||
props={{ ...excludeProps(def, ['control', 'label']) }} />
|
|
||||||
{/each}
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if displayNameField}
|
|
||||||
<PropertyControl
|
|
||||||
control={Input}
|
|
||||||
label="Name"
|
|
||||||
key="_instanceName"
|
|
||||||
value={componentInstance._instanceName}
|
|
||||||
onChange={onInstanceNameChange} />
|
|
||||||
{#if duplicateName}
|
|
||||||
<span class="duplicate-name">Name must be unique</span>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if panelDefinition && panelDefinition.length > 0}
|
|
||||||
{#each panelDefinition as definition}
|
|
||||||
{#if canRenderControl(definition.key, definition.dependsOn)}
|
|
||||||
<PropertyControl
|
<PropertyControl
|
||||||
control={definition.control}
|
bindable={false}
|
||||||
label={definition.label}
|
control={def.control}
|
||||||
key={definition.key}
|
label={def.label}
|
||||||
value={componentInstance[definition.key] || componentInstance[definition.key]?.defaultValue}
|
key={def.key}
|
||||||
{componentInstance}
|
value={screenOrPageInstance[def.key]}
|
||||||
{onChange}
|
onChange={onScreenPropChange}
|
||||||
props={{ ...excludeProps(definition, ['control', 'label']) }} />
|
props={{ ...excludeProps(def, ['control', 'label']) }} />
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if displayNameField}
|
||||||
|
<PropertyControl
|
||||||
|
control={Input}
|
||||||
|
label="Name"
|
||||||
|
key="_instanceName"
|
||||||
|
value={componentInstance._instanceName}
|
||||||
|
onChange={onInstanceNameChange} />
|
||||||
|
{#if duplicateName}
|
||||||
|
<span class="duplicate-name">Name must be unique</span>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/if}
|
||||||
{:else}
|
|
||||||
<div>This component does not have any settings.</div>
|
{#if panelDefinition && panelDefinition.length > 0}
|
||||||
{/if}
|
{#each panelDefinition as definition}
|
||||||
|
{#if canRenderControl(definition.key, definition.dependsOn)}
|
||||||
|
<PropertyControl
|
||||||
|
control={definition.control}
|
||||||
|
label={definition.label}
|
||||||
|
key={definition.key}
|
||||||
|
value={componentInstance[definition.key] || componentInstance[definition.key]?.defaultValue}
|
||||||
|
{componentInstance}
|
||||||
|
{onChange}
|
||||||
|
props={{ ...excludeProps(definition, ['control', 'label']) }} />
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{:else}
|
||||||
|
<div class="empty">This component does not have any settings.</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div {
|
.settings-view-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
gap: var(--spacing-s);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
font-size: var(--font-size-s);
|
font-size: var(--font-size-s);
|
||||||
margin-top: var(--spacing-m);
|
margin-top: var(--spacing-m);
|
||||||
color: var(--grey-6);
|
color: var(--grey-6);
|
||||||
|
|
Loading…
Reference in New Issue