-
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.
[LEMS-2227-adjust-aphrodite-to-not-use-important] Merge branch 'main'…
… into LEMS-2227-adjust-aphrodite-to-not-use-important
- Loading branch information
Showing
33 changed files
with
581 additions
and
57 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,6 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
"@khanacademy/perseus-core": minor | ||
--- | ||
|
||
Implement a widget export function to filter out rubric data from widget options for the Sorter 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,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-core": minor | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Move default widget options for Grapher to Perseus Core |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
"@khanacademy/perseus-core": minor | ||
--- | ||
|
||
Implement a widget export function to filter out rubric data from widget options for the Dropdown 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
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
32 changes: 32 additions & 0 deletions
32
packages/perseus-core/src/widgets/dropdown/dropdown-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,32 @@ | ||
import getDropdownPublicWidgetOptions from "./dropdown-util"; | ||
|
||
import type {PerseusDropdownWidgetOptions} from "../../data-schema"; | ||
|
||
describe("getDropdownPublicWidgetOptions", () => { | ||
it("should return the correct public options without any answer data", () => { | ||
// Arrange | ||
const options: PerseusDropdownWidgetOptions = { | ||
choices: [ | ||
{content: "1", correct: false}, | ||
{content: "2", correct: false}, | ||
{content: "3", correct: true}, | ||
], | ||
placeholder: "Select an option", | ||
static: false, | ||
visibleLabel: "Test Label", | ||
ariaLabel: "Test Aria Label", | ||
}; | ||
|
||
// Act | ||
const publicWidgetOptions = getDropdownPublicWidgetOptions(options); | ||
|
||
// Assert | ||
expect(publicWidgetOptions).toEqual({ | ||
choices: [{content: "1"}, {content: "2"}, {content: "3"}], | ||
placeholder: "Select an option", | ||
static: false, | ||
visibleLabel: "Test Label", | ||
ariaLabel: "Test Aria Label", | ||
}); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
packages/perseus-core/src/widgets/dropdown/dropdown-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,31 @@ | ||
import type {PerseusDropdownWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
/** | ||
* For details on the individual options, see the | ||
* PerseusDropdownWidgetOptions type | ||
*/ | ||
type DropdownPublicWidgetOptions = { | ||
choices: ReadonlyArray<{content: string}>; | ||
placeholder: PerseusDropdownWidgetOptions["placeholder"]; | ||
static: PerseusDropdownWidgetOptions["static"]; | ||
visibleLabel?: PerseusDropdownWidgetOptions["visibleLabel"]; | ||
ariaLabel?: PerseusDropdownWidgetOptions["ariaLabel"]; | ||
}; | ||
|
||
/** | ||
* Given a PerseusDropdownWidgetOptions object, return a new object with only | ||
* the public options that should be exposed to the client. | ||
*/ | ||
function getDropdownPublicWidgetOptions( | ||
options: PerseusDropdownWidgetOptions, | ||
): DropdownPublicWidgetOptions { | ||
return { | ||
choices: options.choices.map((choice) => ({content: choice.content})), | ||
placeholder: options.placeholder, | ||
static: options.static, | ||
visibleLabel: options.visibleLabel, | ||
ariaLabel: options.ariaLabel, | ||
}; | ||
} | ||
|
||
export default getDropdownPublicWidgetOptions; |
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,38 @@ | ||
import type {PerseusGrapherWidgetOptions} from "../../data-schema"; | ||
import type {WidgetLogic} from "../logic-export.types"; | ||
|
||
export type GrapherDefaultWidgetOptions = Pick< | ||
PerseusGrapherWidgetOptions, | ||
"graph" | "correct" | "availableTypes" | ||
>; | ||
|
||
const defaultWidgetOptions: GrapherDefaultWidgetOptions = { | ||
graph: { | ||
labels: ["x", "y"], | ||
range: [ | ||
[-10, 10], | ||
[-10, 10], | ||
], | ||
step: [1, 1], | ||
backgroundImage: { | ||
url: null, | ||
}, | ||
markings: "graph", | ||
rulerLabel: "", | ||
rulerTicks: 10, | ||
valid: true, | ||
showTooltips: false, | ||
}, | ||
correct: { | ||
type: "linear", | ||
coords: null, | ||
}, | ||
availableTypes: ["linear"], | ||
}; | ||
|
||
const grapherWidgetLogic: WidgetLogic = { | ||
name: "grapher", | ||
defaultWidgetOptions, | ||
}; | ||
|
||
export default grapherWidgetLogic; |
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; | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/perseus-core/src/widgets/sorter/sorter-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,24 @@ | ||
import getSorterPublicWidgetOptions from "./sorter-util"; | ||
|
||
import type {PerseusSorterWidgetOptions} from "../../data-schema"; | ||
|
||
describe("getSorterPublicWidgetOptions", () => { | ||
it("should return the correct public options without any answer data", () => { | ||
// Arrange | ||
const options: PerseusSorterWidgetOptions = { | ||
correct: ["$15$ grams", "$55$ grams", "$0.005$ kilograms"], | ||
layout: "horizontal", | ||
padding: true, | ||
}; | ||
|
||
// Act | ||
const publicWidgetOptions = getSorterPublicWidgetOptions(options); | ||
|
||
// Assert | ||
expect(publicWidgetOptions).toEqual({ | ||
correct: ["$0.005$ kilograms", "$15$ grams", "$55$ grams"], | ||
layout: "horizontal", | ||
padding: true, | ||
}); | ||
}); | ||
}); |
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,30 @@ | ||
import type {PerseusSorterWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
/** | ||
* For details on the individual options, see the | ||
* PerseusSorterWidgetOptions type | ||
*/ | ||
type SorterPublicWidgetOptions = { | ||
correct: PerseusSorterWidgetOptions["correct"]; | ||
padding: PerseusSorterWidgetOptions["padding"]; | ||
layout: PerseusSorterWidgetOptions["layout"]; | ||
}; | ||
|
||
/** | ||
* Given a PerseusSorterWidgetOptions object, return a new object with only | ||
* the public options that should be exposed to the client. | ||
*/ | ||
function getSorterPublicWidgetOptions( | ||
options: PerseusSorterWidgetOptions, | ||
): SorterPublicWidgetOptions { | ||
return { | ||
// Note(Tamara): This does not provide correct answer information any longer. | ||
// To maintain compatibility with the original widget options, we are | ||
// keeping the key the same. Represents initial state of the cards here. | ||
correct: options.correct.slice().sort(), | ||
padding: options.padding, | ||
layout: options.layout, | ||
}; | ||
} | ||
|
||
export default getSorterPublicWidgetOptions; |
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
Oops, something went wrong.