mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
30 lines
1011 B
TypeScript
30 lines
1011 B
TypeScript
"use client"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import * as ProgressPrimitive from "@radix-ui/react-progress"
|
|
import * as React from "react"
|
|
|
|
const Progress = React.forwardRef<
|
|
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> & {
|
|
indicatorClassName?: string // 添加一个新的可选属性来自定义Indicator的类名
|
|
}
|
|
>(({ className, value, indicatorClassName, ...props }, ref) => (
|
|
<ProgressPrimitive.Root
|
|
ref={ref}
|
|
className={cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary", className)}
|
|
{...props}
|
|
>
|
|
<ProgressPrimitive.Indicator
|
|
className={cn(
|
|
"h-full w-full flex-1 transition-all",
|
|
indicatorClassName || "bg-primary", // 使用提供的indicatorClassName或默认的bg-primary
|
|
)}
|
|
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
/>
|
|
</ProgressPrimitive.Root>
|
|
))
|
|
Progress.displayName = ProgressPrimitive.Root.displayName
|
|
|
|
export { Progress }
|