feat(copy): support legacy copy to clipboard for older browser (#581)

This commit is contained in:
Corentin THOMASSET 2023-08-22 01:00:20 +02:00 committed by GitHub
parent 76b2761d62
commit 6f93cba3da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 47 additions and 53 deletions

View file

@ -1,10 +1,11 @@
<script setup lang="ts">
import { Plus, Trash } from '@vicons/tabler';
import { useClipboard, useStorage } from '@vueuse/core';
import { useStorage } from '@vueuse/core';
import _ from 'lodash';
import { arrayToMarkdownTable, computeAverage, computeVariance } from './benchmark-builder.models';
import DynamicValues from './dynamic-values.vue';
import { useCopy } from '@/composable/copy';
const suites = useStorage('benchmark-builder:suites', [
{ title: 'Suite 1', data: [5, 10] },
@ -47,7 +48,7 @@ const results = computed(() => {
});
});
const { copy } = useClipboard();
const { copy } = useCopy({ createToast: false });
const header = {
title: 'Suite',

View file

@ -8,7 +8,7 @@ const getVendorValue = (address: string) => address.trim().replace(/[.:-]/g, '')
const macAddress = ref('20:37:06:12:34:56');
const details = computed<string | undefined>(() => db[getVendorValue(macAddress.value)]);
const { copy } = useCopy({ source: details, text: 'Vendor info copied to the clipboard' });
const { copy } = useCopy({ source: () => details.value ?? '', text: 'Vendor info copied to the clipboard' });
</script>
<template>

View file

@ -1,10 +1,10 @@
<script setup lang="ts">
import { useClipboard } from '@vueuse/core';
import { useCopy } from '@/composable/copy';
const props = defineProps<{ tokens: { previous: string; current: string; next: string } }>();
const { copy: copyPrevious, copied: previousCopied } = useClipboard();
const { copy: copyCurrent, copied: currentCopied } = useClipboard();
const { copy: copyNext, copied: nextCopied } = useClipboard();
const { copy: copyPrevious, isJustCopied: previousCopied } = useCopy({ createToast: false });
const { copy: copyCurrent, isJustCopied: currentCopied } = useCopy({ createToast: false });
const { copy: copyNext, isJustCopied: nextCopied } = useCopy({ createToast: false });
const { tokens } = toRefs(props);
</script>

View file

@ -36,7 +36,7 @@ const validationRoman = useValidation({
});
const { copy: copyRoman } = useCopy({ source: outputRoman, text: 'Roman number copied to the clipboard' });
const { copy: copyArabic } = useCopy({ source: outputNumeral, text: 'Arabic number copied to the clipboard' });
const { copy: copyArabic } = useCopy({ source: () => String(outputNumeral), text: 'Arabic number copied to the clipboard' });
</script>
<template>

View file

@ -39,7 +39,7 @@ const { copy } = useCopy({ source: obfuscatedString });
{{ obfuscatedString }}
</div>
<c-button @click="copy">
<c-button @click="copy()">
<icon-mdi:content-copy />
</c-button>
</c-card>

View file

@ -34,7 +34,7 @@ const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard'
/>
<div flex justify-center gap-3>
<c-button autofocus @click="copy">
<c-button autofocus @click="copy()">
Copy
</c-button>
<c-button @click="refreshUUIDs">