Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-cheetahs-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus-core": patch
---

Default addition to parser and editor for labels in locked figures
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,76 @@ describe("parseInteractiveGraphWidget", () => {
);
});

it("defaults color and size on a locked label when they are missing", () => {
const result = parse(
{
type: "interactive-graph",
options: {
step: [1, 1],
markings: "grid",
showProtractor: false,
range: [
[-10, 10],
[-10, 10],
],
showAxisArrows: {
xMin: true,
xMax: true,
yMin: true,
yMax: true,
},
showAxisTicks: {x: true, y: true},
correct: {
type: "linear",
},
lockedFigures: [
{
type: "label",
coord: [0, 0],
text: "A",
},
],
},
},
parseInteractiveGraphWidget,
);
expect(result).toEqual(
success({
type: "interactive-graph",
options: {
step: [1, 1],
markings: "grid",
showProtractor: false,
range: [
[-10, 10],
[-10, 10],
],
showAxisArrows: {
xMin: true,
xMax: true,
yMin: true,
yMax: true,
},
showAxisTicks: {x: true, y: true},
correct: {
type: "linear",
},
graph: {
type: "linear",
},
lockedFigures: [
{
type: "label",
coord: [0, 0],
text: "A",
color: "grayH",
size: "medium",
},
],
},
}),
);
});
it("parses alongEdge labelLocation correctly", () => {
const alongEdgeResult = parse(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,12 @@ const parseStrokeWeight = defaulted(
const parseLockedLabelType = object({
type: constant("label"),
coord: pairOfNumbers,
text: string,
color: parseLockedFigureColor,
size: enumeration("small", "medium", "large"),
text: defaulted(string, () => "label"),
color: defaulted(parseLockedFigureColor, () => "grayH" as const),
size: defaulted(
enumeration("small", "medium", "large"),
() => "medium" as const,
),
});

const parseLockedPointType = object({
Expand Down
Loading