fix: home input validation
This commit is contained in:
@@ -8,29 +8,42 @@ const listNameInput = ref<string>(generateSlug(4));
|
|||||||
function onRandom() {
|
function onRandom() {
|
||||||
listNameInput.value = generateSlug(4);
|
listNameInput.value = generateSlug(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onInput() {
|
||||||
|
listNameInput.value = listNameInput.value
|
||||||
|
.normalize("NFD")
|
||||||
|
.replace(/[\s_]/g, "-")
|
||||||
|
.replace(/[^a-z0-9-]/g, "")
|
||||||
|
.toLowerCase();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<div class="mb-4 italic text-xl font-extralight" v-html="$t('home')">
|
<div
|
||||||
</div>
|
class="mb-4 italic text-xl font-extralight"
|
||||||
|
v-html="$t('home')"
|
||||||
|
></div>
|
||||||
<div class="flex gap-2 mb-4">
|
<div class="flex gap-2 mb-4">
|
||||||
<input
|
<input
|
||||||
v-model="listNameInput"
|
v-model="listNameInput"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="$t('new_task_hint')"
|
:placeholder="$t('new_task_hint')"
|
||||||
class="input grow"
|
class="input grow"
|
||||||
|
@input="onInput"
|
||||||
/>
|
/>
|
||||||
<button
|
<button class="btn btn-square" @click="onRandom">
|
||||||
class="btn btn-square"
|
|
||||||
@click="onRandom"
|
|
||||||
>
|
|
||||||
<dices-icon />
|
<dices-icon />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full px-4">
|
<div class="w-full px-4">
|
||||||
<router-link class="btn btn-lg" :to="`/${listNameInput}`">
|
<router-link
|
||||||
<arrow-big-right-dash-icon class="inline" /> {{ $t('home_button') }}
|
class="btn btn-lg"
|
||||||
|
:class="listNameInput.trim().length === 0 ? 'btn-disabled' : ''"
|
||||||
|
:to="`/${listNameInput.trim()}`"
|
||||||
|
>
|
||||||
|
<arrow-big-right-dash-icon class="inline" />
|
||||||
|
{{ $t("home_button") }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user