Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown story with answerless data #2305

Merged
merged 8 commits into from
Mar 19, 2025
5 changes: 5 additions & 0 deletions .changeset/quiet-insects-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": minor
---

Add a story for Dropdown that uses answerless data
4 changes: 4 additions & 0 deletions packages/perseus-core/src/utils/split-perseus-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {getUpgradedWidgetOptions} from "../widgets/upgrade";

import type {PerseusRenderer} from "../data-schema";

/**
* Upgrades widget options and removes answerful data for all the widgets in a
* Perseus item.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this comment!

export default function splitPerseusItem(
originalItem: PerseusRenderer,
): PerseusRenderer {
Expand Down
5 changes: 5 additions & 0 deletions packages/perseus/src/widgets/dropdown/dropdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {splitPerseusItem} from "@khanacademy/perseus-core";
import * as React from "react";

import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui";
Expand Down Expand Up @@ -41,3 +42,7 @@ export const DropdownWithEmptyPlaceholder = (
): React.ReactElement => {
return <RendererWithDebugUI question={dropdownWithEmptyPlaceholder} />;
};

export const DropdownWithNoAnswers = (args: StoryArgs): React.ReactElement => {
return <RendererWithDebugUI question={splitPerseusItem(basicDropdown)} />;
};
Loading