Add screenslot to current preview.

This commit is contained in:
pngwn 2020-02-18 15:53:22 +00:00
parent 6db4394562
commit 3c51f731ef
6 changed files with 72 additions and 32 deletions

View File

@ -182,6 +182,7 @@ const initialise = (store, initial) => async () => {
} }
store.set(initial) store.set(initial)
console.log(initial)
return initial return initial
} }
@ -743,6 +744,7 @@ const setCurrentPage = store => pageName => {
}) })
} }
const getContainerComponent = components => const getContainerComponent = components =>
components.find(c => c.name === "@budibase/standard-components/container") components.find(c => c.name === "@budibase/standard-components/container")
@ -758,14 +760,16 @@ const addChildComponent = store => componentName => {
) )
_savePage(s) _savePage(s)
//console.log(JSON.stringify(s.screens[0].props._children))
return s return s
}) })
} }
const selectComponent = store => component => { const selectComponent = store => component => {
store.update(s => { store.update(s => {
const componentDef = s.components.find(c => c.name === component._component) const componentDef = component._component.startsWith("##")
? component
: s.components.find(c => c.name === component._component)
s.currentComponentInfo = makePropsSafe(componentDef, component) s.currentComponentInfo = makePropsSafe(componentDef, component)
return s return s
}) })

View File

@ -42,6 +42,7 @@
<LayoutIcon /> <LayoutIcon />
</button> </button>
</li> </li>
{#if !component._component.startsWith('##')}
<li> <li>
<button <button
class:selected={current_view === 'code'} class:selected={current_view === 'code'}
@ -61,9 +62,9 @@
<EventsIcon /> <EventsIcon />
</button> </button>
</li> </li>
{/if}
</ul> </ul>
{$store.currentFrontEndType} {$store.currentFrontEndType}
<div class="component-props-container"> <div class="component-props-container">
{#if current_view === 'props'} {#if current_view === 'props'}
@ -81,8 +82,6 @@
</div> </div>
</div> </div>
<style> <style>

View File

@ -32,7 +32,37 @@
$: frontendDefinition = { $: frontendDefinition = {
componentLibraries: $store.loadLibraryUrls(), componentLibraries: $store.loadLibraryUrls(),
page: $store.currentPreviewItem, page: $store.currentPreviewItem,
screens: [], screens: [{
name: "Screen Placeholder",
route: "*",
props: {
_component: "@budibase/standard-components/container",
type: "div",
_children: [
{
_component: "@budibase/standard-components/container",
_styles: { "position": {},"layout": {} },
_id: "__screenslot__text",
_code: "",
className: "",
onLoad: [],
type: "div",
_children: [{
_component:"@budibase/standard-components/text",
_styles: { "position": {}, "layout": {} },
_id: "__screenslot__text",
_code: "",
text: "content",
font: "",
color: "",
textAlign: "inline",
verticalAlign: "inline",
formattingTag: "none"
}]
}
]
}
}],
appRootPath: "", appRootPath: "",
} }

View File

@ -32,7 +32,7 @@
let modalOpen = false let modalOpen = false
let events = [] let events = []
let selectedEvent = null let selectedEvent = null
$: console.log(component)
$: { $: {
events = Object.keys(component) events = Object.keys(component)
@ -42,8 +42,9 @@
function findType(propName) { function findType(propName) {
if (!component._component) return if (!component._component) return
return components.find(({ name }) => name === component._component) return components.find(({ name }) => name === component._component).props[
.props[propName] propName
]
} }
const openModal = event => { const openModal = event => {

View File

@ -9,6 +9,7 @@ export const screenRouter = (screens, onScreenSelected) => {
let current let current
function route(url) { function route(url) {
const _url = url.state || url const _url = url.state || url
current = routes.findIndex( current = routes.findIndex(
p => p !== "*" && new RegExp("^" + p + "$").test(_url) p => p !== "*" && new RegExp("^" + p + "$").test(_url)
@ -42,7 +43,11 @@ export const screenRouter = (screens, onScreenSelected) => {
onScreenSelected(screens[fallback], store, _url) onScreenSelected(screens[fallback], store, _url)
} }
try {
!url.state && history.pushState(_url, null, _url) !url.state && history.pushState(_url, null, _url)
} catch (_) {
// ignoring an exception here as the builder runs an iframe, which does not like this
}
} }
function click(e) { function click(e) {

View File

@ -34,7 +34,8 @@
return all return all
} }
$: if(_bb.props._children.length > 0) theButton && _bb.attachChildren(theButton) $: if (_bb.props._children.length > 0)
theButton && _bb.attachChildren(theButton)
$: { $: {
cssVariables = { cssVariables = {
@ -73,7 +74,7 @@
disabled={disabled || false} disabled={disabled || false}
on:click={clickHandler} on:click={clickHandler}
style={buttonStyles}> style={buttonStyles}>
{#if _bb.props_children.length === 0}{contentText}{/if} {#if _bb.props._children.length === 0}{contentText}{/if}
</button> </button>
<style> <style>