-
Notifications
You must be signed in to change notification settings - Fork 354
Resolve some TODO comments in the Perseus JSON parsing code #2380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Size Change: -89 B (-0.02%) Total Size: 466 kB
ℹ️ View Unchanged
|
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (5482421) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR2380 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.js -t PR2380 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/perseus-core/src/parse-perseus-json/exhaustive-test-tool/index.ts
Outdated
Show resolved
Hide resolved
packages/perseus-core/src/parse-perseus-json/perseus-parsers/interactive-graph-widget.ts
Show resolved
Hide resolved
@@ -32,7 +32,5 @@ export const parseMeasurerWidget: Parser<MeasurerWidget> = parseWidget( | |||
rulerPixels: number, | |||
rulerLength: number, | |||
box: pair(number, number), | |||
// TODO(benchristel): static is not used. Remove it? | |||
static: defaulted(boolean, () => false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! My guess is that this snuck into the object data at some point by accident.
@@ -163,7 +163,7 @@ type RenderProps = { | |||
* Shapes (points, chords, etc) displayed on the graph that cannot be moved | |||
* by the user. | |||
*/ | |||
lockedFigures?: ReadonlyArray<LockedFigure>; | |||
lockedFigures: ReadonlyArray<LockedFigure>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that these parsers are giving us the ability to make the production code safer/cleaner!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
@@ -1192,9 +1192,6 @@ export type PerseusMeasurerWidgetOptions = { | |||
rulerLength: number; | |||
// Containing area [width, height] | |||
box: [number, number]; | |||
// TODO(benchristel): static is not used. Remove it? | |||
// Always false. Not used for this widget | |||
static: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, static
is so annoying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to remind you to add back coords
in interactive graph and to point out some checks need to be fixed. Also, since data-schema changed, we might need to inform CP, iirc? Just one NB question, but looks good otherwise :)
{props.lockedFigures && ( | ||
<GraphLockedLabelsLayer | ||
lockedFigures={props.lockedFigures} | ||
/> | ||
)} | ||
<GraphLockedLabelsLayer | ||
lockedFigures={props.lockedFigures} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So before when lockedFigures
was optional, if it was falsy in some way, then this GraphLockedLabelsLayer
element wouldn't be included. Now it's always included. Could that cause any side effects with interaction or the UI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this would render in the DOM if lockedFigures
length is 0, because the outermost layer in packages/perseus/src/widgets/interactive-graphs/graph-locked-labels-layer.tsx
is a React fragment. It only renders the actual labels themselves if there are any.
So I think this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Looks good to me.
I added one question for my own understanding, but I don't anticipate it being a problem.
{props.lockedFigures && ( | ||
<GraphLockedLabelsLayer | ||
lockedFigures={props.lockedFigures} | ||
/> | ||
)} | ||
<GraphLockedLabelsLayer | ||
lockedFigures={props.lockedFigures} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this would render in the DOM if lockedFigures
length is 0, because the outermost layer in packages/perseus/src/widgets/interactive-graphs/graph-locked-labels-layer.tsx
is a React fragment. It only renders the actual labels themselves if there are any.
So I think this is fine.
@@ -782,7 +782,7 @@ export type PerseusInteractiveGraphWidgetOptions = { | |||
correct: PerseusGraphType; | |||
// Shapes (points, chords, etc) displayed on the graph that cannot | |||
// be moved by the user. | |||
lockedFigures?: ReadonlyArray<LockedFigure>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very exciting! The rest of the code for making lockedFigures
required makes sense to me. Same for labels
.
Only one question for my own understanding: Is there any possibility of this causing issues for old exercise items that saved this as null
or undefined
? Or would that be fixed by the parser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will be fixed up by the parser! It will default null and undefined to an empty array.
2577f55
to
09e5097
Compare
bcb6197
to
d36f830
Compare
…s of PerseusInteractiveGraphWidgetOptions.lockedFigures
0ecb683
to
5482421
Compare
Issue: none
Test plan:
pnpm test