mirror of
https://bitbucket.org/Mattrixwv/mattrixwvreactcomponents.git
synced 2025-12-06 21:53:57 -05:00
Added progress component
This commit is contained in:
13
lib/component/progress/DangerProgress.tsx
Normal file
13
lib/component/progress/DangerProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function DangerProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-red-600)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/DarkProgress.tsx
Normal file
13
lib/component/progress/DarkProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function DarkProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-white)"
|
||||
progressColor="var(--color-black)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/InfoProgress.tsx
Normal file
13
lib/component/progress/InfoProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function InfoProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-cyan-500)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/LightProgress.tsx
Normal file
13
lib/component/progress/LightProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function LightProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-black)"
|
||||
progressColor="var(--color-white)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/MoltenProgress.tsx
Normal file
13
lib/component/progress/MoltenProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function MoltenProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-orange-600)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/PrimaryProgress.tsx
Normal file
13
lib/component/progress/PrimaryProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function PrimaryProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-blue-500)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
79
lib/component/progress/Progress.tsx
Normal file
79
lib/component/progress/Progress.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import type { ProgressProps } from "$/types/Progress";
|
||||
import clsx from "clsx";
|
||||
import { useMemo } from "react";
|
||||
|
||||
|
||||
export default function Progress({
|
||||
id,
|
||||
className,
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
size = "md",
|
||||
rounding = "full",
|
||||
label,
|
||||
tabIndex,
|
||||
progressColor,
|
||||
backgroundColor
|
||||
}: ProgressProps){
|
||||
const percentage = useMemo(() => {
|
||||
const num = !value || Number.isNaN(value) ? min : Math.max(value, min);
|
||||
const den = (!value || Number.isNaN(value) ? max : Math.max(value, max)) - min;
|
||||
const percentage = (num / den) * 100;
|
||||
return percentage && percentage > max ? max : percentage;
|
||||
}, [ min, max, value ]);
|
||||
|
||||
|
||||
return (
|
||||
<div
|
||||
id={id}
|
||||
className={clsx(
|
||||
"relative w-full overflow-hidden",
|
||||
//Size
|
||||
{
|
||||
"": size === "none",
|
||||
"h-2": size === "xs",
|
||||
"h-3": size === "sm",
|
||||
"h-4": size === "md",
|
||||
"h-5": size === "lg",
|
||||
"h-6": size === "xl",
|
||||
"h-full": size === "full"
|
||||
},
|
||||
//Rounding
|
||||
{
|
||||
"": rounding === "none",
|
||||
"rounded-sm": rounding === "sm",
|
||||
"rounded-md": rounding === "md",
|
||||
"rounded-lg": rounding === "lg",
|
||||
"rounded-full": rounding === "full"
|
||||
},
|
||||
className
|
||||
)}
|
||||
role="progressbar"
|
||||
aria-valuemin={min}
|
||||
aria-valuemax={max}
|
||||
aria-valuenow={value ? Math.round(value * 10000) / 100 : undefined}
|
||||
aria-label={label}
|
||||
tabIndex={tabIndex ?? 0}
|
||||
>
|
||||
<div
|
||||
className={clsx(
|
||||
"absolute -left-[0.52px] h-full transition-all duration-250",
|
||||
)}
|
||||
style={{
|
||||
backgroundColor: progressColor,
|
||||
width: `calc(${percentage}% + 1.04px)`
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
className={clsx(
|
||||
"absolute -right-[0.52px] h-full transition-all duration-250",
|
||||
)}
|
||||
style={{
|
||||
backgroundColor: backgroundColor,
|
||||
width: `${100 - percentage}%`
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/SecondaryProgress.tsx
Normal file
13
lib/component/progress/SecondaryProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function SecondaryProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-neutral-500)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/SuccessProgress.tsx
Normal file
13
lib/component/progress/SuccessProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function SuccessProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-green-600)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/TertiaryProgress.tsx
Normal file
13
lib/component/progress/TertiaryProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function TertiaryProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-purple-600)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
13
lib/component/progress/WarningProgress.tsx
Normal file
13
lib/component/progress/WarningProgress.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ThemedProgressProps } from "$/types/Progress";
|
||||
import Progress from "./Progress";
|
||||
|
||||
|
||||
export default function WarningProgress(props: ThemedProgressProps){
|
||||
return (
|
||||
<Progress
|
||||
backgroundColor="var(--color-gray-300)"
|
||||
progressColor="var(--color-yellow-500)"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user