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 Editor] Add the ability to reorder locked figure settings #1360

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

nishasy
Copy link
Contributor

@nishasy nishasy commented Jun 18, 2024

Summary:

Added some icon buttons so that content authors can reorder the locked figure
settings. This can be used to make sure that one figure can render on top
of another figure as desired. (The lower they are in the settings, the more
in the front they are on the graph.)

Note: I added more tests to the interactive-graph-editor-locked-figures.test.tsx file.
I think it's getting too long, so I'm considering breaking it up into a different file per
describe block in the future in its own PR.

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

Test plan:

yarn jest packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor-locked-figures.test.tsx

Play around with the buttons in the storybook file, as demonstrated in the videos below.

http://localhost:6006/?path=/story/perseuseditor-editorpage--mafs-with-locked-figures-m-2-flag

Videos

Reordering in editor

Screen.Recording.2024-06-18.at.4.14.18.PM.mov

Updating order on graph

Screen.Recording.2024-06-18.at.3.07.08.PM.mov

… only take degrees for the angle input

We had it so that locked ellipse settings allow for either degrees or radians
for the angel input. However, I realized that we're not saving the data for
what unit is being used. This means that if an angle were saved as "30 degrees"
and then the page were reloaded, it would then show up as "0.523599 radians".

For the sake of simplicty and consistency, I'm changing this so that it only
takes degrees, and I'm changing it to a number input since it no longer needs
to evaluate expressions with pi (that required it being a text input).

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

Test plan:
`yarn jest`

Storybook
- http://localhost:6006/?path=/story/perseuseditor-editorpage--mafs-with-locked-figures-m-2-flag
- Confirm that the ellipse settings angle input shows degrees only
- Confirm that it is rotated correctly
…ettings

Added some icon buttons so that content authors can reorder the locked figure
settings. This can be used to make sure that one figure can render on top
of another figure as desired. (The lower they are in the settings, the more
in the front they are on the graph.)

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

Test plan:
todo
@nishasy nishasy self-assigned this Jun 18, 2024
@nishasy nishasy requested review from mark-fitzgerald, benchristel and a team June 18, 2024 23:21
Copy link
Contributor

github-actions bot commented Jun 18, 2024

Size Change: +475 B (+0.06%)

Total Size: 846 kB

Filename Size Change
packages/perseus-editor/dist/es/index.js 272 kB +475 B (+0.18%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38.2 kB
packages/kmath/dist/es/index.js 4.26 kB
packages/math-input/dist/es/index.js 80.1 kB
packages/math-input/dist/es/strings.js 1.73 kB
packages/perseus-core/dist/es/index.js 906 B
packages/perseus-error/dist/es/index.js 866 B
packages/perseus-linter/dist/es/index.js 21.8 kB
packages/perseus/dist/es/index.js 407 kB
packages/perseus/dist/es/strings.js 3.21 kB
packages/pure-markdown/dist/es/index.js 3.67 kB
packages/simple-markdown/dist/es/index.js 12.4 kB

compressed-size-action

@nishasy nishasy marked this pull request as ready for review June 18, 2024 23:27
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 99.80545% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.78%. Comparing base (4bb2b87) to head (e79e001).
Report is 1 commits behind head on main.

Current head e79e001 differs from pull request most recent head 769f454

Please upload reports for the commit 769f454 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1360      +/-   ##
==========================================
+ Coverage   69.65%   70.78%   +1.13%     
==========================================
  Files         489      495       +6     
  Lines      103415   103850     +435     
  Branches     5280    10515    +5235     
==========================================
+ Hits        72033    73510    +1477     
+ Misses      31266    30340     -926     
+ Partials      116        0     -116     

Impacted file tree graph

Files Coverage Δ
...us-editor/src/components/coordinate-pair-input.tsx 100.00% <100.00%> (ø)
...-editor/src/components/defining-point-settings.tsx 100.00% <100.00%> (ø)
...-editor/src/components/locked-ellipse-settings.tsx 100.00% <100.00%> (ø)
...eus-editor/src/components/locked-figure-select.tsx 100.00% <100.00%> (ø)
.../src/components/locked-figure-settings-actions.tsx 100.00% <100.00%> (ø)
...s-editor/src/components/locked-figures-section.tsx 100.00% <100.00%> (+3.20%) ⬆️
...eus-editor/src/components/locked-line-settings.tsx 100.00% <100.00%> (ø)
...us-editor/src/components/locked-point-settings.tsx 100.00% <100.00%> (ø)
...-editor/src/components/locked-polygon-settings.tsx 100.00% <100.00%> (ø)
...s-editor/src/components/locked-vector-settings.tsx 98.12% <100.00%> (-1.88%) ⬇️
... and 3 more

... and 141 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a608098...769f454. Read the comment docs.

@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/neat-carrots-guess.md, packages/perseus-editor/src/components/defining-point-settings.tsx, packages/perseus-editor/src/components/locked-ellipse-settings.tsx, packages/perseus-editor/src/components/locked-figure-settings-actions.tsx, packages/perseus-editor/src/components/locked-figure-settings.tsx, packages/perseus-editor/src/components/locked-figures-section.tsx, packages/perseus-editor/src/components/locked-line-settings.tsx, packages/perseus-editor/src/components/locked-point-settings.tsx, packages/perseus-editor/src/components/locked-polygon-settings.tsx, packages/perseus-editor/src/components/locked-vector-settings.tsx, packages/perseus-editor/src/components/__stories__/locked-ellipse-settings.stories.tsx, packages/perseus-editor/src/components/__stories__/locked-line-settings.stories.tsx, packages/perseus-editor/src/components/__stories__/locked-point-settings.stories.tsx, packages/perseus-editor/src/components/__stories__/locked-polygon-settings.stories.tsx, packages/perseus-editor/src/components/__stories__/locked-vector-settings.stories.tsx, packages/perseus-editor/src/components/__tests__/locked-ellipse-settings.test.tsx, packages/perseus-editor/src/components/__tests__/locked-line-settings.test.tsx, packages/perseus-editor/src/components/__tests__/locked-point-settings.test.tsx, packages/perseus-editor/src/components/__tests__/locked-polygon-settings.test.tsx, packages/perseus-editor/src/components/__tests__/locked-vector-settings.test.tsx, packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor-locked-figures.test.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Member

@benchristel benchristel left a comment

Choose a reason for hiding this comment

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

Very cool! I left a couple suggestions inline, but I don't think this will need another round of review.

export type Props = Omit<
LockedFigureSettingsCommonProps,
"onMove" | "onRemove"
> &
Copy link
Member

Choose a reason for hiding this comment

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

Minor: I'd prefer to list the props explicitly instead of using Omit:

export type Props = LockedPointType & {
  expanded?: boolean;
  onToggle?: (expanded: boolean) => void;
  // ...
}

When I'm trying to use a component, I want to know what props I can/must pass. When I'm working on code inside a component, I want to know what props are available. Having all the props listed together, in the component file makes both of these tasks easier. Yes, the types are duplicated with this approach, but the typechecker will tell us if the duplicated types ever get out of sync.

<IconButton
icon={caretDoubleDownIcon}
size="small"
aria-label={`Move locked ${figureType} to the bottom`}
Copy link
Member

Choose a reason for hiding this comment

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

Minor: in graphics programs, the usual labels for these concepts are "bring to front" and "send to back". E.g. here's how Google Drawings does it:

Screen Shot 2024-06-20 at 11 05 40 AM

"front"/"forward"/"back"/"backward" might be more recognizable than "top"/"up"/"down"/"bottom".

…anded state array updated with the movement.
Copy link
Contributor

github-actions bot commented Jun 20, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1360

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

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

Base automatically changed from add-locked-polygon to main June 20, 2024 20:45
@nishasy
Copy link
Contributor Author

nishasy commented Jun 20, 2024

The parent pull-request (#1357) has been merged into main, but this branch (reorder) now has conflicts with the new base branch. These conflicts must be resolved before checks can complete on this pull-request.

@nishasy nishasy merged commit 753d6ea into main Jun 20, 2024
11 checks passed
@nishasy nishasy deleted the reorder branch June 20, 2024 20:54
nishasy added a commit that referenced this pull request Jun 20, 2024
…1365)

## Summary:
The action buttons that were added in #1360
need to be behind the m2 flag. Adding the check here.

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

## Test plan:
Storybook
- Go to http://localhost:6006/?path=/story/perseuseditor-editorpage--mafs-with-locked-figures-current
- It should not have the action buttons in the locked figure settings
- Go to http://localhost:6006/?path=/story/perseuseditor-editorpage--mafs-with-locked-figures-m-2-flag
- Expand all the locked figure settings.
- They should all have the action buttons.

### Current
<img width="371" alt="Screenshot 2024-06-20 at 2 02 23 PM" src="https://github.com/Khan/perseus/assets/13231763/97e9cca9-c0db-4900-8360-7eb6e67ba2dd">

### M2 flag
<img width="369" alt="Screenshot 2024-06-20 at 2 02 39 PM" src="https://github.com/Khan/perseus/assets/13231763/101941c8-b4f5-450f-b748-eda8ac2e61fa">

<img width="370" alt="Screenshot 2024-06-20 at 2 02 46 PM" src="https://github.com/Khan/perseus/assets/13231763/820cce4a-c54b-4c89-a94e-0db3579c8425">

Author: nishasy

Reviewers: mark-fitzgerald, benchristel

Required Reviewers:

Approved By: mark-fitzgerald

Checks: ✅ gerald, ✅ Upload Coverage (ubuntu-latest, 20.x), ⏭️  Publish npm snapshot, ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), 🚫 Upload Coverage, ✅ gerald, ⏭️  Publish npm snapshot, 🚫 Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), 🚫 Cypress (ubuntu-latest, 20.x), 🚫 Jest Coverage (ubuntu-latest, 20.x), 🚫 Check for .changeset entries for all changed files (ubuntu-latest, 20.x), 🚫 Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants