1
0
Fork 0
mirror of synced 2024-07-06 06:50:49 +12:00

Add builtin slot to list

This commit is contained in:
pngwn 2020-02-18 10:32:00 +00:00
parent 87c363df61
commit 4a62525949
5 changed files with 24 additions and 11 deletions

File diff suppressed because one or more lines are too long

View file

@ -30,6 +30,7 @@ import {
getNewScreen, getNewScreen,
createProps, createProps,
makePropsSafe, makePropsSafe,
getBuiltin,
} from "../userInterface/pagesParsing/createProps" } from "../userInterface/pagesParsing/createProps"
import { expandComponentDefinition } from "../userInterface/pagesParsing/types" import { expandComponentDefinition } from "../userInterface/pagesParsing/types"
import { import {
@ -156,6 +157,7 @@ const initialise = (store, initial) => async () => {
} }
initial.libraries = await loadLibs(appname, pkg) initial.libraries = await loadLibs(appname, pkg)
initial.generatorLibraries = await loadGeneratorLibs(appname, pkg) initial.generatorLibraries = await loadGeneratorLibs(appname, pkg)
initial.loadLibraryUrls = () => loadLibUrls(appname, pkg) initial.loadLibraryUrls = () => loadLibUrls(appname, pkg)
initial.appname = appname initial.appname = appname
@ -168,6 +170,7 @@ const initialise = (store, initial) => async () => {
initial.components = values(pkg.components.components).map( initial.components = values(pkg.components.components).map(
expandComponentDefinition expandComponentDefinition
) )
initial.builtins = [getBuiltin("##builtin/screenslot")]
initial.actions = values(pkg.appDefinition.actions) initial.actions = values(pkg.appDefinition.actions)
initial.triggers = pkg.appDefinition.triggers initial.triggers = pkg.appDefinition.triggers
@ -179,7 +182,6 @@ const initialise = (store, initial) => async () => {
} }
store.set(initial) store.set(initial)
return initial return initial
} }
@ -746,7 +748,9 @@ const getContainerComponent = components =>
const addChildComponent = store => componentName => { const addChildComponent = store => componentName => {
store.update(s => { store.update(s => {
const component = s.components.find(c => c.name === componentName) const component = componentName.startsWith("##")
? getBuiltin(componentName)
: s.components.find(c => c.name === componentName)
const newComponent = createProps(component) const newComponent = createProps(component)
s.currentComponentInfo._children = s.currentComponentInfo._children.concat( s.currentComponentInfo._children = s.currentComponentInfo._children.concat(

View file

@ -66,7 +66,7 @@
</li> </li>
</ul> </ul>
{#each lib.components.filter(_ => true) as component} {#each $store.builtins.concat(lib.components.filter(_ => true)) as component}
<div <div
class="component" class="component"
on:click={() => onComponentChosen(component.name)}> on:click={() => onComponentChosen(component.name)}>

View file

@ -3,6 +3,15 @@ import { types } from "./types"
import { assign } from "lodash" import { assign } from "lodash"
import { uuid } from "../../builderStore/uuid" import { uuid } from "../../builderStore/uuid"
export const getBuiltin = name => {
const { props } = createProps({ name })
return {
name,
props,
}
}
export const getNewScreen = (components, rootComponentName, name) => { export const getNewScreen = (components, rootComponentName, name) => {
const rootComponent = components.find(c => c.name === rootComponentName) const rootComponent = components.find(c => c.name === rootComponentName)
return { return {

File diff suppressed because one or more lines are too long