Added shortcut to search

This commit is contained in:
Alexis
2024-04-05 17:44:49 +02:00
parent fda2e05d99
commit 6368ada51d
2 changed files with 22 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import { Input } from '@/components/ui/input'
import { PhMagnifyingGlass } from '@phosphor-icons/vue' import { PhMagnifyingGlass } from '@phosphor-icons/vue'
import { useCalendarEvents } from '@/stores/events' import { useCalendarEvents } from '@/stores/events'
import CalendarEventList from './CalendarEventList.vue' import CalendarEventList from './CalendarEventList.vue'
import { useMagicKeys, whenever } from '@vueuse/core'
const { allEvents } = useCalendarEvents() const { allEvents } = useCalendarEvents()
@@ -34,15 +35,26 @@ function resetSearch() {
searchQuery.value = '' searchQuery.value = ''
} }
function openDialog() {
modalOpen.value = true
}
function closeDialog() { function closeDialog() {
modalOpen.value = false modalOpen.value = false
} }
// Key combos to deploy modal
const keys = useMagicKeys()
whenever(keys.control_period, () => {
openDialog()
})
</script> </script>
<template> <template>
<Dialog v-model:open="modalOpen" @update:open="resetSearch"> <Dialog v-model:open="modalOpen" @update:open="resetSearch">
<DialogTrigger> <DialogTrigger>
<Button> <Button search-slash>
<PhMagnifyingGlass size="20" weight="light" /> <PhMagnifyingGlass size="20" weight="light" />
Recherche avancée Recherche avancée
</Button> </Button>

View File

@@ -8,6 +8,7 @@ interface Props extends PrimitiveProps {
variant?: ButtonVariants['variant'] variant?: ButtonVariants['variant']
size?: ButtonVariants['size'] size?: ButtonVariants['size']
class?: HTMLAttributes['class'] class?: HTMLAttributes['class']
searchSlash?: boolean
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
@@ -19,8 +20,15 @@ const props = withDefaults(defineProps<Props>(), {
<Primitive <Primitive
:as="as" :as="as"
:as-child="asChild" :as-child="asChild"
:class="cn(buttonVariants({ variant, size }), props.class)" :class="cn(buttonVariants({ variant, size }), props.class, 'group')"
> >
<slot /> <slot />
<span
v-if="props.searchSlash"
class="h-4 p-1 ml-1 grid place-items-center text-[0.7em] leading-none font-semibold text-slate-500 bg-slate-100 border-slate-300 border-[1px] rounded-[3px] shadow-sm group-hover:text-slate-600 group-hover:bg-slate-200 group-hover:border-slate-400 transition-colors"
>
<span class="-mt-[2px]">CTRL + :</span>
</span>
</Primitive> </Primitive>
</template> </template>