1
0
Fork 0

feat(core): Added support for multiple sets of settings

This changes they was settings (what the user provides) are handled.
Before this, settings were passed as an object and that was it.
Now, settings are treated as an array of settings objects and this adds
full support for managing multiple sets of settings in a single pattern
instance.

This is the mechanism that's used for FreeSewing's sampling which used
to be a rather hackish implementation, but now merely sets up the
relevant list of settings, and then calls `pattern.draft()` as usual.

Things to be mindful of is that parts, the store and settings themselves
are tied to each set of settings. So where they used to be an object,
they are now an array of object.
This commit is contained in:
Joost De Cock 2022-09-17 10:24:13 +02:00
parent 11a2a1dd1c
commit 0b18d81e14
7 changed files with 397 additions and 252 deletions

View file

@ -10,12 +10,12 @@ export function Design(config) {
config = { ...loadDesignDefaults(), ...config }
// Create the pattern constructor
const pattern = function (settings) {
const pattern = function (...sets) {
// Pass the design config
Pattern.call(this, config)
// Pass the pattern settings
return this.__applySettings(settings)
return this.__applySettings(sets)
}
// Set up inheritance