Added Audio Questions
This commit is contained in:
34
src/lib/AudioQuestionComponent.svelte
Normal file
34
src/lib/AudioQuestionComponent.svelte
Normal file
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import AudioPlayerComponent from "./AudioPlayerComponent.svelte";
|
||||
import type { AudioQuestion } from "./games/games";
|
||||
|
||||
const path = "/sounds/";
|
||||
|
||||
interface Props {
|
||||
question: AudioQuestion;
|
||||
showAnswer: boolean;
|
||||
showQuestion: boolean;
|
||||
showPlayer: boolean;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
let { question, showAnswer, showQuestion, showPlayer }: Props = $props();
|
||||
</script>
|
||||
|
||||
<div class="mb-4 flex grow flex-col items-center text-6xl">
|
||||
{#if showQuestion || showAnswer}
|
||||
<div class="flex grow-1 items-center">
|
||||
<div class="text-center">{question.data.question}</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if showPlayer}
|
||||
<div class="flex w-full flex-col justify-center">
|
||||
<AudioPlayerComponent src={path + question.data.audio} />
|
||||
</div>
|
||||
{/if}
|
||||
{#if showAnswer}
|
||||
<div class="flex grow-1 items-center text-center">
|
||||
{question.data.answer}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in New Issue
Block a user