-
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.
[tb/LEMS-2597/dropdown-split-out-validation] Merge branch 'main' into…
… tb/LEMS-2597/dropdown-split-out-validation # Conflicts: # packages/perseus-core/src/index.ts
- Loading branch information
Showing
22 changed files
with
383 additions
and
43 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/kmath": patch | ||
--- | ||
|
||
Update repository information |
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-core": minor | ||
--- | ||
|
||
Create a function to get the public options for the LabelImage widget |
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] Allow axis tick labels to be multiples of pi |
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": major | ||
--- | ||
|
||
Removes the following deprecated exports from `@khanacademy/perseus`: `parsePerseusItem`, `parseAndMigratePerseusItem`, `parseAndMigratePerseusArticle`, `isSuccess`, `isFailure`, `Result`, `Success`, `Failure`. Clients should import these from `@khanacademy/perseus-core` instead. |
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
46 changes: 46 additions & 0 deletions
46
packages/perseus-core/src/widgets/label-image/label-image-util.test.ts
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,46 @@ | ||
import getLabelImagePublicWidgetOptions from "./label-image-util"; | ||
|
||
import type {PerseusLabelImageWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
describe("getLabelImagePublicWidgetOptions", () => { | ||
it("removes private fields", () => { | ||
const options: PerseusLabelImageWidgetOptions = { | ||
choices: ["right", "wrong"], | ||
markers: [ | ||
{ | ||
answers: ["right"], | ||
label: "", | ||
x: 0, | ||
y: 0, | ||
}, | ||
], | ||
imageUrl: "", | ||
imageHeight: 0, | ||
imageWidth: 0, | ||
imageAlt: "", | ||
hideChoicesFromInstructions: false, | ||
multipleAnswers: false, | ||
static: false, | ||
}; | ||
|
||
const publicWidgetOptions = getLabelImagePublicWidgetOptions(options); | ||
|
||
expect(publicWidgetOptions).toEqual({ | ||
choices: ["right", "wrong"], | ||
markers: [ | ||
{ | ||
label: "", | ||
x: 0, | ||
y: 0, | ||
}, | ||
], | ||
imageUrl: "", | ||
imageHeight: 0, | ||
imageWidth: 0, | ||
imageAlt: "", | ||
hideChoicesFromInstructions: false, | ||
multipleAnswers: false, | ||
static: false, | ||
}); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
packages/perseus-core/src/widgets/label-image/label-image-util.ts
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,41 @@ | ||
import type { | ||
PerseusLabelImageMarker, | ||
PerseusLabelImageWidgetOptions, | ||
} from "@khanacademy/perseus-core"; | ||
|
||
/** | ||
* For details on the individual options, see the | ||
* PerseusLabelImageWidgetOptions type | ||
*/ | ||
type LabelImagePublicWidgetOptions = { | ||
choices: PerseusLabelImageWidgetOptions["choices"]; | ||
imageUrl: PerseusLabelImageWidgetOptions["imageUrl"]; | ||
imageAlt: PerseusLabelImageWidgetOptions["imageAlt"]; | ||
imageHeight: PerseusLabelImageWidgetOptions["imageHeight"]; | ||
imageWidth: PerseusLabelImageWidgetOptions["imageWidth"]; | ||
markers: ReadonlyArray<LabelImageMarkerPublicData>; | ||
hideChoicesFromInstructions: PerseusLabelImageWidgetOptions["hideChoicesFromInstructions"]; | ||
multipleAnswers: PerseusLabelImageWidgetOptions["multipleAnswers"]; | ||
static: PerseusLabelImageWidgetOptions["static"]; | ||
}; | ||
|
||
type LabelImageMarkerPublicData = Pick< | ||
PerseusLabelImageMarker, | ||
"x" | "y" | "label" | ||
>; | ||
|
||
export default function getLabelImagePublicWidgetOptions( | ||
options: PerseusLabelImageWidgetOptions, | ||
): LabelImagePublicWidgetOptions { | ||
return { | ||
...options, | ||
markers: options.markers.map(getLabelImageMarkerPublicData), | ||
}; | ||
} | ||
|
||
function getLabelImageMarkerPublicData( | ||
marker: PerseusLabelImageMarker, | ||
): LabelImageMarkerPublicData { | ||
const {answers: _, ...publicData} = marker; | ||
return publicData; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {isPiMultiple} from "./math-utils"; | ||
|
||
describe("isPiMultiple", () => { | ||
test.each` | ||
case | number | ||
${"π"} | ${Math.PI} | ||
${"2π"} | ${Math.PI * 2} | ||
${"3π"} | ${Math.PI * 3} | ||
${"-π"} | ${Math.PI * -1} | ||
${"-2π"} | ${Math.PI * -2} | ||
${"π/2"} | ${Math.PI / 2} | ||
${"π/3"} | ${Math.PI / 3} | ||
${"π/4"} | ${Math.PI / 4} | ||
${"π/6"} | ${Math.PI / 6} | ||
${"2π/3"} | ${(Math.PI * 2) / 3} | ||
`("should return true for $case", ({number}) => { | ||
expect(isPiMultiple(number)).toBe(true); | ||
}); | ||
|
||
test.each` | ||
case | number | ||
${"0"} | ${0} | ||
${"1"} | ${1} | ||
${"-1"} | ${-1} | ||
${"3.14"} | ${3.14} | ||
${"3.14159"} | ${3.14159} | ||
${"2.5"} | ${2.5} | ||
${"-1.5"} | ${-1.5} | ||
`("should return false for $case", ({number}) => { | ||
expect(isPiMultiple(number)).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.