Skip to content

Commit

Permalink
enable keyboard navigation #15
Browse files Browse the repository at this point in the history
  • Loading branch information
bonartm committed Dec 24, 2021
1 parent a17d490 commit 664f344
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions src/components/ChoiceView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,41 @@
export let question: BaseQuestion;
</script>

{#if question.quizType === 'MultipleChoice'}
{#each question.answers as answer, i}
<label>
<input
type="checkbox"
bind:group="{question.selected}"
value="{i}"
/>
<span>{@html answer.html}</span>
</label>
{/each}
{:else}
{#each question.answers as answer, i}
<label>
<input
type="radio"
bind:group="{question.selected[0]}"
value="{i}"
/>
<span>{@html answer.html}</span>
</label>
{/each}
{/if}
<fieldset>
{#if question.questionType === 'MultipleChoice'}
{#each question.answers as answer, i}
<label>
<input
type="checkbox"
bind:group="{question.selected}"
value="{i}"
/>
<span>{@html answer.html}</span>
</label>
{/each}
{:else}
{#each question.answers as answer, i}
<label>
<input
type="radio"
bind:group="{question.selected[0]}"
value="{i}"
/>
<span>{@html answer.html}</span>
</label>
{/each}
{/if}
</fieldset>

<style>
fieldset {
border: 0;
}
[type='checkbox'],
[type='radio'] {
display: none;
position: absolute;
opacity: 0;
}
[type='radio'] + span {
Expand All @@ -54,7 +61,9 @@
}
[type='checkbox']:hover + span,
[type='radio']:hover + span {
[type='checkbox']:focus + span,
[type='radio']:hover + span,
[type='radio']:focus + span {
filter: brightness(0.9);
}
Expand Down

0 comments on commit 664f344

Please sign in to comment.