feat(ui): auto focus to sign in input

This commit is contained in:
三咲智子 2022-11-29 20:04:16 +08:00
parent f1cff0738a
commit 560f880448
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E

View file

@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { DEFAULT_SERVER } from '~/constants' import { DEFAULT_SERVER } from '~/constants'
const input = $ref<HTMLInputElement>()
let server = $ref<string>('') let server = $ref<string>('')
async function oauth() { async function oauth() {
@ -13,6 +14,10 @@ async function handleInput() {
if (server.startsWith('https://')) if (server.startsWith('https://'))
server = server.replace('https://', '') server = server.replace('https://', '')
} }
onMounted(() => {
input?.focus()
})
</script> </script>
<template> <template>
@ -23,7 +28,7 @@ async function handleInput() {
<div>Mastodon Server Name</div> <div>Mastodon Server Name</div>
<div flex bg-gray:10 px2 py1 mxa rounded border="~ border" text-xl items-center> <div flex bg-gray:10 px2 py1 mxa rounded border="~ border" text-xl items-center>
<span text-secondary-light mr1 text-sm>https://</span> <span text-secondary-light mr1 text-sm>https://</span>
<input v-model="server" :placeholder="DEFAULT_SERVER" outline-none bg-transparent @input="handleInput"> <input ref="input" v-model="server" :placeholder="DEFAULT_SERVER" outline-none bg-transparent @input="handleInput">
</div> </div>
<button btn-solid mt2> <button btn-solid mt2>
{{ $t('action.sign_in') }} {{ $t('action.sign_in') }}