Skip to content

Commit

Permalink
Merge pull request #7 from Gornius/dev
Browse files Browse the repository at this point in the history
Update from dev
  • Loading branch information
Gornius authored Apr 20, 2024
2 parents 5b1f57d + 6c5d66b commit d596ad3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/QuestionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const previousAnswer = computed(() => storeQuiz.previousAnswers.toReversed()[0])
const previousAnswerCorrect = computed(() => wordComparator.compareWords(previousAnswer.value.answer, previousAnswer.value.verb.word));
function giveAnswer() {
document.getElementById('answer')?.focus();
emits('answerGiven', answer.value);
answer.value = '';
}
Expand All @@ -43,7 +44,7 @@ function giveAnswer() {
<Label for="answer">Answer</Label>
</div>
<div class="flex flex-row gap-2">
<Input id="answer" class="flex-grow" v-model="answer" />
<Input autofocus id="answer" class="flex-grow" v-model="answer" />
<Button type="submit" class="aspect-square p-0">
<Icon icon="ooui:next-ltr"/>
</Button>
Expand Down
10 changes: 9 additions & 1 deletion composables/useWordComparator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
// Todo: change this from composable to util, as it doesn't hold any state
export function useWordComparator() {
function normalize(word: string): string {
return word
.toLocaleLowerCase()
.trim()
.replaceAll(/\s+/g, " ");
}

function compareWords(firstWord: string, secondWord: string) {
return firstWord.toLocaleLowerCase() === secondWord.toLocaleLowerCase();
return normalize(firstWord) === normalize(secondWord);
}

return {
Expand Down
3 changes: 2 additions & 1 deletion composables/useWordsDictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import YAML from 'yaml';
import { type Verb } from '~/models/Verb';
import { type DictionaryEntry } from '~/models/DictionaryEntry';

// Todo: change this from composable to util, as it doesn't hold any state
export function useWordsDictionary() {
function getPerson(verb: Verb | Verb['person']) {
const personDictionary = {
Expand All @@ -13,7 +14,7 @@ export function useWordsDictionary() {
m1: '1. Plural',
m2: '2. Plural',
m3: '3. Plural',
all: 'Any',
all: 'All',
}
if (typeof verb === 'string') {
return personDictionary[verb as Verb['person']];
Expand Down

0 comments on commit d596ad3

Please sign in to comment.