Add showAngles option to polygon locked figure#3481
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🗄️ Schema Change: Changes Detected
|
|
Size Change: +109 B (+0.02%) Total Size: 499 kB 📦 View Changed
ℹ️ View Unchanged
|
🛠️ Item Splitting: Changes Detected
|
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (126d673) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3481If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3481If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3481 |
|
I'll be following through with the CI failures next week! |
… option to polygon locked figure
SonicScrewdriver
left a comment
There was a problem hiding this comment.
This honestly looks great to me, thank you so much for getting this feature built!
I'm happy to approve as I only have a couple small change requests regarding piping through the showAngles value in the question builders, and the hard coded angle snapping.
I'll chat with you elsewhere about when to land/deploy this, as we'll need to coordinate with the platform team due to the schema changes — otherwise we could bring down publishing if we attempt to use the new value. ;)
| points: points, | ||
| color: "grayH", | ||
| showVertices: false, | ||
| showAngles: false, |
There was a problem hiding this comment.
We should pipe in the options.showAngles value here so that we can use the builder in tests/storybook. :)
| @@ -0,0 +1,157 @@ | |||
| import {render, screen} from "@testing-library/react"; | |||
There was a problem hiding this comment.
It seems like we were previously just using the global set of tests in locked-function.test.tsx, but I like the coverage and organization here, so I'm all far it. :)
| endPoints={[pt1, pt2]} | ||
| areEndPointsClockwise={clockwise(points)} | ||
| showAngles={showAngles} | ||
| snapTo="grid" |
There was a problem hiding this comment.
I'm noticing that you've hard-coded this to grid!
That's fine if that's all you will ever need for locked figures, but you may want to consider setting up the full angle snapping setting for locked polygons. If you don't need the full angle snapping logic, I'd love a comment here with a brief explanation for the hard coded value for our future selves. :)
| points: points, | ||
| color: "grayH", | ||
| showVertices: false, | ||
| showAngles: false, |
There was a problem hiding this comment.
We should pipe in the options.showAngles value here so that we can use the builder in tests/storybook. :) (For both builders)
Summary:
Extend the polygon locked figure to include a
showAnglesoption similar to the polygon interactive graph.I'm contributing upstream to Perseus becuase this feature would enable the Visual Output team to lean on Perseus for computing and displaying angles rather than trusting the LLM to do the math. I plan on following up with a change to allow these angle measure labels to be configurable per-vertex.
Feel free to nit-pick style / conventions, and let me know if I'm missing any tests!
Test plan:
pnpm lint && pnpm testonChangePropswhen toggled in locked polygon settings (mirrors existing test cases)packages/perseus/src/widgets/interactive-graphs/graphs/polygon.test.tsx