Skip to content
API 风格:

شريط التقدم Progress ​

يُستخدم LhProgress لعرض تقدّم مهمة أو سعة، بشكليه الخطي والدائري، مع إمكانية تخصيص اللون والنص.

الاستخدام الأساسي ​

شريط تقدم خطي
60%
vue
<script setup lang="ts">
</script>

<template>
  <LhProgress :percentage="60" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhProgress :percentage="60" />
</template>

الحالة ​

normal / success / warning / exception، بلوغ 100 يحوّلها تلقائيًا إلى success
100%
80%
40%
vue
<script setup lang="ts">
</script>

<template>
  <div style="display: flex; flex-direction: column; gap: 12px">
    <LhProgress :percentage="100" />
    <LhProgress :percentage="80" status="warning" />
    <LhProgress :percentage="40" status="exception" />
  </div>
</template>
vue
<script>
export default {}
</script>

<template>
  <div style="display: flex; flex-direction: column; gap: 12px">
    <LhProgress :percentage="100" />
    <LhProgress :percentage="80" status="warning" />
    <LhProgress :percentage="40" status="exception" />
  </div>
</template>

لون ونص مخصّصان ​

color يقبل سلسلة أو دالة، وformat يخصّص النص
55%
70 نقطة
vue
<script setup lang="ts">
</script>

<template>
  <div style="display: flex; flex-direction: column; gap: 12px">
    <LhProgress :percentage="55" color="#B8860B" />
    <LhProgress
      :percentage="70"
      :color="(p: number) => `hsl(${p * 1.2}, 60%, 45%)`"
      :format="(p: number) => `${p} نقطة`"
    />
  </div>
</template>
vue
<script>
export default {}
</script>

<template>
  <div style="display: flex; flex-direction: column; gap: 12px">
    <LhProgress :percentage="55" color="#B8860B" />
    <LhProgress
      :percentage="70"
      :color="(p: number) => `hsl(${p * 1.2}, 60%, 45%)`"
      :format="(p: number) => `${p} نقطة`"
    />
  </div>
</template>

تقدّم دائري ​

تعيين type إلى circle
75%
100%
vue
<script setup lang="ts">
</script>

<template>
  <div style="display: flex; align-items: center; gap: 24px">
    <LhProgress type="circle" :percentage="75" />
    <LhProgress type="circle" :percentage="100" :width="100" :stroke-width="8" />
  </div>
</template>
vue
<script>
export default {}
</script>

<template>
  <div style="display: flex; align-items: center; gap: 24px">
    <LhProgress type="circle" :percentage="75" />
    <LhProgress type="circle" :percentage="100" :width="100" :stroke-width="8" />
  </div>
</template>

إخفاء النص ​

تعيين showText إلى false
vue
<script setup lang="ts">
</script>

<template>
  <LhProgress :percentage="45" :show-text="false" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhProgress :percentage="45" :show-text="false" />
</template>

API ​

Props ​

الخاصيةالوصفالنوعالافتراضي
percentageنسبة التقدّم، يُطبَّق عليها clamp تلقائيًا إذا تجاوزت [0, 100]number0
typeالشكل"line" | "circle"'line'
statusالحالة، عند normal تتحول تلقائيًا إلى success عند بلوغ 100"normal" | "success" | "warning" | "exception"'normal'
colorلون شريط التقدّم: سلسلة أو دالة تُرجع لونًا حسب النسبةstring | ((percentage: number) => string)—
strokeWidthعرض الخط بالبكسل (ارتفاع في line، عرض حد في circle)number6
widthعرض لوحة الرسم في الوضع الدائري بالبكسلnumber126
showTextإظهار النصbooleantrue
formatتنسيق النص مخصص(percentage: number) => string—
sxخصائص التخطيط السريع sxLhSxProps—

Slots ​

اسم الفتحةالوصفالنطاق
textمحتوى النص المخصص{ percentage }

إمكانية الوصول ​

  • العنصر الجذري يحمل role="progressbar" مع aria-valuemin / aria-valuemax / aria-valuenow، موافقًا لنمط progressbar في WAI-ARIA
  • يُزامِن aria-valuetext النص الظاهر: افتراضيًا النسبة المئوية، وعند تمرير format يُذاع النص المنسَّق (مثل «42 نقطة»)
  • القيمة بعد القطع تُزامَن إلى aria-valuenow، فلن يحدث إذاع يتجاوز النطاق

تعريفات الأنواع ​

بنى TypeScript التي يصدّرها هذا المكوّن للخارج (مستخرجة تلقائيًا من packages/components/progress/src/types.ts و@lh-ui/share/core/*؛ انقر كل عنصر لتوسيع تعريفه الكامل؛ لأوصاف الخصائص انظر جدول Props أعلاه):

LhProgressProps
ts
export interface LhProgressProps {
  /** نسبة التقدّم 0-100 (تُقطع تلقائيًا عند التجاوز) */
  percentage: number
  type?: LhProgressType
  status?: LhProgressStatus
  /** لون شريط التقدّم: سلسلة أو دالة تُرجع لونًا حسب النسبة */
  color?: string | ((percentage: number) => string)
  /** عرض الخط بالبكسل (ارتفاع في line، عرض حد في circle) */
  strokeWidth?: number
  /** عرض لوحة الرسم في الوضع الدائري بالبكسل */
  width?: number
  showText?: boolean
  /** تنسيق النص مخصص */
  format?: (percentage: number) => string
  /** خصائص التخطيط السريع sx */
  sx?: LhSxProps
}
LhProgressType (مأخوذ من @lh-ui/share/core/progress)
ts
export type LhProgressType = 'line' | 'circle'
LhProgressStatus (مأخوذ من @lh-ui/share/core/progress)
ts
export type LhProgressStatus = 'normal' | 'success' | 'warning' | 'exception'

جمال التقاليد، أساس الكود