-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary: Adds a simple Story for the `EditorPage` component. This is basically the top-level Exercise Editor. <img width="800" alt="image" src="https://github.com/Khan/perseus/assets/77138/7699c14e-25f5-4d68-9395-d487e5ebda1f"> Issue: "none" ## Test plan: Author: jeremywiebe Reviewers: nedredmond, handeyeco Required Reviewers: Approved By: nedredmond Checks: ✅ codecov/project, ❌ codecov/patch, ✅ Upload Coverage, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Extract i18n strings (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #887
- Loading branch information
1 parent
8e0eb5b
commit d09fdb9
Showing
7 changed files
with
93 additions
and
24 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-editor": patch | ||
--- | ||
|
||
Add Storybook story for EditorPage component |
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": patch | ||
--- | ||
|
||
Export `PerseusItem` type which represents an exercise question |
65 changes: 65 additions & 0 deletions
65
packages/perseus-editor/src/__stories__/editor-page.stories.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,65 @@ | ||
import {action} from "@storybook/addon-actions"; | ||
import * as React from "react"; | ||
|
||
import {EditorPage} from ".."; | ||
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing"; | ||
|
||
import type { | ||
DeviceType, | ||
Hint, | ||
PerseusAnswerArea, | ||
PerseusRenderer, | ||
} from "@khanacademy/perseus"; | ||
|
||
registerAllWidgetsAndEditorsForTesting(); // SIDE_EFFECTY!!!! :cry: | ||
|
||
export default { | ||
title: "Perseus/Editor/EditorPage", | ||
}; | ||
|
||
const onChangeAction = action("onChange"); | ||
|
||
export const Demo = (): React.ReactElement => { | ||
const [previewDevice, setPreviewDevice] = | ||
React.useState<DeviceType>("phone"); | ||
const [jsonMode, setJsonMode] = React.useState<boolean | undefined>(false); | ||
const [answerArea, setAnswerArea] = React.useState< | ||
PerseusAnswerArea | undefined | null | ||
>(); | ||
const [question, setQuestion] = React.useState< | ||
PerseusRenderer | undefined | ||
>(); | ||
const [hints, setHints] = React.useState<ReadonlyArray<Hint> | undefined>(); | ||
|
||
return ( | ||
<EditorPage | ||
apiOptions={{isMobile: false}} | ||
previewDevice={previewDevice} | ||
onPreviewDeviceChange={(newDevice) => setPreviewDevice(newDevice)} | ||
developerMode={true} | ||
jsonMode={jsonMode} | ||
answerArea={answerArea} | ||
question={question} | ||
hints={hints} | ||
frameSource="about:blank" | ||
previewURL="about:blank" | ||
itemId="1" | ||
onChange={(props) => { | ||
onChangeAction(props); | ||
|
||
if ("jsonMode" in props) { | ||
setJsonMode(props.jsonMode); | ||
} | ||
if ("answerArea" in props) { | ||
setAnswerArea(props.answerArea); | ||
} | ||
if ("question" in props) { | ||
setQuestion(props.question); | ||
} | ||
if ("hints" in props) { | ||
setHints(props.hints); | ||
} | ||
}} | ||
/> | ||
); | ||
}; |
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