Make page and screen props editable.
This commit is contained in:
parent
8ab04fa944
commit
b0efaac0f6
|
@ -112,6 +112,7 @@ export const getStore = () => {
|
||||||
store.moveDownComponent = moveDownComponent(store)
|
store.moveDownComponent = moveDownComponent(store)
|
||||||
store.copyComponent = copyComponent(store)
|
store.copyComponent = copyComponent(store)
|
||||||
store.addTemplatedComponent = addTemplatedComponent(store)
|
store.addTemplatedComponent = addTemplatedComponent(store)
|
||||||
|
store.setDetailProp = setDetailProp(store)
|
||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +518,7 @@ const setCurrentScreen = store => screenName => {
|
||||||
screen._css = generate_screen_css([screen.props])
|
screen._css = generate_screen_css([screen.props])
|
||||||
s.currentPreviewItem = screen
|
s.currentPreviewItem = screen
|
||||||
s.currentFrontEndType = "screen"
|
s.currentFrontEndType = "screen"
|
||||||
|
s.currentView = "detail"
|
||||||
|
|
||||||
s.currentComponentInfo = makePropsSafe(
|
s.currentComponentInfo = makePropsSafe(
|
||||||
getContainerComponent(s.components),
|
getContainerComponent(s.components),
|
||||||
|
@ -764,6 +766,7 @@ const addChildComponent = store => (componentToAdd, presetName) => {
|
||||||
? _savePage(state)
|
? _savePage(state)
|
||||||
: _saveScreenApi(state.currentPreviewItem, state)
|
: _saveScreenApi(state.currentPreviewItem, state)
|
||||||
|
|
||||||
|
state.currentView = "component"
|
||||||
state.currentComponentInfo = newComponent.props
|
state.currentComponentInfo = newComponent.props
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
@ -794,6 +797,7 @@ const selectComponent = store => component => {
|
||||||
? component
|
? component
|
||||||
: state.components.find(c => c.name === component._component)
|
: state.components.find(c => c.name === component._component)
|
||||||
state.currentComponentInfo = makePropsSafe(componentDef, component)
|
state.currentComponentInfo = makePropsSafe(componentDef, component)
|
||||||
|
state.currentView = "component"
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -952,6 +956,13 @@ const walkProps = (props, action, cancelToken = null) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setDetailProp = store => (name, prop) => {
|
||||||
|
store.update(s => {
|
||||||
|
s.currentPreviewItem[name] = prop
|
||||||
|
return s
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const _saveCurrentPreviewItem = s =>
|
const _saveCurrentPreviewItem = s =>
|
||||||
s.currentFrontEndType === "page"
|
s.currentFrontEndType === "page"
|
||||||
? _savePage(s)
|
? _savePage(s)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import PropsView from "./PropsView.svelte"
|
import PropsView from "./PropsView.svelte"
|
||||||
|
import StateBindingControl from "./StateBindingControl.svelte"
|
||||||
import { store } from "../builderStore"
|
import { store } from "../builderStore"
|
||||||
import IconButton from "../common/IconButton.svelte"
|
import IconButton from "../common/IconButton.svelte"
|
||||||
import {
|
import {
|
||||||
|
@ -18,12 +19,24 @@
|
||||||
|
|
||||||
$: component = $store.currentComponentInfo
|
$: component = $store.currentComponentInfo
|
||||||
$: originalName = component.name
|
$: originalName = component.name
|
||||||
$: name = component.name
|
$: name =
|
||||||
|
$store.currentView === "detail"
|
||||||
|
? $store.currentPreviewItem.name
|
||||||
|
: component._component
|
||||||
$: description = component.description
|
$: description = component.description
|
||||||
$: components = $store.components
|
$: components = $store.components
|
||||||
|
$: screen_props =
|
||||||
|
$store.currentFrontEndType === "page"
|
||||||
|
? getProps($store.currentPreviewItem, ["name", "favicon"])
|
||||||
|
: getProps($store.currentPreviewItem, ["name", "description", "url"])
|
||||||
|
$: console.log(screen_props)
|
||||||
const onPropChanged = store.setComponentProp
|
const onPropChanged = store.setComponentProp
|
||||||
const onStyleChanged = store.setComponentStyle
|
const onStyleChanged = store.setComponentStyle
|
||||||
|
|
||||||
|
function getProps(obj, keys) {
|
||||||
|
return keys.map((k, i) => [k, obj[k], obj.props._id + i])
|
||||||
|
}
|
||||||
|
$: console.log($store, component)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
|
@ -64,11 +77,23 @@
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
</ul>
|
</ul>
|
||||||
{$store.currentFrontEndType}
|
|
||||||
<div class="component-props-container">
|
<div class="component-props-container">
|
||||||
|
|
||||||
{#if current_view === 'props'}
|
{#if current_view === 'props'}
|
||||||
|
{#if $store.currentView === 'detail'}
|
||||||
|
{#each screen_props as [k, v, id] (id)}
|
||||||
|
<div class="detail-prop" for={k}>
|
||||||
|
<label>{k}:</label>
|
||||||
|
<input
|
||||||
|
id={k}
|
||||||
|
value={v}
|
||||||
|
on:input={({ target }) => store.setDetailProp(k, target.value)} />
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
<PropsView {component} {components} {onPropChanged} />
|
<PropsView {component} {components} {onPropChanged} />
|
||||||
|
{:else}
|
||||||
|
<PropsView {component} {components} {onPropChanged} />
|
||||||
|
{/if}
|
||||||
{:else if current_view === 'layout'}
|
{:else if current_view === 'layout'}
|
||||||
<LayoutEditor {onStyleChanged} {component} />
|
<LayoutEditor {onStyleChanged} {component} />
|
||||||
{:else if current_view === 'events'}
|
{:else if current_view === 'events'}
|
||||||
|
@ -85,6 +110,41 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.detail-prop {
|
||||||
|
height: 40px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 1fr;
|
||||||
|
grid-template-columns: 70px 1fr;
|
||||||
|
grid-gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-prop label {
|
||||||
|
word-wrap: break-word;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #163057;
|
||||||
|
opacity: 0.6;
|
||||||
|
padding-top: 12px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
height: 30px;
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-right: 8px;
|
||||||
|
border: 1px solid #dbdbdb;
|
||||||
|
border-radius: 2px;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus {
|
||||||
|
outline: 0;
|
||||||
|
background-color: #fff;
|
||||||
|
color: #666;
|
||||||
|
border-color: #1e87f0;
|
||||||
|
}
|
||||||
|
|
||||||
.root {
|
.root {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -45,8 +45,6 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
|
||||||
<p>Please create a new screen</p>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue