Skip to content

Commit

Permalink
fix: make require right/wrongAnswer.mp3 work in production AND storybook
Browse files Browse the repository at this point in the history
(With Andrew)
  • Loading branch information
JohnThomson committed Aug 26, 2024
1 parent 5f47999 commit 4bb86ec
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/activities/ActivityContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ export class ActivityContext {
// NB: if this stops working in storybook; the file should be found because the package.json
// script that starts storybook has a "--static-dir" option that should include the folder
// containing the standard activity sounds.
// require on an mp3 gives us some sort of module object where the url of the sound is its 'default'
this.playSound(rightAnswer.default);
// require on an mp3 in storybook gives us some sort of module object where the url of the sound is its 'default'
// whatever we're doing to build the production version, require on the mp3 gives us the url directly.
this.playSound(rightAnswer.default ?? rightAnswer);
}

public playWrong() {
// require on an mp3 gives us some sort of module object where the url of the sound is its 'default'
this.playSound(wrongAnswer.default);
// whatever we're doing to build the production version, require on the mp3 gives us the url directly.
this.playSound(wrongAnswer.default ?? wrongAnswer);
}

private getPagePlayer(): any {
Expand Down

0 comments on commit 4bb86ec

Please sign in to comment.