-
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.
[Hint Mode: Start Coords] Add start coords UI for quadratic graphs (#…
…1469) ## Summary: Add the UI to specify start coords for Quadratic graph type. - Add the quadratic graph type to start-coord-settings.tsx - Create a start-coords-quadratic.tsx file with the main UI - Add a utility for getting the quadratic equation from coordinates (less complex than the static method on InteractiveGraph that does the same) - Add quadratic graph to the phase 2 flag Issue: https://khanacademy.atlassian.net/browse/LEMS-2210 ## Test plan: `yarn jest` Storybook - http://localhost:6006/?path=/story/perseuseditor-widgets-interactive-graph--interactive-graph-quadratic-with-starting-coords Author: nishasy Reviewers: mark-fitzgerald, nishasy, benchristel Required Reviewers: Approved By: mark-fitzgerald Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ✅ gerald, ⏭️ Publish npm snapshot, ✅ Check builds for changes in size (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), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1469
- Loading branch information
Showing
9 changed files
with
252 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,6 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
"@khanacademy/perseus-editor": minor | ||
--- | ||
|
||
[Hint Mode: Start Coords] Add start coords UI for quadratic graphs |
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
95 changes: 95 additions & 0 deletions
95
packages/perseus-editor/src/components/start-coords-quadratic.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,95 @@ | ||
import {View} from "@khanacademy/wonder-blocks-core"; | ||
import {Strut} from "@khanacademy/wonder-blocks-layout"; | ||
import {color, font, spacing} from "@khanacademy/wonder-blocks-tokens"; | ||
import { | ||
BodyMonospace, | ||
LabelLarge, | ||
LabelMedium, | ||
} from "@khanacademy/wonder-blocks-typography"; | ||
import {StyleSheet} from "aphrodite"; | ||
import * as React from "react"; | ||
|
||
import CoordinatePairInput from "./coordinate-pair-input"; | ||
import {getQuadraticEquation} from "./util"; | ||
|
||
import type {Coord, PerseusGraphType} from "@khanacademy/perseus"; | ||
|
||
type Props = { | ||
startCoords: [Coord, Coord, Coord]; | ||
onChange: (startCoords: PerseusGraphType["startCoords"]) => void; | ||
}; | ||
|
||
const StartCoordsQuadratic = (props: Props) => { | ||
const {startCoords, onChange} = props; | ||
|
||
return ( | ||
<> | ||
{/* Current equation */} | ||
<View style={styles.equationSection}> | ||
<LabelMedium>Starting equation:</LabelMedium> | ||
<BodyMonospace style={styles.equationBody}> | ||
{getQuadraticEquation(startCoords)} | ||
</BodyMonospace> | ||
</View> | ||
|
||
{/* Points UI */} | ||
<View style={styles.tile}> | ||
<LabelLarge>Point 1:</LabelLarge> | ||
<Strut size={spacing.small_12} /> | ||
<CoordinatePairInput | ||
coord={startCoords[0]} | ||
labels={["x", "y"]} | ||
onChange={(value) => | ||
onChange([value, startCoords[1], startCoords[2]]) | ||
} | ||
/> | ||
</View> | ||
<View style={styles.tile}> | ||
<LabelLarge>Point 2:</LabelLarge> | ||
<Strut size={spacing.small_12} /> | ||
<CoordinatePairInput | ||
coord={startCoords[1]} | ||
labels={["x", "y"]} | ||
onChange={(value) => | ||
onChange([startCoords[0], value, startCoords[2]]) | ||
} | ||
/> | ||
</View> | ||
<View style={styles.tile}> | ||
<LabelLarge>Point 3:</LabelLarge> | ||
<Strut size={spacing.small_12} /> | ||
<CoordinatePairInput | ||
coord={startCoords[2]} | ||
labels={["x", "y"]} | ||
onChange={(value) => | ||
onChange([startCoords[0], startCoords[1], value]) | ||
} | ||
/> | ||
</View> | ||
</> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
tile: { | ||
backgroundColor: color.fadedBlue8, | ||
marginTop: spacing.xSmall_8, | ||
padding: spacing.small_12, | ||
borderRadius: spacing.xSmall_8, | ||
flexDirection: "row", | ||
alignItems: "center", | ||
}, | ||
equationSection: { | ||
marginTop: spacing.small_12, | ||
}, | ||
equationBody: { | ||
backgroundColor: color.fadedOffBlack8, | ||
border: `1px solid ${color.fadedOffBlack32}`, | ||
marginTop: spacing.xSmall_8, | ||
paddingLeft: spacing.xSmall_8, | ||
paddingRight: spacing.xSmall_8, | ||
fontSize: font.size.xSmall, | ||
}, | ||
}); | ||
|
||
export default StartCoordsQuadratic; |
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