feat: add tooltips for navigation and action buttons in CommandPalette; update localization files for new tooltip texts

This commit is contained in:
2025-09-04 13:50:07 +02:00
parent b40546ed9f
commit 334bd93099
5 changed files with 136 additions and 56 deletions

View File

@@ -61,6 +61,12 @@ function up() {
function down() { function down() {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }) window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' })
} }
const toolTipContent = {
align: 'center',
side: 'top',
sideOffset: 0,
}
</script> </script>
<template> <template>
@@ -71,41 +77,64 @@ function down() {
<UCard variant="outline" class="rounded-xl shadow-lg w-full" :ui="{ body: 'p-2 sm:p-2 flex gap-2 w-full' }"> <UCard variant="outline" class="rounded-xl shadow-lg w-full" :ui="{ body: 'p-2 sm:p-2 flex gap-2 w-full' }">
<ClientOnly> <ClientOnly>
<UFieldGroup v-if="active" class="flex items-center justify-center"> <UFieldGroup v-if="active" class="flex items-center justify-center">
<UButton <UTooltip
icon="i-ph-arrow-fat-up-duotone" :text="t('palette.tooltip.up')"
color="neutral" arrow
variant="outline" :content="toolTipContent"
class="cursor-pointer" :delay-duration="0"
size="xl" >
@click.prevent="up" <UButton
/> icon="i-ph-arrow-fat-up-duotone"
<UButton color="neutral"
icon="i-ph-arrow-fat-down-duotone" variant="outline"
color="neutral" class="cursor-pointer"
variant="outline" size="xl"
class="cursor-pointer" @click.prevent="up"
size="xl" />
@click.prevent="down" </UTooltip>
/>
<UTooltip
:text="t('palette.tooltip.down')"
arrow
:content="toolTipContent"
:delay-duration="0"
>
<UButton
icon="i-ph-arrow-fat-down-duotone"
color="neutral"
variant="outline"
class="cursor-pointer"
size="xl"
@click.prevent="down"
/>
</UTooltip>
</UFieldGroup> </UFieldGroup>
</ClientOnly> </ClientOnly>
<UFieldGroup class="w-full"> <UFieldGroup class="w-full">
<UModal v-model:open="openMessageModal" :ui="modalUi" title="Hey" description="Hey"> <UModal v-model:open="openMessageModal" :ui="modalUi" title="Hey" description="Hey">
<UButton <UTooltip
:label="loading ? t('palette.cmd.sending') : t('palette.cmd.send')" :text="t('palette.tooltip.send')"
variant="outline" arrow
color="neutral" :content="toolTipContent"
size="xl" :kbds="['enter']"
icon="i-ph-paper-plane-tilt-duotone" :delay-duration="0"
class="rounded-lg cursor-pointer p-2 w-full justify-center"
:disabled="loading"
> >
<template #trailing> <UButton
<div class="hidden md:flex px-2 items-center"> :label="loading ? t('palette.cmd.sending') : t('palette.cmd.send')"
<UKbd value="enter" color="info" /> variant="outline"
</div> color="neutral"
</template> size="xl"
</UButton> icon="i-ph-paper-plane-tilt-duotone"
class="rounded-lg cursor-pointer p-2 w-full justify-center"
:disabled="loading"
>
<template #trailing>
<div class="hidden md:flex px-2 items-center">
<UKbd value="enter" color="info" />
</div>
</template>
</UButton>
</UTooltip>
<template #content> <template #content>
<UCommandPalette <UCommandPalette
@@ -156,15 +185,23 @@ function down() {
:title="t('palette.clear.title')" :title="t('palette.clear.title')"
:description="t('palette.clear.description')" :description="t('palette.clear.description')"
> >
<UButton <UTooltip
variant="subtle" :text="t('palette.tooltip.clear')"
color="error" arrow
leading-icon="i-ph-trash-duotone" :content="toolTipContent"
size="xl" :kbds="['meta', 'D']"
class="rounded-lg" :delay-duration="0"
:class="storeMessages.length !== 0 ? 'cursor-pointer' : 'cursor-default'" >
:disabled="storeMessages.length === 0" <UButton
/> variant="subtle"
color="error"
leading-icon="i-ph-trash-duotone"
size="xl"
class="rounded-lg"
:class="storeMessages.length !== 0 ? 'cursor-pointer' : 'cursor-default'"
:disabled="storeMessages.length === 0"
/>
</UTooltip>
<template #footer="{ close }"> <template #footer="{ close }">
<UFieldGroup> <UFieldGroup>
@@ -175,23 +212,39 @@ function down() {
</UModal> </UModal>
</UFieldGroup> </UFieldGroup>
<ClientOnly> <ClientOnly>
<UFieldGroup class="flex items-center justify-center" :orientation="active ? 'horizontal' : 'vertical'"> <UFieldGroup class="flex items-center justify-center">
<UButton <UTooltip
:icon="dark ? 'i-ph-moon-duotone' : 'i-ph-sun-duotone'" :text="t('palette.tooltip.theme')"
color="neutral" arrow
variant="outline" :content="toolTipContent"
class="cursor-pointer" :kbds="['T']"
size="xl" :delay-duration="0"
@click.prevent="toggleDark" >
/> <UButton
<UButton :icon="dark ? 'i-ph-moon-duotone' : 'i-ph-sun-duotone'"
icon="i-ph-translate-duotone" color="neutral"
color="neutral" variant="outline"
variant="outline" class="cursor-pointer"
class="cursor-pointer" size="xl"
size="xl" @click.prevent="toggleDark"
@click.prevent="changeLocale(currentLocale!.code === 'en' ? 'fr' : currentLocale!.code === 'fr' ? 'es' : 'en')" />
/> </UTooltip>
<UTooltip
:text="t('palette.tooltip.language')"
arrow
:content="toolTipContent"
:kbds="['L']"
:delay-duration="0"
>
<UButton
icon="i-ph-translate-duotone"
color="neutral"
variant="outline"
class="cursor-pointer"
size="xl"
@click.prevent="changeLocale(currentLocale!.code === 'en' ? 'fr' : currentLocale!.code === 'fr' ? 'es' : 'en')"
/>
</UTooltip>
</UFieldGroup> </UFieldGroup>
</ClientOnly> </ClientOnly>
</UCard> </UCard>

View File

@@ -47,6 +47,7 @@ watch(
<ChatMain /> <ChatMain />
<div ref="parents" class="space-y-4 my-32"> <div ref="parents" class="space-y-4 my-32">
<ChatMessageContainer <ChatMessageContainer
:id="99999999998"
v-motion v-motion
:initial="{ :initial="{
opacity: 0, opacity: 0,
@@ -71,6 +72,7 @@ watch(
}" }"
/> />
<ChatMessageContainer <ChatMessageContainer
:id="99999999999"
v-motion v-motion
:initial="{ :initial="{
opacity: 0, opacity: 0,
@@ -96,6 +98,7 @@ watch(
/> />
<ChatMessageContainer <ChatMessageContainer
v-for="message in messages" v-for="message in messages"
:id="message.id"
:key="message.id" :key="message.id"
v-motion v-motion
:message="message" :message="message"

View File

@@ -15,6 +15,14 @@
"placeholder": "Use the arrow keys to navigate through the preset prompts. Press Enter to send the message.", "placeholder": "Use the arrow keys to navigate through the preset prompts. Press Enter to send the message.",
"send": "Send new message", "send": "Send new message",
"sending": "Sending..." "sending": "Sending..."
},
"tooltip": {
"up": "Go to the previous message",
"down": "Go to the next message",
"send": "Send a new predefined message",
"clear": "Delete all messages",
"theme": "Change the theme",
"language": "Change the language"
} }
}, },
"command": { "command": {

View File

@@ -15,6 +15,14 @@
"placeholder": "Use las flechas para navegar entre los prefacios de inmediato. Presione Entrar para enviar el mensaje.", "placeholder": "Use las flechas para navegar entre los prefacios de inmediato. Presione Entrar para enviar el mensaje.",
"send": "Enviar un nuevo mensaje", "send": "Enviar un nuevo mensaje",
"sending": "Enviando..." "sending": "Enviando..."
},
"tooltip": {
"up": "Ir al mensaje anterior",
"down": "Ir al siguiente mensaje",
"send": "Enviar un nuevo mensaje predefinido",
"clear": "Eliminar todos los mensajes",
"theme": "Cambiar el tema",
"language": "Cambiar la language"
} }
}, },
"command": { "command": {

View File

@@ -15,6 +15,14 @@
"placeholder": "Utilisez les flèches pour naviguer parmi les prompts préfaits. Appuyez sur Entrer pour envoyer le message.", "placeholder": "Utilisez les flèches pour naviguer parmi les prompts préfaits. Appuyez sur Entrer pour envoyer le message.",
"send": "Envoyer un nouveau message", "send": "Envoyer un nouveau message",
"sending": "Envoi en cours..." "sending": "Envoi en cours..."
},
"tooltip": {
"up": "Aller au message précédent",
"down": "Aller au message suivant",
"send": "Envoyer un nouveau message prédéfini",
"clear": "Supprimer tous les messages",
"theme": "Changer le thème",
"language": "Changer la langue"
} }
}, },
"command": { "command": {