Skip to content

Commit

Permalink
Merge branch 'main' into LEMS-2082-update-expression-attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
anakaren-rojas committed Jun 24, 2024
2 parents d5d4658 + 9615106 commit 076a10c
Show file tree
Hide file tree
Showing 27 changed files with 1,032 additions and 469 deletions.
5 changes: 0 additions & 5 deletions .changeset/funny-sheep-retire.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/giant-shoes-wait.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/neat-carrots-guess.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/nervous-owls-retire.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/shaggy-moles-promise.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/short-badgers-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": patch
"@khanacademy/perseus-editor": patch
---

[Interactive Graph] Update the interactive graph builder with all currently migrated graph types
5 changes: 0 additions & 5 deletions .changeset/smooth-worms-wave.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/sour-coats-agree.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/wild-gifts-grow.md

This file was deleted.

21 changes: 21 additions & 0 deletions packages/perseus-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# @khanacademy/perseus-editor

## 6.12.0

### Minor Changes

- [#1360](https://github.com/Khan/perseus/pull/1360) [`753d6eafe`](https://github.com/Khan/perseus/commit/753d6eafe9f18dd1ae00b4a092e765972a514370) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Editor] Add the ability to reorder locked figure settings

* [#1357](https://github.com/Khan/perseus/pull/1357) [`a60809858`](https://github.com/Khan/perseus/commit/a60809858f88ec6403c442e434aac98ecc6b6056) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Editor] UI for adding/editing/deleting a locked polygon

### Patch Changes

- [#1365](https://github.com/Khan/perseus/pull/1365) [`33adc625e`](https://github.com/Khan/perseus/commit/33adc625edae89540be22939cc0eea1cd573a46a) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Editor] Put the action buttons behind the m2 flag

* [#1368](https://github.com/Khan/perseus/pull/1368) [`86f94e126`](https://github.com/Khan/perseus/commit/86f94e126cedfc9d6c61735054c0d2bb619bc633) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - Organize locked figures within Interactive Graph into their own folders for better organization

- [#1366](https://github.com/Khan/perseus/pull/1366) [`1351ca38b`](https://github.com/Khan/perseus/commit/1351ca38b46901d1571d1c06a8234546560acc39) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Editor] Add the M2b flag in preparation for locked graphs, labels, and polygon markings.

* [#1372](https://github.com/Khan/perseus/pull/1372) [`8cbfeba12`](https://github.com/Khan/perseus/commit/8cbfeba12afea524d442a881e46ec8b76a62c134) Thanks [@nishasy](https://github.com/nishasy)! - [Storybook: Editor Page] Add a storybook-only preview for the questions and hints in the EditorPage component

* Updated dependencies [[`e5a2dd874`](https://github.com/Khan/perseus/commit/e5a2dd8747f3d2691161874923dbac9b4366d654), [`86f94e126`](https://github.com/Khan/perseus/commit/86f94e126cedfc9d6c61735054c0d2bb619bc633), [`753d6eafe`](https://github.com/Khan/perseus/commit/753d6eafe9f18dd1ae00b4a092e765972a514370), [`4bb2b8742`](https://github.com/Khan/perseus/commit/4bb2b8742c7396d212734aee34b5d64320ae1b18), [`e5a54d805`](https://github.com/Khan/perseus/commit/e5a54d805e8ec09b4641fbee8bc120e173a14ba6), [`c6c5064da`](https://github.com/Khan/perseus/commit/c6c5064da1f9e6a18c4cc49be073a198bcfb3be8), [`1351ca38b`](https://github.com/Khan/perseus/commit/1351ca38b46901d1571d1c06a8234546560acc39), [`a60809858`](https://github.com/Khan/perseus/commit/a60809858f88ec6403c442e434aac98ecc6b6056)]:
- @khanacademy/perseus@23.6.0

## 6.11.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Perseus editors",
"author": "Khan Academy",
"license": "MIT",
"version": "6.11.0",
"version": "6.12.0",
"publishConfig": {
"access": "public"
},
Expand All @@ -28,7 +28,7 @@
"@khanacademy/kas": "^0.3.9",
"@khanacademy/kmath": "^0.1.12",
"@khanacademy/math-input": "^19.1.0",
"@khanacademy/perseus": "^23.5.0",
"@khanacademy/perseus": "^23.6.0",
"@khanacademy/perseus-core": "1.4.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import {
Renderer,
type APIOptions,
type DeviceType,
type Hint,
type PerseusAnswerArea,
type PerseusRenderer,
} from "@khanacademy/perseus";
import Button from "@khanacademy/wonder-blocks-button";
import {View} from "@khanacademy/wonder-blocks-core";
import IconButton from "@khanacademy/wonder-blocks-icon-button";
import {Strut} from "@khanacademy/wonder-blocks-layout";
import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
import {LabelLarge} from "@khanacademy/wonder-blocks-typography";
import xIcon from "@phosphor-icons/core/regular/x.svg";
import {action} from "@storybook/addon-actions";
import {StyleSheet} from "aphrodite";
import * as React from "react";

// eslint-disable-next-line import/no-relative-packages
import {mockStrings} from "../../../perseus/src/strings";
import EditorPage from "../editor-page";

import {flags} from "./flags-for-api-options";

type Props = {
apiOptions?: APIOptions;
question?: PerseusRenderer;
hints?: ReadonlyArray<Hint>;
};

const onChangeAction = action("onChange");

function EditorPageWithStorybookPreview(props: Props) {
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>(
props.question,
);
const [hints, setHints] = React.useState<ReadonlyArray<Hint> | undefined>(
props.hints,
);

const [panelOpen, setPanelOpen] = React.useState<boolean>(true);

const apiOptions = props.apiOptions ?? {
isMobile: false,
flags,
};

return (
<View>
<EditorPage
apiOptions={apiOptions}
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);
}
}}
/>

{/* Button to open panel */}
{!panelOpen && (
<Button
onClick={() => setPanelOpen(!panelOpen)}
style={styles.openPanelButton}
>
Open preview (storybook only)
</Button>
)}

{/* Panel to show the question/hint previews */}
{panelOpen && (
<View style={styles.panel}>
{/* Close button */}
<IconButton
icon={xIcon}
onClick={() => setPanelOpen(!panelOpen)}
style={styles.closeButton}
/>

<View style={styles.panelInner}>
{/* Question preview */}
<Renderer
strings={mockStrings}
apiOptions={apiOptions}
{...question}
/>
</View>

{/* Hints preview */}
{hints?.map((hint, index) => (
<View key={index} style={styles.panelInner}>
<Strut size={spacing.medium_16} />
<LabelLarge>{`Hint ${index + 1}`}</LabelLarge>
<Renderer
strings={mockStrings}
apiOptions={apiOptions}
{...hint}
/>
</View>
))}
</View>
)}
</View>
);
}

const styles = StyleSheet.create({
panel: {
position: "fixed",
right: 0,
height: "90vh",
overflow: "auto",
flex: "none",
backgroundColor: color.fadedBlue16,
padding: spacing.medium_16,
borderRadius: spacing.small_12,
alignItems: "end",
},
panelInner: {
flex: "none",
backgroundColor: color.white,
borderRadius: spacing.xSmall_8,
marginTop: spacing.medium_16,
width: "100%",
padding: spacing.xSmall_8,
},
closeButton: {
margin: 0,
},
openPanelButton: {
position: "fixed",
right: spacing.medium_16,
// Extra space so it doesn't get covered up by storybook's
// "Style warnings" button.
bottom: spacing.xxxLarge_64,
},
});

export default EditorPageWithStorybookPreview;
Loading

0 comments on commit 076a10c

Please sign in to comment.