1
0
Fork 0

chore(markdown): Working on v3 docs

This commit is contained in:
Joost De Cock 2022-09-20 18:09:28 +02:00
parent 22680fbddc
commit 1f7ba79f81
17 changed files with 433 additions and 272 deletions

View file

@ -3,42 +3,55 @@ title: Design
order: 10
---
The `Design` object in FreeSewing's core library serves a single purpose:
To instantiate new pattern designs.
The `Design` named export in FreeSewing's core library serves a single purpose:
To create new pattern designs.
## Design constructor
```js
function freesewing.Design(
object config,
object|array plugins, // optional
object|array conditionalPlugins // optional
)
import { Design } from "@freesewing/core"
const Sorcha = new Design({
// design configuration here
})
```
This constructor creates a new pattern design.
It takes the following arguments:
It takes a single argument, an object holding the design's configuration.
- `config` : The pattern configuration
- `plugins` : Either a [plugin object](/guides/plugins/), or an array of plugin objects
- `conditionalPlugins` : Either a [conditional plugin object](/guides/plugins/conditionally-loading-build-time-plugins/), or an array
of conditional plugin objects to (conditionally) load in your pattern
## Design configuration
Since a design's configuration is managed at the part level,
the Design constructor only expects a `parts` attribute that should
hold an array of parts to include in the Design.
```js
import freesewing from "@freesewing/core"
import plugins from "@freesewing/plugin-bundle"
import config from "../config"
const Sorcha = new Design({
parts: [ front, back, sleeve ],
})
```
// Create new design
const Sorcha = new freesewing.Design(config, plugins)
<Tip>A Design in FreeSewing is little more than a container for various Parts</Tip>
Optionally, you can also pass it a `data` attrbute
to hold any custom data you'd like to add to your Design.
Any `data` you add to the Design constructor will be added
to [the Store](/reference/api/store).
```js
const Sorcha = new Design({
parts: [ front, back, sleeve ],
data: {
// Your custom data here
}
})
```
<Tip>
This method is a _super-constructor_. It will return a constructor
method that will become the default export of your design and
should be called to instantiate your pattern.
See [creating a new pattern design](/howtos/code/create-new-design) for a complete example.
This Design constructor is a _super-constructor_.
It will return a constructor method that will a pattern based on your design.
</Tip>