2022-02-05 17:44:23 +01:00
|
|
|
---
|
|
|
|
title: optionGroups
|
|
|
|
---
|
|
|
|
|
|
|
|
Option groups allow you to group options together when presenting them
|
|
|
|
to the user. They also support (one) level of sub-grouping which is
|
|
|
|
useful when your design has many options.
|
|
|
|
|
|
|
|
<Note>
|
|
|
|
|
|
|
|
##### This section applies to frontend integration
|
|
|
|
|
|
|
|
When you use FreeSewing patterns via the API -- in a backend NodeJS system
|
|
|
|
or on the command line for example -- all options can be used.
|
|
|
|
|
|
|
|
The conditional display of options is intended for frontend integration.
|
|
|
|
It is what's used on FreeSewing.org and our development environment alike, but
|
|
|
|
it is not intended as a way to block access to a given option. It merely hides it.
|
|
|
|
|
|
|
|
</Note>
|
|
|
|
|
|
|
|
## Structure
|
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
Option groups are stored under the `optionGroups` key in the pattern
|
2022-02-05 17:44:23 +01:00
|
|
|
configuration file.
|
|
|
|
|
|
|
|
They hold a plain object where each property can hold:
|
|
|
|
|
2022-02-20 14:44:38 +01:00
|
|
|
- An array of strings that are the names of the options to include in the group
|
|
|
|
- A plain object whose properties hold an array of strings that are the names
|
|
|
|
of the options to include in the group. (this creates a subgroup)
|
2022-02-05 17:44:23 +01:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```js
|
|
|
|
optionGroups: {
|
|
|
|
fit: [
|
|
|
|
'chestEase',
|
|
|
|
'waistEase',
|
|
|
|
],
|
|
|
|
style: [
|
|
|
|
'cuffStyle',
|
|
|
|
'hemStyle',
|
|
|
|
{
|
|
|
|
collar: [
|
|
|
|
'collarHeight',
|
|
|
|
'collarShape'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The configuration above will create the following structure:
|
|
|
|
|
2022-02-20 14:44:38 +01:00
|
|
|
- **fit**
|
|
|
|
- `chestEase`
|
|
|
|
- `waistEase`
|
|
|
|
- **style**
|
|
|
|
- `cuffStyle`
|
|
|
|
- `hemStyle`
|
|
|
|
- **collar**
|
|
|
|
- `collarHeight`
|
|
|
|
- `collarShape`
|