1
0
Fork 0
mirror of synced 2024-06-14 00:14:39 +12:00

Simplify some block logic

This commit is contained in:
Andrew Kingston 2021-11-02 12:58:38 +00:00
parent ee7ab70f4d
commit 212e62b62e
2 changed files with 10 additions and 16 deletions

View file

@ -7,9 +7,7 @@
// We need to set a block context to know we're inside a block, but also
// to be able to reference the actual component ID of the block from
// any depth
setContext("block", {
id: $component.id,
})
setContext("block", { id: $component.id })
</script>
<div use:styleable={$component.styles}>

View file

@ -14,22 +14,18 @@
const block = getContext("block")
const rand = generate()
$: id = block.id + rand
$: instance = createInstance(type, props, id)
// Create a fake component instance so that we can use the core Component
// to render this part of the block, taking advantage of binding enrichment
const createInstance = (type, props, id) => {
return {
_component: `@budibase/standard-components/${type}`,
_id: id,
_styles: {
normal: {
...styles,
},
$: id = block.id + rand
$: instance = {
_component: `@budibase/standard-components/${type}`,
_id: id,
_styles: {
normal: {
...styles,
},
...props,
}
},
...props,
}
</script>