-
Notifications
You must be signed in to change notification settings - Fork 350
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
Create UI for adding a locked point to interactive graph editor (mafs only) #1074
Conversation
Size Change: +1.73 kB (0%) Total Size: 812 kB
ℹ️ View Unchanged
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1074 +/- ##
==========================================
+ Coverage 67.28% 68.68% +1.39%
==========================================
Files 436 442 +6
Lines 96519 96885 +366
Branches 6720 10281 +3561
==========================================
+ Hits 64946 66543 +1597
+ Misses 31573 30342 -1231
... and 101 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
return ( | ||
<View style={styles.container}> | ||
<ActionMenu menuText="Add element" style={styles.addElementSelect}> | ||
{[ |
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.
Note: This needs the brackets because there's only one child. We can get rid of this after adding more types.
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.
:til: I would have used a fragment here.
@@ -43,6 +61,9 @@ describe("InteractiveGraphEditor", () => { | |||
|
|||
render( | |||
<InteractiveGraphEditor {...baseProps} onChange={onChangeMock} />, | |||
{ | |||
wrapper: RenderStateRoot, | |||
}, |
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.
Needed to add RenderStateRoot
because of the unique ID provider.
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.
:til: about render()
's wrapper
! Is it worth a render
helper in this test file?
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.
The click target was taking up the whole row when it wasn't supposed to. Figured I'd fix it really quickly while I was here.
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
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.
This looks good to me! Thanks for all the tests!
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.
Coooool. I left some comments, nothing that has to be done. :)
@@ -0,0 +1,42 @@ | |||
import {getValidNumberFromString, getDefaultFigureForFigureType} from "../util"; | |||
|
|||
describe("getValidNumberFromString", () => { |
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.
Thanks for adding tests for this!
@@ -0,0 +1,49 @@ | |||
/** | |||
* Dropdown for selecting a locked figure to add to an interactive graph. | |||
* Locked figures are elements (points, segmeents, etc.) that are not |
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.
* Locked figures are elements (points, segmeents, etc.) that are not | |
* Locked figures are elements (points, segments, etc.) that are not |
return ( | ||
<View style={styles.container}> | ||
<ActionMenu menuText="Add element" style={styles.addElementSelect}> | ||
{[ |
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.
:til: I would have used a fragment here.
|
||
{/* Coordinates */} | ||
<View> | ||
<View style={styles.row}> |
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.
thought: From a design perspective, I wonder if we should put the x and y coord inputs on the same row. Vertical space is so precious in our editors and so I think we should try to avoid scrolling if at all possible.
What do you think about something like this:
*Point*
Coordinate [x ] [y ]
Where the inputs would have a watermark/placeholder for which axis they're for? I think authors using this editor would understand "x" always comes first so even with data in the fields they'd likely understand it's an x, y coordinate pair.
<LockedFigureSettings | ||
key={`${uniqueId}-locked-${figure}-${index}`} | ||
{...figure} | ||
onRemove={() => removeLockedFigure(index)} |
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 have a possibly-unfounded concern that using indexes for these callbacks could be problematic. I know for react, you aren't supposed to use array indexes for keys. Does that apply here?
@@ -43,6 +61,9 @@ describe("InteractiveGraphEditor", () => { | |||
|
|||
render( | |||
<InteractiveGraphEditor {...baseProps} onChange={onChangeMock} />, | |||
{ | |||
wrapper: RenderStateRoot, | |||
}, |
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.
:til: about render()
's wrapper
! Is it worth a render
helper in this test file?
* Locked figures are graph elements (points, lines, line segmeents, | ||
* etc.) that are locked in place and not interactive. | ||
*/ | ||
lockedFigures?: Array<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.
lockedFigures?: Array<LockedFigure>; | |
lockedFigures?: ReadonlyArray<LockedFigure>; |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/perseus-dev-ui@1.3.0 ### Minor Changes - [#1071](#1071) [`eb637b35`](eb637b3) Thanks [@benchristel](https://github.com/benchristel)! - Add a "check answer" button to interactive graphs displayed in the dev flipbook UI ## @khanacademy/perseus@20.2.0 ### Minor Changes - [#1067](#1067) [`6196375a`](6196375) Thanks [@nishasy](https://github.com/nishasy)! - Can pass a point into `lockedFigures` into MafsGraph and a point will be displayed. - [#1074](#1074) [`a263e940`](a263e94) Thanks [@nishasy](https://github.com/nishasy)! - Add "add a locked figure" UI to interactive graph editor + adding points (mafs graphs only) ### Patch Changes - [#1068](#1068) [`881da724`](881da72) Thanks [@benchristel](https://github.com/benchristel)! - Adjust styling of the movable points and line segments on the Mafs segment graph - [#1071](#1071) [`eb637b35`](eb637b3) Thanks [@benchristel](https://github.com/benchristel)! - Add a "check answer" button to interactive graphs displayed in the dev flipbook UI - [#1073](#1073) [`ea0db7d9`](ea0db7d) Thanks [@benchristel](https://github.com/benchristel)! - Fix color of Mafs line segments ## @khanacademy/perseus-editor@5.1.0 ### Minor Changes - [#1074](#1074) [`a263e940`](a263e94) Thanks [@nishasy](https://github.com/nishasy)! - Add "add a locked figure" UI to interactive graph editor + adding points (mafs graphs only) ### Patch Changes - Updated dependencies \[[`881da724`](881da72), [`eb637b35`](eb637b3), [`6196375a`](6196375), [`a263e940`](a263e94), [`ea0db7d9`](ea0db7d)]: - @khanacademy/perseus@20.2.0 Author: khan-actions-bot Reviewers: benchristel Required Reviewers: Approved By: benchristel Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage, ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ⏭️ Publish npm snapshot, ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Extract i18n strings (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), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ gerald, ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x) Pull Request URL: #1069
Summary:
UI for adding a locked point to interactive graph editor! This will only be for mafs graphs as mafs graphs have a slightly different look and API (and also it was just not working very well with graphie anyway).
This UI includes:
The ability to change the color of a point is coming in a future PR.
Issue: LEMS-1813
Test plan:
yarn jest packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx
yarn jest packages/perseus-editor/src/components/__tests__/util.test.ts
Storybook
Demo:
Screen.Recording.2024-03-13.at.7.28.37.PM.mov