feat(ui): external dictionary lookup link on the word-check tool
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 48s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 56s
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 48s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 56s
When a checked word is found, show a 'look it up' text link beside the complaint button that opens an external reference dictionary in a new tab: gramota.ru for the Russian variants, scrabblewordfinder.org for English (word lower-cased and percent-encoded). The link hides for a word that is not found. Inside Telegram it routes through the Mini App SDK's openLink, so Telegram opens it directly instead of the WebView's 'open this link?' confirmation; in a browser the anchor's own target=_blank handles it. Relabel the complaint button to 'Возражаю' (ru); English stays 'Disagree'.
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
import { handleError, showToast } from '../lib/app.svelte';
|
||||
import { t } from '../lib/i18n/index.svelte';
|
||||
import { alphabetLetters } from '../lib/alphabet';
|
||||
import { canCheckWord, sanitizeCheckWord } from '../lib/checkword';
|
||||
import { canCheckWord, dictionaryLookupUrl, sanitizeCheckWord } from '../lib/checkword';
|
||||
import { telegramOpenExternalLink } from '../lib/telegram';
|
||||
import type { Variant } from '../lib/model';
|
||||
|
||||
// Word-check on its own screen: unlimited dictionary lookups, each with a
|
||||
@@ -57,6 +58,12 @@
|
||||
handleError(e);
|
||||
}
|
||||
}
|
||||
// Inside Telegram, route the dictionary link through the Mini App SDK so Telegram opens it in
|
||||
// its in-app browser instead of the WebView's "open this link?" confirmation; in a plain
|
||||
// browser the anchor's own target=_blank handles it.
|
||||
function openLookup(e: MouseEvent) {
|
||||
if (telegramOpenExternalLink((e.currentTarget as HTMLAnchorElement).href)) e.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="wrap">
|
||||
@@ -75,7 +82,17 @@
|
||||
? t('game.wordLegal', { word: result.word })
|
||||
: t('game.wordIllegal', { word: result.word })}
|
||||
</p>
|
||||
<button class="complain" onclick={complain}>{t('game.complain')}</button>
|
||||
<div class="actions">
|
||||
<button class="complain" onclick={complain}>{t('game.complain')}</button>
|
||||
{#if result.legal}
|
||||
<a
|
||||
class="lookup"
|
||||
href={dictionaryLookupUrl(result.word, variant)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onclick={openLookup}>{t('game.lookup')}</a>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -120,12 +137,21 @@
|
||||
.verdict.bad {
|
||||
color: var(--danger, #c0392b);
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.complain {
|
||||
align-self: flex-start;
|
||||
padding: 8px 14px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
.lookup {
|
||||
color: var(--accent);
|
||||
text-decoration: underline;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user