Skip to content

Commit

Permalink
Add a function to get the public options for a cs-program widget (#2178)
Browse files Browse the repository at this point in the history
CSProgram doesn't have any private options, so this is just the identity
function.

Issue: https://khanacademy.atlassian.net/browse/LEMS-2770

## Test plan:

`yarn test`

Author: benchristel

Reviewers: Myranae, handeyeco, jeremywiebe

Required Reviewers:

Approved By: Myranae

Checks: ✅ 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), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2178
  • Loading branch information
benchristel authored Feb 3, 2025
1 parent 43d8bc6 commit dbd4967
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/nasty-rockets-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": minor
"@khanacademy/perseus-core": minor
---

Create a function to get the public widget options for a CS widget.
1 change: 1 addition & 0 deletions packages/perseus-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export type * from "./widgets/logic-export.types";

export {default as getOrdererPublicWidgetOptions} from "./widgets/orderer/orderer-util";
export {default as getCategorizerPublicWidgetOptions} from "./widgets/categorizer/categorizer-util";
export {default as getCSProgramPublicWidgetOptions} from "./widgets/cs-program/cs-program-util";
export {default as getExpressionPublicWidgetOptions} from "./widgets/expression/expression-util";
export {default as getLabelImagePublicWidgetOptions} from "./widgets/label-image/label-image-util";
export {default as getSorterPublicWidgetOptions} from "./widgets/sorter/sorter-util";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type {PerseusCSProgramWidgetOptions} from "../../data-schema";

export default function getCSProgramPublicWidgetOptions(
options: PerseusCSProgramWidgetOptions,
): PerseusCSProgramWidgetOptions {
return options;
}
4 changes: 3 additions & 1 deletion packages/perseus/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
WidgetOptionsUpgradeMap,
getOrdererPublicWidgetOptions,
getCategorizerPublicWidgetOptions,
getCSProgramPublicWidgetOptions,
getExpressionPublicWidgetOptions,
getSorterPublicWidgetOptions,
getDropdownPublicWidgetOptions,
Expand Down Expand Up @@ -551,7 +552,8 @@ export type PublicWidgetOptionsFunction =
| typeof getOrdererPublicWidgetOptions
| typeof getExpressionPublicWidgetOptions
| typeof getLabelImagePublicWidgetOptions
| typeof getSorterPublicWidgetOptions;
| typeof getSorterPublicWidgetOptions
| typeof getCSProgramPublicWidgetOptions;

export type WidgetExports<
T extends React.ComponentType<any> & Widget = React.ComponentType<any>,
Expand Down
2 changes: 2 additions & 0 deletions packages/perseus/src/widgets/cs-program/cs-program.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* This widget is for embedding Khan Academy CS programs.
*/

import {getCSProgramPublicWidgetOptions} from "@khanacademy/perseus-core";
import {scoreCSProgram} from "@khanacademy/perseus-score";
import {StyleSheet, css} from "aphrodite";
import $ from "jquery";
Expand Down Expand Up @@ -204,4 +205,5 @@ export default {
// TODO(LEMS-2656): remove TS suppression
// @ts-expect-error: Type 'UserInput' is not assignable to type 'PerseusCSProgramUserInput'.
scorer: scoreCSProgram,
getPublicWidgetOptions: getCSProgramPublicWidgetOptions,
} satisfies WidgetExports<typeof CSProgram>;

0 comments on commit dbd4967

Please sign in to comment.