-
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.
Take 2: Grapher default widget options (#2157)
## Summary: This is an alternative for: #2146 In #2146 I tried to a direct move of logic from `perseus` to `perseus-core` to get the default widget options for Grapher. That required `defaultPlotProps` which required `maybePointsFromNormalized` which eventually required `kmath`. It was gross for a number of reasons: 1. I had to move a lot of utilities 2. I had to give `perseus-core` a dependency on `kmath` (and `perseus-core` probably shouldn't have dependencies) 3. There was a lot of misdirection and logic all to make one static object Whatever, I was okay hacking my way through that. _However_ we ended up with a circular dependency: `kmath` depends on `perseus-core` which was now depending on `kmath`. At this point I reflected on my life choices and thought "why are we using all of these utilities just to compute an unchanging object? Why am I moving all this logic just to generate 2 properties? So I just logged the default object and copied it to `perseus-core`. Issue: LEMS-2737 ## Test plan: Nothing should change, just copy/pasta-ing code. Author: handeyeco Reviewers: jeremywiebe Required Reviewers: Approved By: jeremywiebe Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2157
- Loading branch information
Showing
4 changed files
with
56 additions
and
13 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,6 @@ | ||
--- | ||
"@khanacademy/perseus-core": minor | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Move default widget options for Grapher to Perseus Core |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type {PerseusGrapherWidgetOptions} from "../../data-schema"; | ||
import type {WidgetLogic} from "../logic-export.types"; | ||
|
||
export type GrapherDefaultWidgetOptions = Pick< | ||
PerseusGrapherWidgetOptions, | ||
"graph" | "correct" | "availableTypes" | ||
>; | ||
|
||
const defaultWidgetOptions: GrapherDefaultWidgetOptions = { | ||
graph: { | ||
labels: ["x", "y"], | ||
range: [ | ||
[-10, 10], | ||
[-10, 10], | ||
], | ||
step: [1, 1], | ||
backgroundImage: { | ||
url: null, | ||
}, | ||
markings: "graph", | ||
rulerLabel: "", | ||
rulerTicks: 10, | ||
valid: true, | ||
showTooltips: false, | ||
}, | ||
correct: { | ||
type: "linear", | ||
coords: null, | ||
}, | ||
availableTypes: ["linear"], | ||
}; | ||
|
||
const grapherWidgetLogic: WidgetLogic = { | ||
name: "grapher", | ||
defaultWidgetOptions, | ||
}; | ||
|
||
export default grapherWidgetLogic; |
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