Show percent progress bar during long Excel imports.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-03 17:45:08 +03:30
co-authored by Cursor
parent c629729a9a
commit 07bdc4a3b6
2 changed files with 88 additions and 8 deletions
+57 -2
View File
@@ -1,16 +1,31 @@
<script setup lang="ts">
withDefaults(
import { computed } from 'vue';
import { toFaDigits } from '@/lib/jalali';
const props = withDefaults(
defineProps<{
open: boolean;
message?: string;
/** وقتی true باشد روی مودال هم دیده می‌شود */
nest?: boolean;
/** درصد پیشرفت ۰ تا ۱۰۰؛ اگر null باشد نوار نشان داده نمی‌شود */
progress?: number | null;
}>(),
{
message: 'لطفاً صبر کنید…',
nest: false,
progress: null,
},
);
const showBar = computed(
() => props.progress != null && Number.isFinite(props.progress),
);
const pct = computed(() => {
if (!showBar.value) return 0;
return Math.max(0, Math.min(100, Math.round(props.progress!)));
});
const pctLabel = computed(() => toFaDigits(String(pct.value)));
</script>
<template>
@@ -22,10 +37,19 @@ withDefaults(
role="status"
aria-live="polite"
aria-busy="true"
:aria-valuenow="showBar ? pct : undefined"
aria-valuemin="0"
aria-valuemax="100"
>
<div class="card">
<span class="spinner" aria-hidden="true" />
<p>{{ message }}</p>
<div v-if="showBar" class="progress-wrap">
<div class="progress-track" aria-hidden="true">
<div class="progress-fill" :style="{ width: `${pct}%` }" />
</div>
<strong class="progress-pct">{{ pctLabel }}٪</strong>
</div>
</div>
</div>
</Teleport>
@@ -51,7 +75,8 @@ withDefaults(
display: grid;
justify-items: center;
gap: 0.85rem;
min-width: min(18rem, 100%);
min-width: min(20rem, 100%);
max-width: 22rem;
padding: 1.35rem 1.5rem;
border-radius: 16px;
background: #fff;
@@ -67,6 +92,36 @@ withDefaults(
line-height: 1.6;
}
.progress-wrap {
display: grid;
gap: 0.45rem;
width: 100%;
justify-items: center;
}
.progress-track {
width: 100%;
height: 8px;
border-radius: 999px;
background: #e2e8f0;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #0d9488, #14b8a6);
transition: width 0.25s ease;
}
.progress-pct {
font-size: 1.15rem;
font-weight: 800;
font-variant-numeric: tabular-nums;
color: #0f766e;
letter-spacing: 0.02em;
}
.spinner {
width: 28px;
height: 28px;