1
0
Fork 0

chore(core): Use hide, not render

This commit is contained in:
Joost De Cock 2022-09-18 17:01:19 +02:00
parent 026560ef24
commit 5dc7401308
82 changed files with 337 additions and 293 deletions
packages/core/src

View file

@ -128,19 +128,19 @@ Pattern.prototype.draft = function () {
}
} else this.stores[set].log.error(`Unable to draft pattern. Part.draft() is not callable`)
try {
this.parts[set][partName].render =
this.parts[set][partName].render === false ? false : this.__wants(partName, set)
this.parts[set][partName].hidden =
this.parts[set][partName].hidden === true ? true : !this.__wants(partName, set)
} catch (err) {
this.stores[set].log.error([
`Unable to set \`render\` property on part \`${partName}\``,
`Unable to set \`hidden\` property on part \`${partName}\``,
err,
])
}
} else {
this.stores[set].log.debug(
`Part \`${partName}\` is not needed. Skipping draft and setting render to \`false\``
`Part \`${partName}\` is not needed. Skipping draft and setting hidden to \`true\``
)
this.parts[set][partName].render = false
this.parts[set][partName].hidden = true
}
}
this.__runHooks('postDraft')
@ -149,6 +149,15 @@ Pattern.prototype.draft = function () {
return this
}
/**
* Return the initialized configuration
*
* @return {object} config - The initialized config
*/
Pattern.prototype.getConfig = function () {
return this.init().config
}
/** Returns props required to render this pattern through
* an external renderer (eg. a React component)
*
@ -176,7 +185,7 @@ Pattern.prototype.getRenderProps = function () {
}))
props.parts = {}
for (let p in this.parts) {
if (this.parts[p].render) {
if (!this.parts[p].hidden) {
props.parts[p] = {
paths: this.parts[p].paths,
points: this.parts[p].points,