Skip to content

Commit 50997b7

Browse files
refactor(ui): use new useClipboard with async (#2675)
Co-authored-by: Willow (GHOST) <[email protected]>
1 parent e11ed69 commit 50997b7

4 files changed

Lines changed: 48 additions & 54 deletions

File tree

app/composables/useClipboardAsync.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

app/pages/package/[[org]]/[name].vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,20 @@ const {
108108
)
109109
110110
//copy README file as Markdown
111-
const { copied: copiedReadme, copy: copyReadme } = useClipboardAsync(
112-
async () => {
111+
const {
112+
copied: copiedReadme,
113+
copy,
114+
copyPending: copyReadmePending,
115+
} = useClipboard({
116+
copiedDuring: 2000,
117+
})
118+
119+
function copyReadme() {
120+
copy(async () => {
113121
await fetchReadmeMarkdown()
114122
return readmeMarkdownData.value?.markdown ?? ''
115-
},
116-
{
117-
copiedDuring: 2000,
118-
},
119-
)
123+
})
124+
}
120125
121126
function prefetchReadmeMarkdown() {
122127
if (readmeMarkdownStatus.value === 'idle') {
@@ -1040,7 +1045,11 @@ const showSkeleton = shallowRef(false)
10401045
"
10411046
:classicon="copiedReadme ? 'i-lucide:check' : 'i-simple-icons:markdown'"
10421047
>
1043-
{{ copiedReadme ? $t('common.copied') : $t('common.copy') }}
1048+
<span>{{ copiedReadme ? $t('common.copied') : $t('common.copy') }}</span>
1049+
<span
1050+
v-if="copyReadmePending"
1051+
class="i-lucide:loader-circle animate-spin size-4"
1052+
></span>
10441053
</ButtonBase>
10451054
</TooltipApp>
10461055
<ReadmeTocDropdown

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"@vercel/speed-insights": "2.0.0",
7878
"@vite-pwa/assets-generator": "1.0.2",
7979
"@vite-pwa/nuxt": "1.1.1",
80-
"@vueuse/core": "14.2.1",
80+
"@vueuse/core": "14.3.0",
8181
"@vueuse/integrations": "14.2.1",
8282
"@vueuse/nuxt": "14.2.1",
8383
"@vueuse/router": "^14.2.1",

pnpm-lock.yaml

Lines changed: 30 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)