feat(markdown): Ported code howtos to v3
This commit is contained in:
parent
d1edf93750
commit
af99d3e8c0
25 changed files with 451 additions and 636 deletions
|
@ -1,16 +1,26 @@
|
|||
---
|
||||
title: Accessing user options
|
||||
for: developers
|
||||
about: Shows you how to access user options from inside your pattern
|
||||
title: Accessing options
|
||||
---
|
||||
|
||||
Options are stored in `pattern.settings.options`.
|
||||
(the value of) Options are available on the `options` key of from the object
|
||||
passed to your part's draft method. You can destructure them for easy access.
|
||||
|
||||
You can pull them out of there with
|
||||
the [shorthand](/howtos/code/shorthand/) call:
|
||||
```design/src/part.mjs
|
||||
function draftPart = ({
|
||||
// highlight-start
|
||||
options,
|
||||
// highlight-end
|
||||
part
|
||||
}) {
|
||||
|
||||
```js
|
||||
const { measurements, options } = part.shorthand()
|
||||
// Do something here
|
||||
|
||||
let sleeveBonus = measurements.shoulderToWrist * (1 + options.sleeveLengthBonus);
|
||||
return part
|
||||
}
|
||||
```
|
||||
|
||||
<Note>
|
||||
|
||||
Unlike measurements, options come with default values.
|
||||
|
||||
</Note>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue