-
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.
[Interactive Graph Editor] Implement the UI for adding start coords f…
…or circle graphs (#1453) ## Summary: Add the UI to specify start coords for Circle graph type. - Add the circle graph type to `start-coor-settings.tsx` - Create a `start-coords-circle.tsx` file with the main UI - Update the circle graph type so that `startCoords` includes both the center and the radius. - Update tests Issue: https://khanacademy.atlassian.net/browse/LEMS-2206 ## Test plan: `yarn jest` Storybook - Go to http://localhost:6006/?path=/story/perseuseditor-widgets-interactive-graph--interactive-graph-circle-with-starting-coords - Confirm that the preview shows the circle at the already set coords + radius - Confirm that the UI reflects these coords + radius - Press "Use default start coordinates" - Confirm that the circle goes to [0, 0] with a radius of 2. - Go to http://localhost:6006/?path=/story/perseuseditor-editorpage--demo - Create an interactive graph widget - Change the graph to circle type - Confirm that the start coords UI shows the center at [0, 0] with radius 2 <img width="384" alt="Screenshot 2024-07-25 at 4 29 34 PM" src="https://github.com/user-attachments/assets/8756f8f9-6a4c-40c0-b609-de10d7844612"> Author: nishasy Reviewers: nishasy, benchristel, SonicScrewdriver, Myranae Required Reviewers: Approved By: benchristel Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1453
- Loading branch information
Showing
12 changed files
with
228 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": minor | ||
"@khanacademy/perseus-editor": minor | ||
--- | ||
|
||
[Interactive Graph Editor] Implement the UI for adding start coords for circle 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
77 changes: 77 additions & 0 deletions
77
packages/perseus-editor/src/components/start-coords-circle.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,77 @@ | ||
import {View} from "@khanacademy/wonder-blocks-core"; | ||
import {TextField} from "@khanacademy/wonder-blocks-form"; | ||
import {Strut} from "@khanacademy/wonder-blocks-layout"; | ||
import {color, spacing} from "@khanacademy/wonder-blocks-tokens"; | ||
import {LabelLarge} from "@khanacademy/wonder-blocks-typography"; | ||
import {StyleSheet} from "aphrodite"; | ||
import * as React from "react"; | ||
|
||
import CoordinatePairInput from "./coordinate-pair-input"; | ||
|
||
import type {Coord, PerseusGraphType} from "@khanacademy/perseus"; | ||
|
||
type Props = { | ||
startCoords: { | ||
center: Coord; | ||
radius: number; | ||
}; | ||
// center: number; | ||
onChange: (startCoords: PerseusGraphType["startCoords"]) => void; | ||
}; | ||
|
||
const StartCoordsCircle = (props: Props) => { | ||
const {startCoords, onChange} = props; | ||
|
||
return ( | ||
<View style={styles.tile}> | ||
{/* Center */} | ||
<View style={styles.row}> | ||
<LabelLarge>Center:</LabelLarge> | ||
<Strut size={spacing.small_12} /> | ||
<CoordinatePairInput | ||
coord={startCoords.center} | ||
labels={["x", "y"]} | ||
onChange={(coord) => | ||
onChange({center: coord, radius: startCoords.radius}) | ||
} | ||
/> | ||
</View> | ||
<Strut size={spacing.small_12} /> | ||
|
||
{/* Radius */} | ||
<View style={styles.row}> | ||
<LabelLarge>Radius:</LabelLarge> | ||
<Strut size={spacing.small_12} /> | ||
<TextField | ||
value={startCoords.radius.toString()} | ||
type="number" | ||
onChange={(value) => { | ||
onChange({ | ||
center: startCoords.center, | ||
radius: parseFloat(value), | ||
}); | ||
}} | ||
style={styles.textField} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
tile: { | ||
backgroundColor: color.fadedBlue8, | ||
marginTop: spacing.xSmall_8, | ||
padding: spacing.small_12, | ||
borderRadius: spacing.xSmall_8, | ||
}, | ||
row: { | ||
flexDirection: "row", | ||
alignItems: "center", | ||
}, | ||
textField: { | ||
width: spacing.xxxLarge_64, | ||
}, | ||
}); | ||
|
||
export default StartCoordsCircle; |
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
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