Skip to content
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

[Interactive Graph] Update protractor to new SVG #2263

Merged
merged 8 commits into from
Feb 26, 2025
Merged

Conversation

nishasy
Copy link
Contributor

@nishasy nishasy commented Feb 21, 2025

Summary:

The old protractor looked awful. We got a request to use a protractor
with two rows of numbers going in opposite directions (previously
there was only one direction).

  • Update the protractor to a new SVG with numbers going both ways

Note: The numbers are kind of hard to read over the axes. I tried to add
white backgrounds to the numbers, but it's unfortunately not as easy as
it looks. Since this is not a regression, I left it as is.

Issue: https://khanacademy.atlassian.net/browse/LEMS-2863

Test plan:

Storybook

Before After
image image

The old protractor looked awful. We got a request to use a protractor
with two rows of numbers going in opposite directions (previously
there was only one direction).

- Update the protractor to a new SVG with numbers going both ways

Note: The numbers are kind of hard to read over the axes. I tried to add
white backgrounds to the numbers, but it's unfortunately not as easy as
it looks. Since this is not a regression, I left it as is.

Note 2: There is a noticable performance hit with this implementation.
If someone has ideas for how to improve the performance, please let me know!

Issue: https://khanacademy.atlassian.net/browse/LEMS-2863

Test plan:
Storybook
- https://khan.github.io/perseus/?path=/story/perseus-widgets-interactive-graph-visual-regression-tests--mafs-with-protractor
@nishasy nishasy self-assigned this Feb 21, 2025
Copy link
Contributor

github-actions bot commented Feb 21, 2025

Size Change: +1 B (0%)

Total Size: 872 kB

Filename Size Change
packages/perseus/dist/es/index.js 367 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39.5 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 11.1 kB
packages/math-input/dist/es/index.js 78.2 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 29.8 kB
packages/perseus-editor/dist/es/index.js 276 kB
packages/perseus-linter/dist/es/index.js 22.8 kB
packages/perseus-score/dist/es/index.js 20.6 kB
packages/perseus/dist/es/strings.js 6.74 kB
packages/pure-markdown/dist/es/index.js 4.14 kB
packages/simple-markdown/dist/es/index.js 13.1 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Feb 21, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (67965da) and published it to npm. You
can install it using the tag PR2263.

Example:

pnpm add @khanacademy/perseus@PR2263

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2263

@nishasy nishasy marked this pull request as ready for review February 24, 2025 20:09
Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I had two thoughts (neither of which are blocking):

  1. This increases the bundle size by about 45kb. Previously we loaded the protractor image remotely which meant that the image size didn't increase the main Perseus bundle size. Perhaps you could touch base with FEI to see their thoughts on something like this? I think it makes sense to embed the SVG ... and perhaps the gzip compression we apply when serving the JS bundles will negate the increase.
  2. Should we change the mouse cursor to the move handle instead the default arrow? I notice for other movables in the graph we do that, but not when moving the protractor. This seems like a new change, but it felt "off" that the mouse cursor didn't change to show I could drag the protractor (but it did for the double-ended arrow that allows me to rotate the protractor)

Also, for posterity, here's the Chromatic publish of Storybook with the new Protractor SVG: https://650db21c3f5d1b2f13c02952-bhaakpommq.chromatic.com/?path=/story/perseus-widgets-interactive-graph-visual-regression-tests--mafs-with-protractor

Comment on lines 243 to 247
stroke: #808080;
}

.MafsView .interactive-graph-protractor .protractor-number {
fill: #21242c;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two colours represented in CSS variables? It's likely not worth the effort to create them if they don't exist given that the Protractor isn't a tool we want to encourage new usages of, though.

@nishasy nishasy requested a review from jeremywiebe February 25, 2025 21:25
@nishasy
Copy link
Contributor Author

nishasy commented Feb 25, 2025

Latest storybook publish

@nishasy nishasy requested a review from a team February 25, 2025 23:10
Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Round II. Still looks good. 😁

@nishasy nishasy merged commit 4dde998 into main Feb 26, 2025
8 checks passed
@nishasy nishasy deleted the update-protractor branch February 26, 2025 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants