-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
View a locked point with mafs (#1067)
## Summary: The ability to view a locked points was added as part of [LEMS-1702](https://khanacademy.atlassian.net/browse/LEMS-1702), but now that we've switched to mafs, we need to implement viewing a point again with mafs. - Add a layer for locked figures to the mafs graph - Createa a new component for said locked feature - Add an interactive graph story to confirm that locked points can be viewed Issue: https://khanacademy.atlassian.net/browse/LEMS-1702 ## Test plan: - Open http://localhost:6006/?path=/story/perseus-widgets-interactive-graph--segment-with-mafs-and-locked-points - Confirm that red points are there at (-7, -7) and (2, -5) - Drag the points of the line segment over the locked points and confirm that the blue points sit on top of the red points. (Check the interactive layer is on top of the locked layer.) [LEMS-1702]: https://khanacademy.atlassian.net/browse/LEMS-1702?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ### Story <img width="917" alt="Screenshot 2024-03-12 at 3 17 13 PM" src="https://github.com/Khan/perseus/assets/13231763/3045a9fe-8b17-4190-b73c-68d72159ae8e"> Author: nishasy Reviewers: benchristel, nishasy, mark-fitzgerald, jeremywiebe, nedredmond Required Reviewers: Approved By: jeremywiebe, nedredmond Checks: ✅ Upload Coverage, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Extract i18n strings (ubuntu-latest, 20.x), ✅ Cypress (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), ✅ gerald Pull Request URL: #1067
- Loading branch information
Showing
9 changed files
with
206 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
--- | ||
|
||
Can pass a point into `lockedFigures` into MafsGraph and a point will be displayed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/perseus/src/widgets/interactive-graphs/graph-locked-layer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {UnreachableCaseError} from "@khanacademy/wonder-stuff-core"; | ||
import {Point} from "mafs"; | ||
import * as React from "react"; | ||
|
||
import type {LockedFigure} from "../../perseus-types"; | ||
|
||
type Props = { | ||
lockedFigures: ReadonlyArray<LockedFigure>; | ||
}; | ||
|
||
const GraphLockedLayer = (props: Props) => { | ||
const {lockedFigures} = props; | ||
return ( | ||
<> | ||
{lockedFigures.map((figure, index) => { | ||
switch (figure.type) { | ||
case "point": | ||
const [x, y] = figure.coord; | ||
return ( | ||
<Point | ||
key={`${figure.type}-${index}`} | ||
x={x} | ||
y={y} | ||
svgCircleProps={{style: figure.style}} | ||
/> | ||
); | ||
} | ||
|
||
/** | ||
* Devlopment-time future-proofing: This `never` should | ||
* fail during type-checking if we add a new locked | ||
* shape type and forget to handle it in any other | ||
* switch case here. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
throw new UnreachableCaseError(figure.type); | ||
})} | ||
</> | ||
); | ||
}; | ||
|
||
export default GraphLockedLayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters