Browse Source

Expose the screens and layouts from the screen store in the client library

pull/4023/head
Andrew Kingston 5 years ago
parent
commit
ee8033e88f
  1. 11
      packages/client/src/store/screens.js

11
packages/client/src/store/screens.js

@ -11,17 +11,20 @@ const createScreenStore = () => {
const store = derived(
[config, routeStore, builderStore],
([$config, $routeStore, $builderStore]) => {
let activeLayout
let activeScreen
let activeLayout, activeScreen
let layouts, screens
if ($builderStore.inBuilder) {
// Use builder defined definitions if inside the builder preview
activeLayout = $builderStore.layout
activeScreen = $builderStore.screen
layouts = [activeLayout]
screens = [activeScreen]
} else {
activeLayout = { props: { _component: "screenslot" } }
// Find the correct screen by matching the current route
const { screens, layouts } = $config
screens = $config.screens
layouts = $config.layouts
if ($routeStore.activeRoute) {
activeScreen = screens.find(
screen => screen._id === $routeStore.activeRoute.screenId
@ -33,7 +36,7 @@ const createScreenStore = () => {
)
}
}
return { activeLayout, activeScreen }
return { layouts, screens, activeLayout, activeScreen }
}
)

Loading…
Cancel
Save