| 1 |
<script lang="ts"> |
| 2 |
import AutocompleteInput from "../AutocompleteInput.svelte"; |
| 3 |
import { urlForAccount } from "../helpers"; |
| 4 |
import { _ } from "../i18n"; |
| 5 |
import router from "../router"; |
| 6 |
import { accounts } from "../stores"; |
| 7 |
|
| 8 |
let value = $state(""); |
| 9 |
|
| 10 |
function select(el: HTMLInputElement) { |
| 11 |
if (value) { |
| 12 |
router.navigate($urlForAccount(value)); |
| 13 |
el.blur(); |
| 14 |
value = ""; |
| 15 |
} |
| 16 |
} |
| 17 |
</script> |
| 18 |
|
| 19 |
<li> |
| 20 |
<AutocompleteInput |
| 21 |
bind:value |
| 22 |
placeholder={_("Go to account")} |
| 23 |
suggestions={$accounts} |
| 24 |
className="account-selector" |
| 25 |
key="g a" |
| 26 |
onSelect={select} |
| 27 |
onEnter={select} |
| 28 |
/> |
| 29 |
</li> |
| 30 |
|
| 31 |
<style> |
| 32 |
:global(.account-selector input) { |
| 33 |
padding: 0.25em 0.5em 0.25em 1em; |
| 34 |
border: none; |
| 35 |
} |
| 36 |
</style> |