From 5444d6801e0eaa825a3cc0861e3c00dff11bd85d Mon Sep 17 00:00:00 2001 From: FS-Frost <30810344+FS-Frost@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:59:44 -0300 Subject: [PATCH] More clickable stuff. --- src/Dictionary.svelte | 29 +++++++++++++++++++++++ src/Word.svelte | 54 +++++++++++++++++++++++++++++-------------- src/strings.ts | 9 ++++++++ 3 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 src/strings.ts diff --git a/src/Dictionary.svelte b/src/Dictionary.svelte index 9a7e4a4..00efcf4 100644 --- a/src/Dictionary.svelte +++ b/src/Dictionary.svelte @@ -8,6 +8,7 @@ LANG_ES, } from "./DictionaryClient"; import Word from "./Word.svelte"; + import { cleanWord } from "./strings"; let response: ClientResponse; let isLoading: boolean = false; @@ -29,6 +30,9 @@ ? "Ups, I hit an error. Try again." : "Vaya, me tropecé con una piedra. Intenta de nuevo."; $: searchingMessage = isLangEnglish ? "Searching..." : "Buscando..."; + $: proTip = isLangEnglish + ? "Pro tip: click a word to search it." + : "Pro tip: clic en una palabra para buscarla."; onMount(() => { const url = new URL(window.location.href); @@ -116,6 +120,26 @@ +

+ + {#each proTip.split(" ") as subword} + { + word = cleanWord(subword); + searchWord(); + }} + > + {subword} + + {" "} + {/each} + +

+ {#if !isLoading && response && response.json} {#each response.json as defWord} diff --git a/src/Word.svelte b/src/Word.svelte index 20d9119..761610a 100644 --- a/src/Word.svelte +++ b/src/Word.svelte @@ -1,6 +1,7 @@
- {word.word}{#if word.phonetic != null} + {word.word} + {#if word.phonetic != null} ({word.phonetic}) {/if}
@@ -56,10 +48,38 @@ {#each word.meanings as meaning} {#if meaning.partOfSpeech != null}
- {getPartOfSpeechPrefix(meaning.partOfSpeech)} - {meaning.partOfSpeech} + + {#each getPartOfSpeechPrefix(meaning.partOfSpeech).split(" ") as subword} + searchWord(cleanWord(subword))} + > + {subword} + + {" "} + {/each} + + searchWord( + cleanWord(meaning.partOfSpeech ?? "") + )} + > + {meaning.partOfSpeech} + +
{/if} @@ -68,7 +88,7 @@ {#each definition.definition.split(" ") as subword}