Skip to content

Commit

Permalink
Default buttonSets
Browse files Browse the repository at this point in the history
  • Loading branch information
benchristel committed Dec 5, 2024
1 parent d4ee47a commit 0d4a5cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ function removeInvalidAnswerForms(
return valid;
}

const buttonSet = enumeration(
"basic",
"basic+div",
"trig",
"prealgebra",
"logarithms",
"basic relations",
"advanced relations",
);

// This default is copied from the default props of the Expression component.
// See parse-perseus-json/README.md for why the default is duplicated here.
const defaultButtonSets = () => ["basic", "trig", "prealgebra", "logarithms"] as const;

const version1 = object({major: constant(1), minor: number});
const parseExpressionWidgetV1: Parser<ExpressionWidget> =
parseWidgetWithVersion(
Expand All @@ -67,17 +81,7 @@ const parseExpressionWidgetV1: Parser<ExpressionWidget> =
times: boolean,
visibleLabel: optional(string),
ariaLabel: optional(string),
buttonSets: array(
enumeration(
"basic",
"basic+div",
"trig",
"prealgebra",
"logarithms",
"basic relations",
"advanced relations",
),
),
buttonSets: defaulted(array(buttonSet), defaultButtonSets),
buttonsVisible: optional(enumeration("always", "never", "focused")),
}),
);
Expand All @@ -94,17 +98,7 @@ const parseExpressionWidgetV0 = parseWidgetWithVersion(
form: boolean,
simplify: boolean,
value: string,
buttonSets: array(
enumeration(
"basic",
"basic+div",
"trig",
"prealgebra",
"logarithms",
"basic relations",
"advanced relations",
),
),
buttonSets: defaulted(array(buttonSet), defaultButtonSets),
buttonsVisible: optional(enumeration("always", "never", "focused")),
}),
);
Expand Down

0 comments on commit 0d4a5cd

Please sign in to comment.