improve haptics
This commit is contained in:
@@ -1,11 +1,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { OnClickOutside } from '@vueuse/components'
|
import { OnClickOutside } from '@vueuse/components'
|
||||||
|
import { Haptics, ImpactStyle } from '@capacitor/haptics'
|
||||||
|
|
||||||
|
const vibrate = (event: PointerEvent) => {
|
||||||
|
if (event.target !== document.activeElement) {
|
||||||
|
Haptics.impact({ style: ImpactStyle.Light })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<OnClickOutside>
|
<OnClickOutside>
|
||||||
<UIDropdown class="search-active-hide">
|
<UIDropdown class="search-active-hide">
|
||||||
<template #activator>
|
<template #activator>
|
||||||
<UIButton :dropdown="true" size="sm" variant="outline" class="topbar-button text-white">
|
<UIButton
|
||||||
|
:dropdown="true"
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
class="topbar-button text-white"
|
||||||
|
@mousedown="vibrate"
|
||||||
|
>
|
||||||
<i class="fa-fw fa-solid fa-user-gear" />
|
<i class="fa-fw fa-solid fa-user-gear" />
|
||||||
</UIButton>
|
</UIButton>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
setActiveNote,
|
setActiveNote,
|
||||||
getNoteReferences
|
getNoteReferences
|
||||||
} from '@/composables/useNotes'
|
} from '@/composables/useNotes'
|
||||||
|
import { Haptics, ImpactStyle } from '@capacitor/haptics'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
note: Note
|
note: Note
|
||||||
@@ -31,14 +32,16 @@ const updateNoteContent = (content: string) => {
|
|||||||
const references = computed<Note[]>(() => getNoteReferences(props.note))
|
const references = computed<Note[]>(() => getNoteReferences(props.note))
|
||||||
|
|
||||||
const handleAction = async (action: string, closeModal: () => Promise<Boolean>) => {
|
const handleAction = async (action: string, closeModal: () => Promise<Boolean>) => {
|
||||||
if (action === 'delete') {
|
Haptics.impact({ style: ImpactStyle.Light })
|
||||||
if (closeModal) await closeModal()
|
switch (action) {
|
||||||
setActiveNote(rootNote.value?.id)
|
case 'delete':
|
||||||
deleteNote(props.note.id)
|
if (closeModal) await closeModal()
|
||||||
}
|
setActiveNote(rootNote.value?.id)
|
||||||
if (action === 'setRoot') {
|
deleteNote(props.note.id)
|
||||||
setRootNote(props.note.id)
|
break
|
||||||
if (closeModal) closeModal()
|
case 'setRoot':
|
||||||
|
setRootNote(props.note.id)
|
||||||
|
if (closeModal) closeModal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user