progress.tsx 792 B

1234567891011121314151617181920212223242526
  1. "use client";
  2. import type { ComponentRenderProps } from "./types";
  3. import { baseClass, getCustomClass } from "./utils";
  4. export function Progress({ element }: ComponentRenderProps) {
  5. const { props } = element;
  6. const customClass = getCustomClass(props);
  7. const value = Math.min(100, Math.max(0, (props.value as number) || 0));
  8. return (
  9. <div className={`${baseClass} ${customClass}`}>
  10. {props.label ? (
  11. <div className="text-[10px] text-muted-foreground mb-1 text-left">
  12. {props.label as string}
  13. </div>
  14. ) : null}
  15. <div className="h-2 bg-muted rounded-full overflow-hidden">
  16. <div
  17. className="h-full bg-foreground rounded-full transition-all"
  18. style={{ width: `${value}%` }}
  19. />
  20. </div>
  21. </div>
  22. );
  23. }