Merge pull request #202 from shogunpurple/screenslot

show screenslot and layout together
This commit is contained in:
Martin McKeaveney 2020-04-06 19:17:15 +01:00 committed by GitHub
commit aedb6ffe46
3 changed files with 9 additions and 8 deletions

View File

@ -29,10 +29,12 @@
[map(s => `<link rel="stylesheet" href="${s}"/>`), join("\n")] [map(s => `<link rel="stylesheet" href="${s}"/>`), join("\n")]
) )
$: screensExist = $store.currentPreviewItem._screens && $store.currentPreviewItem._screens.length > 0
$: frontendDefinition = { $: frontendDefinition = {
componentLibraries: $store.loadLibraryUrls($store.currentPageName), componentLibraries: $store.loadLibraryUrls($store.currentPageName),
page: $store.currentPreviewItem, page: $store.currentPreviewItem,
screens: [{ screens: screensExist ? $store.currentPreviewItem._screens : [{
name: "Screen Placeholder", name: "Screen Placeholder",
route: "*", route: "*",
props: { props: {

View File

@ -34,9 +34,9 @@ export const createApp = (
routeTo, routeTo,
appRootPath: frontendDefinition.appRootPath, appRootPath: frontendDefinition.appRootPath,
}) })
const getAttchChildrenParams = attachChildrenParams(stateManager) const getAttachChildrenParams = attachChildrenParams(stateManager)
screenSlotNode.props._children = [screen.props] screenSlotNode.props._children = [screen.props]
const initialiseChildParams = getAttchChildrenParams(screenSlotNode) const initialiseChildParams = getAttachChildrenParams(screenSlotNode)
attachChildren(initialiseChildParams)(screenSlotNode.rootElement, { attachChildren(initialiseChildParams)(screenSlotNode.rootElement, {
hydrate: true, hydrate: true,
force: true, force: true,
@ -102,6 +102,7 @@ export const createApp = (
return rootTreeNode return rootTreeNode
} }
return { return {
initialisePage, initialisePage,
screenStore: () => screenStateManager.store, screenStore: () => screenStateManager.store,

View File

@ -44,11 +44,9 @@ export const screenRouter = (screens, onScreenSelected, appRootPath) => {
storeInitial["##routeParams"] = params storeInitial["##routeParams"] = params
const store = writable(storeInitial) const store = writable(storeInitial)
if (current !== -1) { const screenIndex = current !== -1 ? current : fallback;
onScreenSelected(screens[current], store, _url)
} else { onScreenSelected(screens[screenIndex], store, _url)
onScreenSelected(screens[fallback], store, _url)
}
try { try {
!url.state && history.pushState(_url, null, _url) !url.state && history.pushState(_url, null, _url)