Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

style: new progress bar component (#524)

Brad Barbinfe93c3c0b1c8
diff --git a/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx b/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
index ec5ca58267..f3f69293af 100644
--- a/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
+++ b/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
@@ -1,6 +1,7 @@
import {
Alert,
AlertTitle,
+ BarProgress,
Button,
Combobox,
Input,
@@ -16,7 +17,6 @@ import {
NumberInput,
NumberInputGroup,
NumberInputStepper,
- Progress,
Select,
SelectContent,
SelectItem,
@@ -537,7 +537,7 @@ function ConfiguratorProgress() {
return (
<div className="w-full space-y-2">
- <Progress value={progress} className="h-2" />
+ <BarProgress progress={progress} />
</div>
);
}
diff --git a/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx b/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx
index a4953e959c..25e8f77e61 100644
--- a/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx
+++ b/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx
@@ -50,7 +50,7 @@ const DetailTopbar = ({
);
return (
- <div className="inline-flex h-8 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground">
+ <div className="inline-flex h-9 items-center justify-center rounded-full bg-muted p-1 text-muted-foreground shadow-[inset_0_1px_2px_rgba(0,0,0,0.15)] border-b border-border">
{links.map((route) => {
const isActive = route.isActive
? route.isActive(location.pathname)
@@ -67,8 +67,8 @@ const DetailTopbar = ({
to={linkTo}
prefetch="intent"
className={cn(
- "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
- isActive && "bg-background text-foreground shadow"
+ "inline-flex items-center justify-center whitespace-nowrap rounded-full px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
+ isActive && "bg-background text-foreground shadow-button-base"
)}
>
{route.icon && <route.icon className="mr-2" />}
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
index 949fa49f25..f6f7267534 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
@@ -1,6 +1,6 @@
import {
Card,
- CardDescription,
+ CardContent,
CardHeader,
CardTitle,
VStack
@@ -44,86 +44,83 @@ const InventoryDetails = ({
<VStack>
<div className="w-full grid gap-2 grid-cols-1 md:grid-cols-2 lg:grid-cols-2">
<Card>
- <CardHeader className="pb-8">
- <CardDescription>
- <VStack>Quantity on Hand</VStack>
- </CardDescription>
- <CardTitle className="text-4xl">
- {`${formatter.format(quantities?.quantityOnHand ?? 0)}`}
- </CardTitle>
+ <CardHeader>
+ <CardTitle>Quantity on Hand</CardTitle>
</CardHeader>
+ <CardContent>
+ <h3 className="text-4xl font-medium tracking-tighter">
+ {formatter.format(quantities?.quantityOnHand ?? 0)}
+ </h3>
+ </CardContent>
</Card>
<Card>
- <CardHeader className="pb-8">
- <CardDescription>
- <VStack>Days Remaining</VStack>
- </CardDescription>
- <CardTitle className="text-4xl">
- {`${formatter.format(quantities?.daysRemaining ?? 0)}`}
- </CardTitle>
+ <CardHeader>
+ <CardTitle>Days Remaining</CardTitle>
</CardHeader>
+ <CardContent>
+ <h3 className="text-4xl font-medium tracking-tighter">
+ {formatter.format(quantities?.daysRemaining ?? 0)}
+ </h3>
+ </CardContent>
</Card>
<Card>
- <CardHeader className="pb-8">
- <CardDescription>
- <VStack>Daily Usage</VStack>
- </CardDescription>
- <CardTitle className="text-4xl ">
- <div className="flex justify-start items-center gap-1">
- {`${formatter.format(quantities?.usageLast30Days ?? 0)}`}
- </div>
- </CardTitle>
+ <CardHeader>
+ <CardTitle>Daily Usage</CardTitle>
</CardHeader>
+ <CardContent>
+ <h3 className="text-4xl font-medium tracking-tighter">
+ {formatter.format(quantities?.usageLast30Days ?? 0)}
+ </h3>
+ </CardContent>
</Card>
<Card>
- <CardHeader className="pb-8">
- <CardDescription>
- <VStack>Quantity on Purchase Order</VStack>
- </CardDescription>
- <CardTitle className="text-4xl ">
- <div className="flex justify-start items-center gap-1">
- {`${formatter.format(
- quantities?.quantityOnPurchaseOrder ?? 0
- )}`}
- <LuMoveUp className="text-emerald-500 text-lg" />
- </div>
- </CardTitle>
+ <CardHeader>
+ <CardTitle>Quantity on Purchase Order</CardTitle>
</CardHeader>
+ <CardContent>
+ <div className="flex justify-start items-center gap-1">
+ <h3 className="text-4xl font-medium tracking-tighter">
+ {formatter.format(quantities?.quantityOnPurchaseOrder ?? 0)}
+ </h3>
+ <LuMoveUp className="text-emerald-500 text-lg" />
+ </div>
+ </CardContent>
</Card>
<Card>
- <CardHeader className="pb-8">
- <CardDescription>
- <VStack>Quantity on Sales Order</VStack>
- </CardDescription>
- <CardTitle className="text-4xl">
- <div className="flex justify-start items-center gap-1">
- {`${formatter.format(quantities?.quantityOnSalesOrder ?? 0)}`}
- <LuMoveDown className="text-red-500 text-lg" />
- </div>
- </CardTitle>
+ <CardHeader>
+ <CardTitle>Quantity on Sales Order</CardTitle>
</CardHeader>
+ <CardContent>
+ <div className="flex justify-start items-center gap-1">
+ <h3 className="text-4xl font-medium tracking-tighter">
+ {formatter.format(quantities?.quantityOnSalesOrder ?? 0)}
+ </h3>
+ <LuMoveDown className="text-red-500 text-lg" />
+ </div>
+ </CardContent>
</Card>
<Card>
- <CardHeader className="pb-8 ">
- <CardDescription>
- <VStack>Quantity on Jobs</VStack>
- </CardDescription>
- <CardTitle className="text-4xl flex items-start justify-start gap-2">
+ <CardHeader>
+ <CardTitle>Quantity on Jobs</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <div className="flex items-start justify-start gap-2">
<div className="flex justify-start items-center gap-1">
- <span>{`${formatter.format(
- quantities?.quantityOnProductionOrder ?? 0
- )}`}</span>
+ <h3 className="text-4xl font-medium tracking-tighter">
+ {formatter.format(quantities?.quantityOnProductionOrder ?? 0)}
+ </h3>
<LuMoveUp className="text-emerald-500 text-lg" />
</div>
-
<div className="flex justify-start items-center gap-1">
- <span>{`${formatter.format(
- quantities?.quantityOnProductionDemand ?? 0
- )}`}</span>
+ <h3 className="text-4xl font-medium tracking-tighter">
+ {formatter.format(
+ quantities?.quantityOnProductionDemand ?? 0
+ )}
+ </h3>
<LuMoveDown className="text-red-500 text-lg" />
</div>
- </CardTitle>
- </CardHeader>
+ </div>
+ </CardContent>
</Card>
</div>
<InventoryShelves
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
index 1a5c548b40..78ed584fc8 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
@@ -1,6 +1,7 @@
import { useCarbon } from "@carbon/auth";
import {
Badge,
+ BarProgress,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
@@ -9,7 +10,6 @@ import {
HStack,
MenuIcon,
MenuItem,
- Progress,
toast,
useDisclosure,
VStack
@@ -238,14 +238,12 @@ const JobsTable = memo(({ data, count, tags }: JobsTableProps) => {
cell: ({ row }) => {
if (row.original.status === "Ready") {
return (
- <Progress
- value={
+ <BarProgress
+ progress={
((row.original.quantityComplete ?? 0) /
(row.original.quantity ?? 0)) *
100
}
- numerator={(row.original.quantityComplete ?? 0).toString()}
- denominator={(row.original.quantity ?? 0).toString()}
/>
);
}
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
index 77d40542b3..3b71d96e13 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
@@ -1,5 +1,6 @@
import { ValidatedForm } from "@carbon/form";
import {
+ BarProgress,
Card,
CardContent,
CardFooter,
@@ -12,7 +13,6 @@ import {
DropdownMenuTrigger,
HStack,
IconButton,
- Progress as ProgressComponent,
Tooltip,
TooltipContent,
TooltipTrigger
@@ -223,19 +223,10 @@ export function ItemCard({ item, isOverlay, progressByItemId }: ItemCardProps) {
Number(progress) >= 0 &&
Number(item?.duration) >= 0 && (
<HStack>
- <ProgressComponent
- indicatorClassName={
- (progress ?? 0) > (item.duration ?? 0)
- ? "bg-red-500"
- : status === "Paused"
- ? "bg-yellow-500"
- : ""
- }
- numerator={progress ? formatDurationMilliseconds(progress) : ""}
- denominator={
- item.duration ? formatDurationMilliseconds(item.duration) : ""
- }
- value={Math.min(
+ <BarProgress
+ gradient
+ invertGradient
+ progress={Math.min(
progress && item.duration
? (progress / item.duration) * 100
: 0,
@@ -249,14 +240,8 @@ export function ItemCard({ item, isOverlay, progressByItemId }: ItemCardProps) {
Number.isFinite(item.targetQuantity ?? item.quantity) &&
Number(item.targetQuantity ?? item.quantity) > 0 && (
<HStack>
- <ProgressComponent
- numerator={(item.quantityCompleted ?? 0).toString()}
- denominator={(
- item.targetQuantity ??
- item.quantity ??
- 0
- ).toString()}
- value={
+ <BarProgress
+ progress={
item.quantityCompleted &&
(item.targetQuantity ?? item.quantity)
? (item.quantityCompleted /
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/JobCard.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/JobCard.tsx
index 127b2ad368..55eeb98b3e 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/JobCard.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/JobCard.tsx
@@ -1,4 +1,5 @@
import {
+ BarProgress,
Card,
CardContent,
CardFooter,
@@ -11,7 +12,6 @@ import {
DropdownMenuTrigger,
HStack,
IconButton,
- Progress as ProgressComponent,
Tooltip,
TooltipContent,
TooltipTrigger
@@ -235,11 +235,11 @@ export function JobCard({ item, isOverlay, progressByItemId }: JobCardProps) {
Number.isFinite(item.progress) &&
Number(item.progress) >= 0 && (
<HStack>
- <ProgressComponent
- indicatorClassName={
+ <BarProgress
+ activeClassName={
status === "Completed" ? "bg-emerald-500" : "bg-blue-500"
}
- value={Math.min((item.progress ?? 0) * 100, 100)}
+ progress={Math.min((item.progress ?? 0) * 100, 100)}
/>
<FaTasks className="text-muted-foreground w-4 h-4" />
</HStack>
diff --git a/apps/erp/app/modules/quality/ui/Issue/IssueTask.tsx b/apps/erp/app/modules/quality/ui/Issue/IssueTask.tsx
index c4ca9c6c3f..67b59b001e 100644
--- a/apps/erp/app/modules/quality/ui/Issue/IssueTask.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/IssueTask.tsx
@@ -1,6 +1,7 @@
import { useCarbon } from "@carbon/auth";
import type { JSONContent } from "@carbon/react";
import {
+ BarProgress,
Button,
Command,
CommandEmpty,
@@ -21,7 +22,6 @@ import {
Popover,
PopoverContent,
PopoverTrigger,
- Progress,
toast,
useDebounce,
useDisclosure
@@ -54,7 +54,6 @@ import { useRealtime } from "~/hooks/useRealtime";
import type {
Issue,
IssueActionTask,
- IssueInvestigationTask,
IssueItem,
IssueReviewer
} from "~/modules/quality";
@@ -67,7 +66,7 @@ export function TaskProgress({
tasks,
className
}: {
- tasks: { status: IssueInvestigationTask["status"] }[];
+ tasks: { status: IssueActionTask["status"] }[];
className?: string;
}) {
const completedOrSkippedTasks = tasks.filter(
@@ -77,10 +76,11 @@ export function TaskProgress({
return (
<div className={cn("flex flex-col items-end gap-2 pt-2 pr-14", className)}>
- <Progress value={progressPercentage} className="h-2 w-24" />
- <span className="text-xs text-muted-foreground">
- {completedOrSkippedTasks} of {tasks.length} complete
- </span>
+ <BarProgress
+ gradient
+ progress={progressPercentage}
+ value={`${completedOrSkippedTasks}/${tasks.length}`}
+ />
</div>
);
}
@@ -93,10 +93,11 @@ export function ItemProgress({ items }: { items: IssueItem[] }) {
return (
<div className="flex flex-col items-end gap-2 pt-2 pr-14">
- <Progress value={progressPercentage} className="h-2 w-24" />
- <span className="text-xs text-muted-foreground">
- {completedOrSkippedItems} of {items.length} complete
- </span>
+ <BarProgress
+ gradient
+ progress={progressPercentage}
+ value={`${completedOrSkippedItems}/${items.length}`}
+ />
</div>
);
}
@@ -130,7 +131,7 @@ function SupplierAssignment({
supplierIds,
isDisabled = false
}: {
- task: IssueInvestigationTask | IssueActionTask;
+ task: IssueActionTask;
type: "investigation" | "action";
supplierIds: string[];
isDisabled?: boolean;
@@ -253,7 +254,7 @@ export function TaskItem({
showDragHandle = false,
dragControls
}: {
- task: IssueInvestigationTask | IssueActionTask | IssueReviewer;
+ task: IssueActionTask | IssueReviewer;
type: "investigation" | "action" | "review";
suppliers: { supplierId: string; externalLinkId: string | null }[];
isDisabled?: boolean;
@@ -297,7 +298,7 @@ export function TaskItem({
? (task as IssueActionTask).name
: (task as IssueReviewer).title;
- if (task.supplierId) {
+ if (type === "action" && (task as IssueActionTask).supplierId) {
taskTitle = `Supplier ${taskTitle}`;
}
@@ -399,7 +400,7 @@ export function TaskItem({
)}
{(type === "investigation" || type === "action") && (
<SupplierAssignment
- task={task as IssueInvestigationTask | IssueActionTask}
+ task={task as IssueActionTask}
type={type}
supplierIds={suppliers.map((s) => s.supplierId)}
isDisabled={isDisabled}
@@ -512,7 +513,7 @@ function useOptimisticTaskStatus(taskId: string) {
f.key === `nonConformanceTask:${taskId}`
);
return pendingUpdate?.formData?.get("status") as
- | IssueInvestigationTask["status"]
+ | IssueActionTask["status"]
| undefined;
}
@@ -525,11 +526,11 @@ function useTaskStatus({
disabled?: boolean;
task: {
id?: string;
- status: IssueInvestigationTask["status"];
+ status: IssueActionTask["status"];
assignee: string | null;
};
type: "investigation" | "action" | "approval" | "review";
- onChange?: (status: IssueInvestigationTask["status"]) => void;
+ onChange?: (status: IssueActionTask["status"]) => void;
}) {
const submit = useSubmit();
const permissions = usePermissions();
@@ -538,7 +539,7 @@ function useTaskStatus({
const isDisabled = !permissions.can("update", "production") || disabled;
const onOperationStatusChange = useCallback(
- (id: string, status: IssueInvestigationTask["status"]) => {
+ (id: string, status: IssueActionTask["status"]) => {
onChange?.(status);
submit(
{
@@ -576,12 +577,12 @@ export function IssueTaskStatus({
}: {
task: {
id?: string;
- status: IssueInvestigationTask["status"];
+ status: IssueActionTask["status"];
assignee: string | null;
};
type: "investigation" | "action" | "approval" | "review";
className?: string;
- onChange?: (status: IssueInvestigationTask["status"]) => void;
+ onChange?: (status: IssueActionTask["status"]) => void;
isDisabled?: boolean;
}) {
const { currentStatus, onOperationStatusChange } = useTaskStatus({
@@ -610,7 +611,7 @@ export function IssueTaskStatus({
onValueChange={(status) =>
onOperationStatusChange(
task.id!,
- status as IssueInvestigationTask["status"]
+ status as IssueActionTask["status"]
)
}
>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx
index d730f482e7..6b98647ca9 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx
@@ -1,8 +1,8 @@
import {
+ BarProgress,
HStack,
MenuIcon,
MenuItem,
- Progress,
useDisclosure
} from "@carbon/react";
import { formatDate } from "@carbon/utils";
@@ -116,10 +116,9 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
const lines = row.original.lines ?? 0;
const completedLines = row.original.completedLines ?? 0;
return status === "Draft" ? (
- <Progress
- numerator={completedLines.toString()}
- denominator={lines.toString()}
- value={lines === 0 ? 0 : (completedLines / lines) * 100}
+ <BarProgress
+ gradient
+ progress={lines === 0 ? 0 : (completedLines / lines) * 100}
/>
) : (
<QuoteStatus status={status} />
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
index 04b511f4f0..1b9c415ace 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
@@ -2,6 +2,7 @@ import { useCarbon } from "@carbon/auth";
import { ValidatedForm } from "@carbon/form";
import {
Badge,
+ BarProgress,
Button,
Card,
CardAction,
@@ -19,7 +20,6 @@ import {
ModalFooter,
ModalHeader,
ModalTitle,
- Progress,
toast,
useDisclosure,
useMount,
@@ -463,8 +463,8 @@ function JobDetails({ job }: { job: Job }) {
/>
) : (
<div className="py-2 w-full">
- <Progress
- value={Math.min(
+ <BarProgress
+ progress={Math.min(
((operation.quantityComplete ?? 0) /
(operation.targetQuantity ??
operation.operationQuantity ??
@@ -472,14 +472,7 @@ function JobDetails({ job }: { job: Job }) {
100,
100
)}
- numerator={(
- operation.quantityComplete ?? 0
- ).toString()}
- denominator={(
- operation.targetQuantity ??
- operation.operationQuantity ??
- 0
- ).toString()}
+ value={`${operation.quantityComplete ?? 0}/${operation.targetQuantity ?? operation.operationQuantity ?? 0}`}
/>
</div>
)}
diff --git a/apps/erp/app/routes/share+/training.$id.tsx b/apps/erp/app/routes/share+/training.$id.tsx
index 47a3de4121..bcfefb5616 100644
--- a/apps/erp/app/routes/share+/training.$id.tsx
+++ b/apps/erp/app/routes/share+/training.$id.tsx
@@ -4,6 +4,7 @@ import {
Alert,
AlertDescription,
AlertTitle,
+ BarProgress,
Button,
Card,
CardContent,
@@ -15,7 +16,6 @@ import {
HStack,
NumberField,
NumberInput,
- Progress,
RadioGroup,
RadioGroupItem,
Select,
@@ -358,7 +358,7 @@ export default function TrainingWizard() {
spacing={8}
className="w-full min-h-screen max-w-4xl mx-auto p-4 md:p-8 pb-24"
>
- <Progress value={progress} className="w-full" />
+ <BarProgress progress={progress} gradient />
<Card className="w-full">
<CardHeader>
diff --git a/apps/erp/app/routes/x+/resources+/assignments.tsx b/apps/erp/app/routes/x+/resources+/assignments.tsx
index e92c0ed1ba..6db9553236 100644
--- a/apps/erp/app/routes/x+/resources+/assignments.tsx
+++ b/apps/erp/app/routes/x+/resources+/assignments.tsx
@@ -3,10 +3,10 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import {
Badge,
+ BarProgress,
HStack,
MenuIcon,
MenuItem,
- Progress,
VStack
} from "@carbon/react";
import type { ColumnDef } from "@tanstack/react-table";
@@ -193,15 +193,10 @@ const TrainingAssignmentsTable = memo(
accessorKey: "completionPercent",
header: "Progress",
cell: ({ row }) => (
- <HStack spacing={2} className="w-32">
- <Progress
- value={row.original.completionPercent}
- className="h-2"
- />
- <span className="text-xs text-muted-foreground">
- {row.original.completionPercent}%
- </span>
- </HStack>
+ <BarProgress
+ progress={row.original.completionPercent}
+ value={`${row.original.completionPercent}%`}
+ />
),
meta: {
icon: <LuChartColumnIncreasing />
diff --git a/apps/mes/app/components/JobOperation/JobOperation.tsx b/apps/mes/app/components/JobOperation/JobOperation.tsx
index 28cffd1b42..a60ae6d3ef 100644
--- a/apps/mes/app/components/JobOperation/JobOperation.tsx
+++ b/apps/mes/app/components/JobOperation/JobOperation.tsx
@@ -4,7 +4,12 @@ import type { Database } from "@carbon/database";
import type { JSONContent } from "@carbon/react";
import {
Badge,
+ BarProgress,
Button,
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
Copy,
cn,
DropdownMenu,
@@ -17,7 +22,6 @@ import {
HStack,
IconButton,
ModelViewer,
- Progress,
ScrollArea,
Separator,
SidebarTrigger,
@@ -252,7 +256,7 @@ export const JobOperation = ({
if (operation.setupDuration > 0) operations++;
if (operation.laborDuration > 0) operations++;
if (operation.machineDuration > 0) operations++;
- return 40 + operations * 24;
+ return 60 + operations * 40;
}, [
operation.laborDuration,
operation.machineDuration,
@@ -445,18 +449,14 @@ export const JobOperation = ({
</div>
<div className="hidden md:flex flex-shrink-0 items-center justify-end gap-2">
<TabsList className="md:ml-auto">
- <TabsTrigger variant="primary" value="details">
- Details
- </TabsTrigger>
+ <TabsTrigger value="details">Details</TabsTrigger>
<TabsTrigger
- variant="primary"
disabled={!job.modelPath && !operation.itemModelPath}
value="model"
>
Model
</TabsTrigger>
<TabsTrigger
- variant="primary"
disabled={
!operation.workInstruction ||
Object.keys(operation.workInstruction).length === 0
@@ -465,9 +465,7 @@ export const JobOperation = ({
>
Procedure
</TabsTrigger>
- <TabsTrigger variant="primary" value="chat">
- Chat
- </TabsTrigger>
+ <TabsTrigger value="chat">Chat</TabsTrigger>
</TabsList>
</div>
</HStack>
@@ -618,69 +616,69 @@ export const JobOperation = ({
<Separator />
<div className="flex items-start p-4 lg:p-6">
<div className="grid gap-4 sm:grid-cols-1 md:grid-cols-3 w-full">
- <div className="rounded-xl border bg-card text-card-foreground shadow">
- <div className="p-6 flex flex-row items-center justify-between space-y-0 pb-2">
- <h3 className="tracking-tight text-sm font-medium">
- Completed
- </h3>
+ <Card>
+ <CardHeader className="flex flex-row items-center gap-2 justify-between">
+ <CardTitle>Completed</CardTitle>
<FaCheck className="h-3 w-3 text-emerald-500" />
- </div>
- <div className="p-6 pt-0">
+ </CardHeader>
+
+ <CardContent>
<Heading size="h1">
{operation.quantityComplete} of {operation.targetQuantity}
</Heading>
- </div>
- </div>
- <div className="rounded-xl border bg-card text-card-foreground shadow">
- <div className="p-6 flex flex-row items-center justify-between space-y-0 pb-2">
- <h3 className="tracking-tight text-sm font-medium">
- Scrapped
- </h3>
+ </CardContent>
+ </Card>
+ <Card>
+ <CardHeader className="flex flex-row items-center gap-2 justify-between">
+ <CardTitle>Scrapped</CardTitle>
<FaTrash className="h-3 w-3 text-muted-foreground" />
- </div>
- <div className="p-6 pt-0">
+ </CardHeader>
+ <CardContent>
<Heading size="h1">{operation.quantityScrapped}</Heading>
- </div>
- </div>
- <div className="rounded-xl border bg-card text-card-foreground shadow">
- <div className="p-6 flex flex-row items-center justify-between space-y-0 pb-2">
- <h3 className="tracking-tight text-sm font-medium">
- Due Date
- </h3>
+ </CardContent>
+ </Card>
+ <Card>
+ <CardHeader className="flex flex-row items-center gap-2 justify-between">
+ <CardTitle>Due Date</CardTitle>
<DeadlineIcon
deadlineType={operation.jobDeadlineType}
overdue={isOverdue}
/>
- </div>
- <div className="p-6 pt-0">
- <VStack className="justify-start" spacing={0}>
- <Heading
- size="h3"
- className={cn(
- "w-full truncate",
- isOverdue ? "text-red-500" : ""
- )}
- >
- {["ASAP", "No Deadline"].includes(
- operation.jobDeadlineType
- )
- ? operation.jobDeadlineType
- : operation.jobDueDate
- ? `Due ${formatRelativeTime(
- convertDateStringToIsoString(
- operation.jobDueDate
- )
- )}`
- : "–"}
- </Heading>
- <span className="text-muted-foreground text-sm">
- {operation.jobDueDate
- ? formatDate(operation.jobDueDate)
- : null}
- </span>
- </VStack>
- </div>
- </div>
+ </CardHeader>
+ <CardContent>
+ <Heading size="h1">
+ {operation.jobDueDate
+ ? formatDate(operation.jobDueDate)
+ : null}
+ <VStack className="justify-start" spacing={0}>
+ <Heading
+ size="h3"
+ className={cn(
+ "w-full truncate",
+ isOverdue ? "text-red-500" : ""
+ )}
+ >
+ {["ASAP", "No Deadline"].includes(
+ operation.jobDeadlineType
+ )
+ ? operation.jobDeadlineType
+ : operation.jobDueDate
+ ? `Due ${formatRelativeTime(
+ convertDateStringToIsoString(
+ operation.jobDueDate
+ )
+ )}`
+ : "–"}
+ </Heading>
+ <span className="text-muted-foreground text-sm">
+ {operation.jobDueDate
+ ? formatDate(operation.jobDueDate)
+ : null}
+ </span>
+ </VStack>
+ </Heading>
+ </CardContent>
+ </Card>
</div>
</div>
@@ -840,8 +838,11 @@ export const JobOperation = ({
)}
</div>
- <Progress
- value={
+ <BarProgress
+ label="Steps"
+ gradient
+ invertGradient
+ progress={
(attributes.filter((a) =>
a.jobOperationStepRecord.some(
(r) => r.index === activeStep
@@ -850,7 +851,6 @@ export const JobOperation = ({
attributes.length) *
100
}
- className="h-2 w-24"
/>
<span className="text-xs text-muted-foreground">
{
@@ -1743,8 +1743,11 @@ export const JobOperation = ({
</div>
<div className="flex flex-col justify-center items-end gap-1">
- <Progress
- value={
+ <BarProgress
+ label="Steps"
+ gradient
+ invertGradient
+ progress={
(attributes.filter((a) =>
a.jobOperationStepRecord.some(
(r) => r.index === activeStep
@@ -1753,7 +1756,6 @@ export const JobOperation = ({
attributes.length) *
100
}
- className="h-2 w-24"
/>
<span className="text-xs text-muted-foreground">
{
@@ -2062,16 +2064,18 @@ export const JobOperation = ({
</TooltipTrigger>
<TooltipContent side="right">Setup</TooltipContent>
</Tooltip>
- <Progress
- numerator={formatDurationMilliseconds(progress.setup)}
- denominator={formatDurationMilliseconds(
- operation.setupDuration
- )}
- value={(progress.setup / operation.setupDuration) * 100}
- indicatorClassName={
+ <BarProgress
+ label="Setup"
+ gradient
+ invertGradient
+ value={`${formatDurationMilliseconds(progress.setup, { style: "short" })}/${formatDurationMilliseconds(operation.setupDuration, { style: "short" })}`}
+ progress={
+ (progress.setup / operation.setupDuration) * 100
+ }
+ activeClassName={
progress.setup > operation.setupDuration
? "bg-red-500"
- : ""
+ : "bg-emerald-500"
}
/>
</HStack>
@@ -2084,16 +2088,18 @@ export const JobOperation = ({
</TooltipTrigger>
<TooltipContent side="right">Labor</TooltipContent>
</Tooltip>
- <Progress
- numerator={formatDurationMilliseconds(progress.labor)}
- denominator={formatDurationMilliseconds(
- operation.laborDuration
- )}
- value={(progress.labor / operation.laborDuration) * 100}
- indicatorClassName={
+ <BarProgress
+ label="Labor"
+ gradient
+ invertGradient
+ value={`${formatDurationMilliseconds(progress.labor, { style: "short" })}/${formatDurationMilliseconds(operation.laborDuration, { style: "short" })}`}
+ progress={
+ (progress.labor / operation.laborDuration) * 100
+ }
+ activeClassName={
progress.labor > operation.laborDuration
? "bg-red-500"
- : ""
+ : "bg-emerald-500"
}
/>
</HStack>
@@ -2106,18 +2112,18 @@ export const JobOperation = ({
</TooltipTrigger>
<TooltipContent side="right">Machine</TooltipContent>
</Tooltip>
- <Progress
- numerator={formatDurationMilliseconds(progress.machine)}
- denominator={formatDurationMilliseconds(
- operation.machineDuration
- )}
- value={
+ <BarProgress
+ label="Machine"
+ gradient
+ invertGradient
+ value={`${formatDurationMilliseconds(progress.machine, { style: "short" })}/${formatDurationMilliseconds(operation.machineDuration, { style: "short" })}`}
+ progress={
(progress.machine / operation.machineDuration) * 100
}
- indicatorClassName={
+ activeClassName={
progress.machine > operation.machineDuration
? "bg-red-500"
- : ""
+ : "bg-emerald-500"
}
/>
</HStack>
@@ -2129,16 +2135,16 @@ export const JobOperation = ({
</TooltipTrigger>
<TooltipContent side="right">Quantity</TooltipContent>
</Tooltip>
- <Progress
- indicatorClassName={
+ <BarProgress
+ label="Quantity"
+ activeClassName={
operation.operationStatus === "Paused" &&
operation.quantityComplete < operation.targetQuantity
? "bg-yellow-500"
- : ""
+ : "bg-emerald-500"
}
- numerator={operation.quantityComplete.toString()}
- denominator={operation.targetQuantity.toString()}
- value={
+ value={`${operation.quantityComplete}/${operation.targetQuantity}`}
+ progress={
(operation.quantityComplete / operation.targetQuantity) *
100
}
diff --git a/apps/mes/app/components/Kanban/components/ItemCard.tsx b/apps/mes/app/components/Kanban/components/ItemCard.tsx
index 8eb3ebcdd2..48df2a6061 100644
--- a/apps/mes/app/components/Kanban/components/ItemCard.tsx
+++ b/apps/mes/app/components/Kanban/components/ItemCard.tsx
@@ -1,5 +1,6 @@
import {
Badge,
+ BarProgress,
Card,
CardContent,
CardFooter,
@@ -7,7 +8,6 @@ import {
cn,
Heading,
HStack,
- Progress as ProgressComponent,
Tooltip,
TooltipContent,
TooltipTrigger
@@ -139,23 +139,17 @@ export function ItemCard({
Number(progress) >= 0 &&
Number(item?.duration) > 0 && (
<HStack className="mt-2">
- <ProgressComponent
- indicatorClassName={
+ <BarProgress
+ gradient
+ invertGradient
+ activeClassName={
progress > (item.duration ?? 0)
? "bg-red-500"
: status === "Paused"
? "bg-yellow-500"
- : ""
+ : "bg-emerald-500"
}
- numerator={
- progress ? formatDurationMilliseconds(progress) : ""
- }
- denominator={
- item.duration
- ? formatDurationMilliseconds(item.duration)
- : ""
- }
- value={Math.min(
+ progress={Math.min(
progress && item.duration
? (progress / item.duration) * 100
: 0,
@@ -169,14 +163,8 @@ export function ItemCard({
Number.isFinite(item.quantity) &&
Number(item.quantity) > 0 && (
<HStack className="mt-2">
- <ProgressComponent
- numerator={(item.quantityCompleted ?? 0).toString()}
- denominator={(
- item.targetQuantity ??
- item.quantity ??
- 0
- ).toString()}
- value={
+ <BarProgress
+ progress={
item.quantityCompleted && item.targetQuantity
? (item.quantityCompleted / item.targetQuantity) * 100
: 0
diff --git a/packages/react/src/BarProgress.tsx b/packages/react/src/BarProgress.tsx
new file mode 100644
index 0000000000..e599d2a54c
--- /dev/null
+++ b/packages/react/src/BarProgress.tsx
@@ -0,0 +1,178 @@
+"use client";
+
+import { useCallback, useEffect, useRef, useState } from "react";
+import { cn } from "./utils/cn";
+
+const BAR_WIDTH = 2;
+const BAR_HEIGHT = 14;
+const BAR_GAP = 3;
+
+/**
+ * Interpolates between two [r,g,b] colors at a given ratio (0-1).
+ */
+function lerpColor(
+ a: [number, number, number],
+ b: [number, number, number],
+ t: number
+): string {
+ const r = Math.round(a[0] + (b[0] - a[0]) * t);
+ const g = Math.round(a[1] + (b[1] - a[1]) * t);
+ const bl = Math.round(a[2] + (b[2] - a[2]) * t);
+ return `rgb(${r},${g},${bl})`;
+}
+
+type GradientStop = { pos: number; color: [number, number, number] };
+
+// red -> yellow -> green
+const GRADIENT_STOPS: GradientStop[] = [
+ { pos: 0, color: [239, 68, 68] }, // red-500
+ { pos: 0.5, color: [234, 179, 8] }, // yellow-500
+ { pos: 0.8, color: [34, 197, 94] }, // green-500
+ { pos: 1, color: [34, 197, 94] } // green-500
+];
+
+// green -> yellow -> red (inverted)
+const GRADIENT_STOPS_INVERTED: GradientStop[] = [
+ { pos: 0, color: [34, 197, 94] }, // green-500
+ { pos: 0.2, color: [34, 197, 94] }, // green-500
+ { pos: 0.5, color: [234, 179, 8] }, // yellow-500
+ { pos: 0.8, color: [239, 68, 68] }, // red-500
+ { pos: 1, color: [239, 68, 68] } // red-500
+];
+
+function getGradientColor(ratio: number, stops: GradientStop[]): string {
+ const clamped = Math.min(Math.max(ratio, 0), 1);
+ for (let i = 0; i < stops.length - 1; i++) {
+ const curr = stops[i];
+ const next = stops[i + 1];
+ if (clamped >= curr.pos && clamped <= next.pos) {
+ const t = (clamped - curr.pos) / (next.pos - curr.pos);
+ return lerpColor(curr.color, next.color, t);
+ }
+ }
+ return lerpColor(stops[0].color, stops[0].color, 0);
+}
+
+interface BarProgressProps {
+ /** Numeric progress value */
+ progress: number;
+ /** Maximum progress value (default: 100) */
+ max?: number;
+ /** Label displayed above-left of the bar */
+ label?: string;
+ /** Value string displayed above-right of the bar */
+ value?: string;
+ /** Enable a red-yellow-green gradient across active bars */
+ gradient?: boolean;
+ /** Invert the gradient to green-yellow-red */
+ invertGradient?: boolean;
+ /** Additional class names for the outer wrapper */
+ className?: string;
+ /** Class name for the active (filled) bars (ignored when gradient is true) */
+ activeClassName?: string;
+ /** Class name for the inactive (unfilled) bars */
+ inactiveClassName?: string;
+}
+
+export function BarProgress({
+ progress,
+ max = 100,
+ label,
+ value,
+ gradient = false,
+ invertGradient = false,
+ className,
+ activeClassName = "bg-emerald-500",
+ inactiveClassName = "bg-muted"
+}: BarProgressProps) {
+ const containerRef = useRef<HTMLDivElement>(null);
+ const [barCount, setBarCount] = useState(0);
+
+ const calculateBars = useCallback(() => {
+ if (!containerRef.current) return;
+ const width = containerRef.current.clientWidth;
+ // Total width per bar = BAR_WIDTH + BAR_GAP, minus one trailing gap
+ // width = bars * BAR_WIDTH + (bars - 1) * BAR_GAP
+ // width = bars * (BAR_WIDTH + BAR_GAP) - BAR_GAP
+ // bars = floor((width + BAR_GAP) / (BAR_WIDTH + BAR_GAP))
+ const count = Math.floor((width + BAR_GAP) / (BAR_WIDTH + BAR_GAP));
+ setBarCount(Math.max(count, 1));
+ }, []);
+
+ useEffect(() => {
+ const el = containerRef.current;
+ if (!el) return;
+
+ calculateBars();
+
+ const observer = new ResizeObserver(calculateBars);
+ observer.observe(el);
+ return () => observer.disconnect();
+ }, [calculateBars]);
+
+ const clampedProgress = Math.min(Math.max(progress, 0), max);
+ const percentage = (clampedProgress / max) * 100;
+ const activeBars = Math.round((clampedProgress / max) * barCount);
+
+ const hasHeader = label || value;
+
+ return (
+ <div className={cn("w-full", className)}>
+ {hasHeader && (
+ <div className="mb-1.5 flex items-baseline justify-between">
+ {label ? (
+ <span className="text-sm font-medium text-foreground">{label}</span>
+ ) : (
+ <div />
+ )}
+ {value && (
+ <span className="text-xs font-mono text-muted-foreground">
+ {value}
+ </span>
+ )}
+ </div>
+ )}
+ <div
+ ref={containerRef}
+ role="progressbar"
+ aria-valuenow={clampedProgress}
+ aria-valuemin={0}
+ aria-valuemax={max}
+ aria-label={label ?? "Progress"}
+ className="flex w-full items-center gap-[3px]"
+ >
+ {barCount > 0 &&
+ Array.from({ length: barCount }, (_, i) => {
+ const isActive = i < activeBars;
+ const gradientStyle =
+ isActive && gradient && barCount > 0
+ ? {
+ backgroundColor: getGradientColor(
+ i / (barCount - 1 || 1),
+ invertGradient ? GRADIENT_STOPS_INVERTED : GRADIENT_STOPS
+ )
+ }
+ : undefined;
+
+ return (
+ <span
+ key={i}
+ aria-hidden="true"
+ className={cn(
+ "shrink-0 rounded-[2px] transition-colors duration-200",
+ !gradient && isActive && activeClassName,
+ !isActive && inactiveClassName
+ )}
+ style={{
+ width: BAR_WIDTH,
+ height: BAR_HEIGHT,
+ ...gradientStyle
+ }}
+ />
+ );
+ })}
+ <span className="sr-only">{Math.round(percentage)}%</span>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/react/src/Tabs.tsx b/packages/react/src/Tabs.tsx
index 1724b7da2e..1d4174ce7c 100644
--- a/packages/react/src/Tabs.tsx
+++ b/packages/react/src/Tabs.tsx
@@ -15,7 +15,7 @@ const TabsList = forwardRef<
<TabsPrimitive.List
ref={ref}
className={cn(
- "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground shadow-[inset_0_1px_2px_rgba(0,0,0,0.15)]",
+ "inline-flex h-9 items-center justify-center rounded-full bg-muted p-1 text-muted-foreground shadow-[inset_0_1px_2px_rgba(0,0,0,0.15)] border-b border-border",
className
)}
{...props}
@@ -32,11 +32,9 @@ const TabsTrigger = forwardRef<
<TabsPrimitive.Trigger
ref={ref}
className={cn(
- "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
- variant === "primary" &&
- "data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow",
- variant === "secondary" &&
- "data-[state=active]:bg-background data-[state=active]:text-foreground",
+ "inline-flex items-center justify-center whitespace-nowrap rounded-full px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
+ "data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-button-base",
+
className
)}
{...props}
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index 90a626aa10..8816cc98d7 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -19,6 +19,7 @@ import {
} from "./Avatar";
import type { BadgeProps } from "./Badge";
import { Badge, BadgeCloseButton } from "./Badge";
+import { BarProgress } from "./BarProgress";
import type { ButtonProps } from "./Button";
import { Button, buttonVariants } from "./Button";
import {
@@ -312,6 +313,7 @@ export {
AccordionContent,
AccordionItem,
AccordionTrigger,
+ BarProgress,
ActionBar,
ActionBarButton,
ActionMenu,
diff --git a/packages/utils/src/themes.ts b/packages/utils/src/themes.ts
index 9e7290582a..29128762cd 100644
--- a/packages/utils/src/themes.ts
+++ b/packages/utils/src/themes.ts
@@ -164,9 +164,8 @@ export const themes = [
"popover-foreground": "0 0% 98%",
primary: "0 72.2% 50.6%",
"primary-foreground": "0 85.7% 97.3%",
- active: "0 5.2% 13.9%",
- "active-foreground": "0 0% 98%",
-
+ active: "0 40% 17%",
+ "active-foreground": "0 80% 63%",
secondary: "0 0% 14.9%",
"secondary-foreground": "0 0% 98%",
muted: "0 0% 14.9%",
@@ -225,8 +224,8 @@ export const themes = [
"popover-foreground": "60 9.1% 97.8%",
primary: "17 96% 57%",
"primary-foreground": "60 9.1% 3.8%",
- active: "20 24.3% 14.1%",
- "active-foreground": "0 0% 98%",
+ active: "18 40% 17%",
+ "active-foreground": "18 80% 63%",
secondary: "12 6.5% 15.1%",
"secondary-foreground": "60 9.1% 97.8%",
muted: "12 6.5% 15.1%",
@@ -285,8 +284,9 @@ export const themes = [
"popover-foreground": "61 9.1% 97.8%",
primary: "61 100% 53.1%",
"primary-foreground": "61 83.3% 14.1%",
- active: "61 100% 13.1%",
- "active-foreground": "61 100% 53.1%",
+ active: "61 40% 17%",
+ "active-foreground": "61 80% 63%",
+
secondary: "12 6.5% 15.1%",
"secondary-foreground": "61 9.1% 97.8%",
muted: "12 6.5% 15.1%",
@@ -466,8 +466,8 @@ export const themes = [
"popover-foreground": "210 20% 98%",
primary: "327 70% 40.4%",
"primary-foreground": "210 20% 98%",
- active: "263 40% 20%",
- "active-foreground": "263 41 98%",
+ active: "327 40% 17%",
+ "active-foreground": "327 80% 63%",
secondary: "263 27.9% 16.9%",
"secondary-foreground": "263 20% 98%",
muted: "263 27.9% 12.9%",