-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added plugin data lookup to audio links page [PT-187885744]
- Loading branch information
1 parent
c54071f
commit 3470db6
Showing
10 changed files
with
305 additions
and
66 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
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
25 changes: 25 additions & 0 deletions
25
js/containers/glossary-audio/components/glossary-word-button.tsx
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,25 @@ | ||
import React, { useMemo } from "react"; | ||
import { CurrentWord } from "../glossary-audio-app"; | ||
|
||
import css from "../../../../css/glossary-audio/glossary-word.less"; | ||
|
||
type Props = { | ||
word: string; | ||
index: number; | ||
currentWord?: CurrentWord; | ||
onClick: (word: string, index: number) => void; | ||
} | ||
|
||
function GlossaryWordButton({word, index, currentWord, onClick}: Props) { | ||
const handleClick = () => onClick(word, index); | ||
|
||
const isPlaying = useMemo(() => currentWord && currentWord.word === word && currentWord.index === index && currentWord.playing, [currentWord, word, index]); | ||
|
||
const className = `${css.button} ${isPlaying ? css.playing : ""}`; | ||
if (isPlaying) { | ||
return <button className={className} onClick={handleClick}>Stop</button>; | ||
} | ||
return <button className={className} onClick={handleClick}>Play</button>; | ||
} | ||
|
||
export default GlossaryWordButton; |
24 changes: 10 additions & 14 deletions
24
js/containers/glossary-audio/components/glossary-word.tsx
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
29 changes: 29 additions & 0 deletions
29
js/containers/glossary-audio/hooks/use-glossary-audio-params.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,29 @@ | ||
export type GlossaryAudioDemoParams = { | ||
demo: true; | ||
} | ||
|
||
export type GlossaryAudioPortalParams = { | ||
demo: false; | ||
sourceKey: string; | ||
pluginDataKey: string; | ||
portalUrl: string; | ||
studentId: string; | ||
classId: string; | ||
offeringId: string; | ||
} | ||
|
||
export type GlossaryAudioParams = GlossaryAudioDemoParams | GlossaryAudioPortalParams | ||
|
||
export const useGlossaryAudioParams = (): GlossaryAudioParams => { | ||
const params = new URLSearchParams(window.location.search); | ||
const sourceKey = params.get("sourceKey") ?? undefined; | ||
const portalUrl = params.get("portalUrl") ?? undefined; | ||
const pluginDataKey = params.get("pluginDataKey") ?? undefined; | ||
const studentId = params.get("studentId") ?? undefined; | ||
const classId = params.get("classId") ?? undefined; | ||
const offeringId = params.get("offeringId") ?? undefined; | ||
if (sourceKey !== undefined && portalUrl !== undefined && pluginDataKey !== undefined && studentId !== undefined && classId !== undefined && offeringId !== undefined) { | ||
return {demo: false, sourceKey, portalUrl, pluginDataKey, studentId, classId, offeringId}; | ||
} | ||
return { demo: true }; | ||
}; |
Oops, something went wrong.