-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(providers-transformers): progress support
Signed-off-by: Neko Ayaka <neko@ayaka.moe>
- Loading branch information
1 parent
d7dddaa
commit 9be00ea
Showing
3 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/provider-transformers/playground/src/components/Progress.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script setup lang="ts"> | ||
withDefaults(defineProps<{ | ||
text: string | ||
percentage: number | ||
total?: number | ||
}>(), { | ||
percentage: 0, | ||
}) | ||
function formatBytes(size?: number) { | ||
if (!size) | ||
size = 0 | ||
const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)) | ||
return +((size / 1024 ** i).toFixed(2)) * 1 + ['B', 'kB', 'MB', 'GB', 'TB'][i] | ||
} | ||
</script> | ||
|
||
<template> | ||
<div | ||
class="flex items-center justify-between whitespace-nowrap rounded-lg bg-violet-100 px-3 py-2 text-sm dark:bg-violet-900" | ||
:style="{ width: `${percentage}%` }" | ||
> | ||
<span>{{ text }}</span> | ||
<span>({{ percentage.toFixed(2) }}%{{ Number.isNaN(total) ? '' : ` of ${formatBytes(total)}` }})</span> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters