Simplify some block logic
This commit is contained in:
parent
e43aba075e
commit
76c0f24977
|
@ -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}>
|
||||
|
|
|
@ -14,13 +14,10 @@
|
|||
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 {
|
||||
$: id = block.id + rand
|
||||
$: instance = {
|
||||
_component: `@budibase/standard-components/${type}`,
|
||||
_id: id,
|
||||
_styles: {
|
||||
|
@ -30,7 +27,6 @@
|
|||
},
|
||||
...props,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Component {instance}>
|
||||
|
|
Loading…
Reference in New Issue