✨ Added support for loading defaults from recipe
This commit is contained in:
parent
391894b5a3
commit
3a20d35b56
6 changed files with 41 additions and 12 deletions
|
@ -1,7 +1,17 @@
|
|||
import optionType from "../optionType";
|
||||
|
||||
const optionDefault = option => {
|
||||
const optionDefault = (name, option, recipe) => {
|
||||
let type = optionType(option);
|
||||
let factor = type === "pct" ? 100 : 1;
|
||||
// Default from recipe?
|
||||
if (
|
||||
recipe &&
|
||||
typeof recipe.settings !== "undefined" &&
|
||||
typeof recipe.settings.options !== "undefined" &&
|
||||
typeof recipe.settings.options[name] !== "undefined"
|
||||
)
|
||||
return Math.round(10 * recipe.settings.options[name] * factor) / 10;
|
||||
|
||||
switch (type) {
|
||||
case "constant":
|
||||
return option;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue