chore: add more composables (#138)

This commit is contained in:
Sylvain Marroufin
2023-03-09 11:42:22 +01:00
committed by GitHub
parent fef93f3198
commit fd4b608150
11 changed files with 221 additions and 71 deletions

View File

@@ -128,6 +128,16 @@
<UButton icon="i-heroicons-bell" variant="red" label="Trigger an error" @click="onNotificationClick" />
</div>
<div>
<div class="font-medium text-sm mb-1 u-text-gray-700">
Copy text to clipboard:
</div>
<div class="flex gap-2">
<UInput v-model="textToCopy" name="textToCopy" />
<UButton icon="i-heroicons-document-duplicate-solid" variant="primary" label="Copy text" @click="onCopyTextClick" />
</div>
</div>
<div>
<div class="font-medium text-sm mb-1 u-text-gray-700">
Context menu:
@@ -230,6 +240,7 @@
<script setup>
const isModalOpen = ref(false)
const textToCopy = ref('Copied text')
const people = ref([
{ id: 1, name: 'Durward Reynolds', disabled: false },
@@ -251,7 +262,8 @@ const form = reactive({
persons: ref([people.value[0]])
})
const { $toast } = useNuxtApp()
const toast = useToast()
const clipboard = useCopyToClipboard()
const x = ref(0)
const y = ref(0)
@@ -346,6 +358,10 @@ const customDropdownItems = [
]
const onNotificationClick = () => {
$toast.error({ title: 'Error', description: 'This is an error message' })
toast.error({ title: 'Error', description: 'This is an error message' })
}
const onCopyTextClick = () => {
clipboard.copy(textToCopy.value, { title: 'Text copied successfully!' })
}
</script>