mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-01 22:09:55 +00:00
## Summary Automated initial change, cleaned up manually. Please check the screenshot changes. Includes a11y updates to icon buttons. Doesn't hit the buttons in Desktop. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7649-WIP-Component-The-Rest-of-the-PrimeVue-buttons-2ce6d73d365081d68e06f200f1321267) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
70 lines
1.8 KiB
Vue
70 lines
1.8 KiB
Vue
<!-- A file download button with a label and a size hint -->
|
|
<template>
|
|
<div class="flex flex-row items-center gap-2">
|
|
<div>
|
|
<div>
|
|
<span :title="hint">{{ label }}</span>
|
|
</div>
|
|
<Message
|
|
v-if="props.error"
|
|
severity="error"
|
|
icon="pi pi-exclamation-triangle"
|
|
size="small"
|
|
variant="outlined"
|
|
class="my-2 h-min max-w-xs px-1"
|
|
:title="props.error"
|
|
:pt="{
|
|
text: { class: 'overflow-hidden text-ellipsis' }
|
|
}"
|
|
>
|
|
{{ props.error }}
|
|
</Message>
|
|
</div>
|
|
<div>
|
|
<Button
|
|
variant="secondary"
|
|
:disabled="!!props.error"
|
|
:title="props.url"
|
|
@click="download.triggerBrowserDownload"
|
|
>
|
|
{{ $t('g.download') + ' (' + fileSize + ')' }}
|
|
</Button>
|
|
</div>
|
|
<div>
|
|
<Button variant="secondary" :disabled="!!props.error" @click="copyURL">
|
|
{{ $t('g.copyURL') }}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import Message from 'primevue/message'
|
|
import { computed } from 'vue'
|
|
|
|
import Button from '@/components/ui/button/Button.vue'
|
|
import { useCopyToClipboard } from '@/composables/useCopyToClipboard'
|
|
import { useDownload } from '@/composables/useDownload'
|
|
import { formatSize } from '@/utils/formatUtil'
|
|
|
|
const props = defineProps<{
|
|
url: string
|
|
hint?: string
|
|
label?: string
|
|
error?: string
|
|
}>()
|
|
|
|
const label = computed(() => props.label || props.url.split('/').pop())
|
|
|
|
const hint = computed(() => props.hint || props.url)
|
|
const download = useDownload(props.url)
|
|
const fileSize = computed(() =>
|
|
download.fileSize.value ? formatSize(download.fileSize.value) : '?'
|
|
)
|
|
const copyURL = async () => {
|
|
await copyToClipboard(props.url)
|
|
}
|
|
|
|
const { copyToClipboard } = useCopyToClipboard()
|
|
</script>
|