Initial implementation of props editor.

This commit is contained in:
pngwn 2020-01-22 15:18:28 +00:00
parent 3594f07346
commit 05a32f25f0
3 changed files with 85 additions and 79 deletions

View File

@ -53,38 +53,38 @@ store.subscribe(s => {
components = s.components; components = s.components;
}); });
// const save = () => { const save = () => {
// ignoreStore = true; ignoreStore = true;
// if(!validate()) { if(!validate()) {
// ignoreStore = false; ignoreStore = false;
// return; return;
// } }
// component.name = originalName || name; component.name = originalName || name;
// component.description = description; component.description = description;
// component.tags = pipe(tagsString, [ component.tags = pipe(tagsString, [
// split(","), split(","),
// map(s => s.trim()) map(s => s.trim())
// ]); ]);
// store.saveScreen(component); store.saveScreen(component);
// ignoreStore = false; ignoreStore = false;
// // now do the rename // now do the rename
// if(name !== originalName) { if(name !== originalName) {
// store.renameScreen(originalName, name); store.renameScreen(originalName, name);
// } }
// } }
// const deleteComponent = () => { const deleteComponent = () => {
// showDialog(); showDialog();
// } }
// const confirmDeleteComponent = () => { const confirmDeleteComponent = () => {
// store.deleteScreen(component.name); store.deleteScreen(component.name);
// hideDialog(); hideDialog();
// } }
const onPropsValidate = result => { const onPropsValidate = result => {
propsValidationErrors = result; propsValidationErrors = result;
@ -100,6 +100,7 @@ const updateComponent = doChange => {
const onPropsChanged = newProps => { const onPropsChanged = newProps => {
updateComponent(newComponent => updateComponent(newComponent =>
assign(newComponent.props, newProps)); assign(newComponent.props, newProps));
save();
} }

View File

@ -27,14 +27,14 @@ const setComponentProp = (props) => {
{#if propDef.type === "event"} {#if propDef.type === "event"}
<div class="prop-label">{propDef.____name}</div> <h5>{propDef.____name}</h5>
<EventListSelector parentProps={props} <EventListSelector parentProps={props}
{propDef} {propDef}
onValueChanged={setComponentProp} /> onValueChanged={setComponentProp} />
{:else } {:else }
<div class="prop-label">{propDef.____name}</div> <h5>{propDef.____name}</h5>
<StateBindingControl value={props[propDef.____name]} <StateBindingControl value={props[propDef.____name]}
type={propDef.type} type={propDef.type}
options={propDef.options} options={propDef.options}
@ -47,13 +47,21 @@ const setComponentProp = (props) => {
<style> <style>
.root { .root {
padding: 1rem 0 0rem 0; height: 40px;
margin-bottom: 15px;
display: grid;
grid-template-rows: 1fr;
grid-template-columns: 70px 1fr;
grid-gap: 10px;
} }
.prop-label { h5 {
font-size: 0.8rem; font-size: 12px;
color: var(--secondary100); font-weight: 700;
font-weight: bold; color: #163057;
} opacity: 0.6;
padding-top: 12px;
margin-bottom: 0;
}
</style> </style>

View File

@ -66,10 +66,10 @@ const setBindingSource = ev => {
bind(bindingPath, bindingFallbackValue, ev.target.value); bind(bindingPath, bindingFallbackValue, ev.target.value);
} }
const makeBinding = () => { // const makeBinding = () => {
forceIsBound=true; // forceIsBound=true;
isExpanded=true; // isExpanded=true;
} // }
</script> </script>
@ -77,11 +77,11 @@ const makeBinding = () => {
<div> <div>
<div class="bound-header"> <div class="bound-header">
<div>{isExpanded ? "" : bindingPath}</div> <div>{isExpanded ? "" : bindingPath}</div>
<IconButton icon={isExpanded ? "chevron-up" : "chevron-down"} <IconButton icon={isExpanded ? "chevron-up" : "chevron-down"}
size="12" size="12"
on:click={() => isExpanded=!isExpanded}/> on:click={() => isExpanded=!isExpanded}/>
{#if !canOnlyBind} {#if !canOnlyBind}
<IconButton icon="trash" <IconButton icon="trash"
size="12" size="12"
on:click={clearBinding}/> on:click={clearBinding}/>
{/if} {/if}
@ -97,8 +97,8 @@ const makeBinding = () => {
value={bindingFallbackValue} value={bindingFallbackValue}
on:change={setBindingFallback} > on:change={setBindingFallback} >
<div class="binding-prop-label">Binding Source</div> <div class="binding-prop-label">Binding Source</div>
<select class="uk-select uk-form-small" <select class="uk-select uk-form-small"
value={bindingSource} value={bindingSource}
on:change={setBindingSource}> on:change={setBindingSource}>
<option>store</option> <option>store</option>
@ -117,13 +117,13 @@ const makeBinding = () => {
<div> <div>
<IconButton icon={value == true ? "check-square" : "square"} <IconButton icon={value == true ? "check-square" : "square"}
size="19" size="19"
on:click={() => onChanged(!value)}/> on:click={() => onChanged(!value)} />
</div> </div>
{:else if type === "options"} {:else if type === "options"}
<select class="uk-select uk-form-small" <select class="uk-select uk-form-small"
value={value} value={value}
on:change={ev => onChanged(ev.target.value)}> on:change={ev => onChanged(ev.target.value)}>
{#each options as option} {#each options as option}
<option value={option}>{option}</option> <option value={option}>{option}</option>
@ -132,49 +132,46 @@ const makeBinding = () => {
{:else} {:else}
<input class="uk-input uk-form-small" <input on:change={ev => onChanged(ev.target.value)}
on:change={ev => onChanged(ev.target.value)} bind:value={value}
bind:value={value} style="flex: 1 0 auto;" />
style="flex: 1 0 auto;" >
{/if} {/if}
<IconButton icon="link"
size="12"
on:click={makeBinding} />
</div> </div>
{/if} {/if}
<style> <style>
.unbound-container {
display:flex;
}
.unbound-container { .bound-header {
display:flex; display: flex;
margin: .5rem 0rem .5rem 0rem; }
}
.unbound-container > *:nth-child(1) { .bound-header > div:nth-child(1) {
width:auto; flex: 1 0 auto;
flex: 1 0 auto; width: 30px;
font-size: 0.8rem; color: var(--secondary50);
color: var(--secondary100); padding-left: 5px;
border-radius: .2rem; }
}
.bound-header { .binding-prop-label {
display: flex; color: var(--secondary50);
} }
.bound-header > div:nth-child(1) { input {
flex: 1 0 auto; font-size: 12px;
width: 30px; font-weight: 700;
color: var(--secondary50); color: #163057;
padding-left: 5px; opacity: 0.7;
} padding: 5px 10px;
box-sizing: border-box;
.binding-prop-label { border: 1px solid #DBDBDB;
color: var(--secondary50); border-radius: 2px;
} outline: none;
}
</style>
</style>