Form and button update

This commit is contained in:
Joe 2020-06-03 22:49:55 +01:00
parent e4cc5656ae
commit 94a9868427
4 changed files with 125 additions and 42 deletions

View File

@ -1,6 +1,6 @@
<script> <script>
import { setContext, onMount } from "svelte" import { setContext, onMount } from "svelte"
import {screen, page} from "./propertyCategories.js" import { screen, page } from "./propertyCategories.js"
import PropsView from "./PropsView.svelte" import PropsView from "./PropsView.svelte"
import { store } from "builderStore" import { store } from "builderStore"
import IconButton from "components/common/IconButton.svelte" import IconButton from "components/common/IconButton.svelte"
@ -38,20 +38,22 @@
c => c._component === componentInstance._component c => c._component === componentInstance._component
) || {} ) || {}
let panelDefinition = {} let panelDefinition = {}
$: { $: {
if(componentPropDefinition.properties) { if (componentPropDefinition.properties) {
if(selectedCategory.value === "design") { if (selectedCategory.value === "design") {
panelDefinition = componentPropDefinition.properties["design"] panelDefinition = componentPropDefinition.properties["design"]
}else{ } else {
let panelDef = componentPropDefinition.properties["settings"] let panelDef = componentPropDefinition.properties["settings"]
if($store.currentFrontEndType === "page") { if ($store.currentFrontEndType === "page") {
panelDefinition = [...page,...panelDef] panelDefinition = [...page, ...panelDef]
}else if($store.currentFrontEndType === "screen" && $store.currentView !== "component") { } else if (
$store.currentFrontEndType === "screen" &&
$store.currentView !== "component"
) {
panelDefinition = [...screen, ...panelDef] panelDefinition = [...screen, ...panelDef]
}else { } else {
panelDefinition = panelDef panelDefinition = panelDef
} }
} }
@ -60,21 +62,32 @@
let componentInstance = {} let componentInstance = {}
$: { $: {
if(($store.currentFrontEndType === "screen" || $store.currentFrontEndType === "page") && $store.currentView !== "component") { if (
componentInstance = {...$store.currentPreviewItem, ...$store.currentComponentInfo} ($store.currentFrontEndType === "screen" ||
}else { $store.currentFrontEndType === "page") &&
componentInstance = $store.currentComponentInfo $store.currentView !== "component"
} ) {
componentInstance = {
...$store.currentPreviewItem,
...$store.currentComponentInfo,
}
} else {
componentInstance = $store.currentComponentInfo
}
} }
const onStyleChanged = store.setComponentStyle const onStyleChanged = store.setComponentStyle
function onPropChanged(key, value) { function onPropChanged(key, value) {
if($store.currentFrontEndType === "page" || ($store.currentFrontEndType === "screen" && $store.currentView !== "component")) { if (
$store.currentFrontEndType === "page" ||
($store.currentFrontEndType === "screen" &&
$store.currentView !== "component")
) {
store.editPageOrScreen(key, value) store.editPageOrScreen(key, value)
return; return
} }
store.setComponentProp(key, value) store.setComponentProp(key, value)
} }

View File

@ -10,8 +10,9 @@
export let onChange = () => {} export let onChange = () => {}
let pageScreenProps = ["title", "favicon", "description", "route"] let pageScreenProps = ["title", "favicon", "description", "route"]
const propExistsOnComponentDef = prop => pageScreenProps.includes(prop) || prop in componentDefinition.props const propExistsOnComponentDef = prop =>
pageScreenProps.includes(prop) || prop in componentDefinition.props
function handleChange(key, data) { function handleChange(key, data) {
const value = data.target ? data.target.value : data const value = data.target ? data.target.value : data

View File

@ -17,7 +17,7 @@
<button <button
bind:this={theButton} bind:this={theButton}
class={className} class="default"
disabled={disabled || false} disabled={disabled || false}
on:click={clickHandler}> on:click={clickHandler}>
{#if !_bb.props._children || _bb.props._children.length === 0}{text}{/if} {#if !_bb.props._children || _bb.props._children.length === 0}{text}{/if}
@ -25,23 +25,21 @@
<style> <style>
.default { .default {
font-family: inherit; align-items: center;
font-size: inherit; font-family: Inter;
padding: 0.4em; font-size: 16px;
margin: 0 0 0.5em 0; padding: 0px 16px;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #ccc; border-radius: 4px;
border-radius: 2px;
color: #000333;
outline: none; outline: none;
} height: 40px;
cursor: pointer;
.default:active { transition: all 0.2s ease 0s;
background-color: #f9f9f9; overflow: hidden;
} outline: none;
user-select: none;
.default:focus { white-space: nowrap;
border-color: #666; text-align: center;
} }
.border { .border {

View File

@ -58,24 +58,95 @@
} }
</script> </script>
<form class="uk-form" on:submit|preventDefault> <form class="form" on:submit|preventDefault>
<h4>{modelDef.name}</h4> <div class="form-content">
<div>
{#each fields as field} {#each fields as field}
<div class="uk-margin"> <div class="form-item">
<label class="form-label" for="form-stacked-text">{field}</label> <label class="form-label" for="form-stacked-text">{field}</label>
<input <input
class="uk-input" class="input"
placeholder={field}
type={schema[field].type === 'string' ? 'text' : schema[field].type} type={schema[field].type === 'string' ? 'text' : schema[field].type}
on:change={handleInput(field)} /> on:change={handleInput(field)} />
</div> </div>
<hr />
{/each} {/each}
<div class="button-block">
<button on:click={save}>Submit Form</button>
</div>
</div> </div>
<button on:click={save}>SAVE</button>
</form> </form>
<style> <style>
.form {
align-items: center;
width: 100%;
}
.form-content {
margin-bottom: 20px;
justify-content: space-between;
align-items: baseline;
}
.input {
width: 600px;
height: 40px;
border-radius: 5px;
border: 1px solid #e6e6e6;
padding: 6px 12px 6px 12px;
font-size: 16px;
}
.form-item {
display: flex;
justify-content: space-between;
margin-bottom: 16px;
}
.form-label { .form-label {
font-weight: bold; font-weight: bold;
margin-bottom: 8px;
}
hr {
border: 1px solid #fafafa;
margin: 20px 0px;
}
hr:nth-last-child(2) {
border: 1px solid #fff;
margin: 20px 0px;
}
.button-block {
display: flex;
justify-content: flex-end;
}
button {
font-family: Inter;
font-size: 16px;
padding: 0.4em;
box-sizing: border-box;
border-radius: 4px;
color: white;
background-color: #393c44;
outline: none;
width: 300px;
height: 40px;
cursor: pointer;
transition: all 0.2s ease 0s;
overflow: hidden;
outline: none;
user-select: none;
white-space: nowrap;
text-align: center;
}
button:hover {
background-color: white;
border-color: #393c44;
color: #393c44;
} }
</style> </style>