Skip to content

Commit

Permalink
💄 Use determine type for reader progress indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
nwingt committed Jun 24, 2024
1 parent d469a00 commit d7c5686
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@
}
},
"preview": "Preview",
"reader_loading_label": "Loading",
"RedirectPage": {
"title": "Redirecting"
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@
}
},
"preview": "預覽",
"reader_loading_label": "載入中",
"RedirectPage": {
"title": "重新轉向"
},
Expand Down
10 changes: 10 additions & 0 deletions src/mixins/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ export default {
totalSizeInMB() {
return (this.totalSize / (1024 * 1024)).toFixed(2);
},
progressIndicatorType() {
return this.totalSize ? 'determinate' : 'indeterminate';
},
progressLabelText() {
return this.totalSize
? `${this.progressSizeInMB} / ${this.totalSizeInMB} MB (${
this.progressPercent
}%)`
: this.$t('reader_loading_label');
},
},
methods: {
async getFileBuffer(cacheKey) {
Expand Down
8 changes: 7 additions & 1 deletion src/pages/reader.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template>
<div class="fixed inset-0 flex flex-col items-center justify-center">
<ProgressIndicator v-if="isLoading" />
<div
v-if="isLoading"
class="fixed inset flex flex-col justify-center items-center bg-white gap-[16px]"
>
<ProgressIndicator />
<span class="text-like-green">{{ $t('reader_loading_label') }}</span>
</div>
<Component
:is="isLoginRequired ? 'AuthRequiredView' : 'div'"
v-else
Expand Down
11 changes: 6 additions & 5 deletions src/pages/reader/epub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<div>
<div
v-if="isLoading"
class="fixed inset-0 flex flex-col justify-center items-center"
class="fixed inset-0 flex flex-col justify-center items-center gap-[16px] bg-white"
>
<ProgressIndicator />
<div class="text-like-green">
{{ progressSizeInMB }} / {{ totalSizeInMB }}MB ({{ progressPercent }}%)
</div>
<ProgressIndicator
:type="progressIndicatorType"
:value="progressPercent"
/>
<span class="text-like-green text-center">{{ progressLabelText }}</span>
</div>
<div v-else class="flex items-center justify-between">
<div class="grow" />
Expand Down
11 changes: 6 additions & 5 deletions src/pages/reader/pdf.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<div class="w-full h-full">
<div
v-if="isLoading"
class="fixed inset-0 flex flex-col justify-center items-center"
class="fixed inset-0 flex flex-col justify-center items-center gap-[16px] bg-like-green"
>
<ProgressIndicator />
<div class="text-white">
{{ progressSizeInMB }} / {{ totalSizeInMB }}MB ({{ progressPercent }}%)
</div>
<ProgressIndicator
:type="progressIndicatorType"
:value="progressPercent"
/>
<span class="text-white text-center">{{ progressLabelText }}</span>
</div>
<iframe
ref="pdfIframe"
Expand Down

0 comments on commit d7c5686

Please sign in to comment.