-
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 sinusoid graphs (#1468
) ## Summary: Add the UI to specify start coords for Sinusoid graph type. - Add the sinusoid graph type to start-coord-settings.tsx - Create a start-coords-sinusoid.tsx file with the main UI - Add a utility for getting the sinusoid equation from coordinates (less complex than the static method on InteractiveGraph that does the same) - Add start coords UI phase 2 flag Issue: https://khanacademy.atlassian.net/browse/LEMS-2207 ## Test plan: `yarn jest` Storybook - http://localhost:6006/?path=/story/perseuseditor-widgets-interactive-graph--interactive-graph-sinusoid-with-starting-coords Author: nishasy Reviewers: nishasy, mark-fitzgerald, benchristel Required Reviewers: Approved By: mark-fitzgerald Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ✅ gerald, ⏭️ Publish npm snapshot, ✅ Lint, Typecheck, Format, and Test (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), ✅ Cypress (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: #1468
- Loading branch information
Showing
12 changed files
with
294 additions
and
8 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 sinusoid 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
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
80 changes: 80 additions & 0 deletions
80
packages/perseus-editor/src/components/start-coords-sinusoid.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,80 @@ | ||
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 {getSinusoidEquation} from "./util"; | ||
|
||
import type {Coord, PerseusGraphType} from "@khanacademy/perseus"; | ||
|
||
type Props = { | ||
startCoords: [Coord, Coord]; | ||
onChange: (startCoords: PerseusGraphType["startCoords"]) => void; | ||
}; | ||
|
||
const StartCoordsSinusoid = (props: Props) => { | ||
const {startCoords, onChange} = props; | ||
|
||
return ( | ||
<> | ||
{/* Current equation */} | ||
<View style={styles.equationSection}> | ||
<LabelMedium>Starting equation:</LabelMedium> | ||
<BodyMonospace style={styles.equationBody}> | ||
{getSinusoidEquation(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]])} | ||
/> | ||
</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])} | ||
/> | ||
</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 StartCoordsSinusoid; |
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
Oops, something went wrong.