diff --git a/components/ui/meter.tsx b/components/ui/meter.tsx index a2b6a048..06c46f03 100644 --- a/components/ui/meter.tsx +++ b/components/ui/meter.tsx @@ -1,45 +1,54 @@ "use client" -import * as React from "react" - -import { motion } from "framer-motion" -import { IconTriangleInfoFill } from "justd-icons" -import type { MeterProps as AriaMeterProps } from "react-aria-components" +import { IconCircleInfo, IconTriangleInfo } from "justd-icons" +import type { MeterProps as MeterPrimitiveProps } from "react-aria-components" import { Meter as MeterPrimitive } from "react-aria-components" import { Label } from "./field" -import { ctr } from "./primitive" +import { cn, ctr } from "./primitive" -export interface MeterProps extends AriaMeterProps { +export interface MeterProps extends MeterPrimitiveProps { label?: string } -const Meter = ({ label, ...props }: MeterProps) => { +export function Meter({ + label, + positive, + informative, + ...props +}: MeterProps & + ( + | { + positive?: true + informative?: never + } + | { positive?: never; informative?: true } + )) { return ( {({ percentage, valueText }) => ( <> -
+
- = 80 ? "text-danger" : "text-muted-fg"}`}> - {percentage >= 80 && ( - + {percentage >= 90 ? ( + + ) : percentage >= 80 ? ( + - )} - {" " + valueText} + ) : null} + {valueText}
-
- +
@@ -49,12 +58,8 @@ const Meter = ({ label, ...props }: MeterProps) => { } const getColor = (percentage: number) => { - if (percentage < 30) { - return "#0d6efd" // Blue - } - if (percentage < 50) { - return "#198754" // Green + return "#0d6efd" // Green } if (percentage < 70) { @@ -67,5 +72,3 @@ const getColor = (percentage: number) => { return "#e11d48" // Red } - -export { Meter, getColor } diff --git a/components/ui/progress-bar.tsx b/components/ui/progress-bar.tsx index 723b29cd..f4757462 100644 --- a/components/ui/progress-bar.tsx +++ b/components/ui/progress-bar.tsx @@ -1,17 +1,12 @@ "use client" -import * as React from "react" - -import { motion } from "framer-motion" -import { - ProgressBar as ProgressBarPrimitive, - type ProgressBarProps as ProgressBarPrimitiveProps -} from "react-aria-components" +import type { ProgressBarProps as ProgressBarPrimitiveProps } from "react-aria-components" +import { ProgressBar as ProgressBarPrimitive } from "react-aria-components" import { Label } from "./field" -import { ctr } from "./primitive" +import { cn, ctr } from "./primitive" -interface ProgressBarProps extends ProgressBarPrimitiveProps { +export interface ProgressBarProps extends ProgressBarPrimitiveProps { label?: string } @@ -25,25 +20,15 @@ const ProgressBar = ({ label, ...props }: ProgressBarProps) => { {valueText}
- {!isIndeterminate ? ( - - ) : ( - - )} +
)} diff --git a/resources/content/docs/components/statuses/progress-bar.mdx b/resources/content/docs/components/statuses/progress-bar.mdx index d033f331..2f1aa790 100644 --- a/resources/content/docs/components/statuses/progress-bar.mdx +++ b/resources/content/docs/components/statuses/progress-bar.mdx @@ -24,4 +24,4 @@ Progress bars show how much an operation is done, either exactly or roughly, ove ## Indeterminate Progress Bar An indeterminate progress bar is a type of progress indicator that does not show a specific amount of progress or percentage complete. - +