2020-11-24 10:31:54 +01:00
|
|
|
import { writable } from "svelte/store"
|
|
|
|
|
|
|
|
const createBuilderStore = () => {
|
|
|
|
const initialState = {
|
|
|
|
inBuilder: false,
|
2021-01-07 15:53:56 +01:00
|
|
|
appId: null,
|
2020-11-27 17:36:31 +01:00
|
|
|
layout: null,
|
2020-11-24 10:31:54 +01:00
|
|
|
screen: null,
|
2020-11-30 13:11:50 +01:00
|
|
|
selectedComponentId: null,
|
|
|
|
previewId: null,
|
2021-01-06 11:11:56 +01:00
|
|
|
previewType: null,
|
|
|
|
}
|
|
|
|
const store = writable(initialState)
|
|
|
|
const actions = {
|
2021-05-03 09:31:09 +02:00
|
|
|
selectComponent: (id) => {
|
2021-01-26 15:40:44 +01:00
|
|
|
if (id) {
|
|
|
|
window.dispatchEvent(
|
|
|
|
new CustomEvent("bb-select-component", { detail: id })
|
|
|
|
)
|
|
|
|
}
|
2021-01-06 11:11:56 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...store,
|
|
|
|
actions,
|
2020-11-24 10:31:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const builderStore = createBuilderStore()
|