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

View File

@ -27,14 +27,14 @@ const setComponentProp = (props) => {
{#if propDef.type === "event"}
<div class="prop-label">{propDef.____name}</div>
<h5>{propDef.____name}</h5>
<EventListSelector parentProps={props}
{propDef}
onValueChanged={setComponentProp} />
{:else }
<div class="prop-label">{propDef.____name}</div>
<h5>{propDef.____name}</h5>
<StateBindingControl value={props[propDef.____name]}
type={propDef.type}
options={propDef.options}
@ -47,13 +47,21 @@ const setComponentProp = (props) => {
<style>
.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 {
font-size: 0.8rem;
color: var(--secondary100);
font-weight: bold;
h5 {
font-size: 12px;
font-weight: 700;
color: #163057;
opacity: 0.6;
padding-top: 12px;
margin-bottom: 0;
}
</style>

View File

@ -66,10 +66,10 @@ const setBindingSource = ev => {
bind(bindingPath, bindingFallbackValue, ev.target.value);
}
const makeBinding = () => {
forceIsBound=true;
isExpanded=true;
}
// const makeBinding = () => {
// forceIsBound=true;
// isExpanded=true;
// }
</script>
@ -132,33 +132,20 @@ const makeBinding = () => {
{:else}
<input class="uk-input uk-form-small"
on:change={ev => onChanged(ev.target.value)}
<input on:change={ev => onChanged(ev.target.value)}
bind:value={value}
style="flex: 1 0 auto;" >
style="flex: 1 0 auto;" />
{/if}
<IconButton icon="link"
size="12"
on:click={makeBinding} />
</div>
{/if}
<style>
.unbound-container {
display:flex;
margin: .5rem 0rem .5rem 0rem;
}
.unbound-container > *:nth-child(1) {
width:auto;
flex: 1 0 auto;
font-size: 0.8rem;
color: var(--secondary100);
border-radius: .2rem;
}
.bound-header {
@ -176,5 +163,15 @@ const makeBinding = () => {
color: var(--secondary50);
}
input {
font-size: 12px;
font-weight: 700;
color: #163057;
opacity: 0.7;
padding: 5px 10px;
box-sizing: border-box;
border: 1px solid #DBDBDB;
border-radius: 2px;
outline: none;
}
</style>