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.

Chart color fix (#514)

Chase Fosterc22a0bf4f496
diff --git a/apps/erp/app/components/AvatarMenu.tsx b/apps/erp/app/components/AvatarMenu.tsx
index 8c67b144c8..b5fd1bd975 100644
--- a/apps/erp/app/components/AvatarMenu.tsx
+++ b/apps/erp/app/components/AvatarMenu.tsx
@@ -43,13 +43,14 @@ const AvatarMenu = () => {
const edition = useEdition();
const mode = useMode();
- const theme = useTheme();
+ const serverTheme = useTheme();
const nextMode = mode === "dark" ? "light" : "dark";
const modeSubmitRef = useRef<HTMLButtonElement>(null);
const fetcher = useFetcher<typeof action>();
const [isOpen, setIsOpen] = useState(false);
+ const [selectedTheme, setSelectedTheme] = useState<string | null>(null);
const onThemeChange = (t: string) => {
const newTheme = themes.find((theme) => theme.name === t);
@@ -57,6 +58,8 @@ const AvatarMenu = () => {
const variables =
mode === "dark" ? newTheme.cssVars.dark : newTheme.cssVars.light;
+ setSelectedTheme(t);
+
const formData = new FormData();
formData.append("theme", t);
fetcher.submit(formData, { method: "post", action: path.to.theme });
@@ -66,8 +69,7 @@ const AvatarMenu = () => {
});
};
- const optimisticTheme =
- (fetcher?.formData?.get("theme") as string | null) ?? theme;
+ const optimisticTheme = selectedTheme ?? serverTheme;
const itarDisclosure = useDisclosure();
diff --git a/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx b/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx
index b99629dcb0..390ac03abb 100644
--- a/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx
+++ b/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx
@@ -1,8 +1,15 @@
-import { cn, IconButton, useDisclosure } from "@carbon/react";
+import { cn, IconButton, useIsMobile } from "@carbon/react";
import { motion, useReducedMotion } from "framer-motion";
import type { ComponentProps, PropsWithChildren } from "react";
-import { createContext, forwardRef, useContext, useMemo } from "react";
+import {
+ createContext,
+ forwardRef,
+ useContext,
+ useEffect,
+ useMemo
+} from "react";
import { LuPanelLeft } from "react-icons/lu";
+import { useUIStore } from "~/stores/ui";
interface CollapsibleSidebarContextValue {
hasSidebar: boolean;
@@ -24,14 +31,23 @@ export function useCollapsibleSidebar() {
}
export function CollapsibleSidebarProvider({ children }: PropsWithChildren) {
- const disclosure = useDisclosure({ defaultIsOpen: true });
+ const isMobile = useIsMobile();
+ const isSidebarOpen = useUIStore((state) => state.isSidebarOpen);
+ const setSidebarOpen = useUIStore((state) => state.setSidebarOpen);
+ const toggleSidebar = useUIStore((state) => state.toggleSidebar);
+
+ useEffect(() => {
+ if (isMobile) {
+ setSidebarOpen(false);
+ }
+ }, [isMobile, setSidebarOpen]);
return (
<CollapsibleSidebarContext.Provider
value={{
hasSidebar: true,
- isOpen: disclosure.isOpen,
- onToggle: disclosure.onToggle
+ isOpen: isSidebarOpen,
+ onToggle: toggleSidebar
}}
>
{children}
diff --git a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
index 80ad76c577..fae4446f71 100644
--- a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
+++ b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
@@ -104,8 +104,9 @@ const GroupedContentSidebar = ({
variant={isActive ? "active" : "ghost"}
className={cn(
"justify-start flex-grow truncate",
- !isActive &&
- "hover:bg-active hover:text-active-foreground hover:scale-100 focus-visible:scale-100"
+ isActive
+ ? "shadow-none dark:shadow-button-base"
+ : "hover:bg-active hover:text-active-foreground hover:scale-100 focus-visible:scale-100"
)}
>
<Link
@@ -231,9 +232,10 @@ const ViewsReorderGroup = ({
asChild
variant={isViewActive ? "active" : "ghost"}
className={cn(
- "justify-start text-sm pl-7 pr-7 truncate flex-grow",
- !isViewActive &&
- "hover:bg-active hover:text-active-foreground"
+ "justify-start text-sm pl-7 pr-7 truncate flex-grow !shadow-none",
+ isViewActive
+ ? "shadow-none border-active-foreground/30 dark:border-none dark:shadow-button-base"
+ : "hover:bg-active hover:text-active-foreground"
)}
>
<Link to={view.to} prefetch="intent">
diff --git a/apps/erp/app/components/Layout/Navigation/PrimaryNavigation.tsx b/apps/erp/app/components/Layout/Navigation/PrimaryNavigation.tsx
index 55db27727b..9c58f9d919 100644
--- a/apps/erp/app/components/Layout/Navigation/PrimaryNavigation.tsx
+++ b/apps/erp/app/components/Layout/Navigation/PrimaryNavigation.tsx
@@ -94,7 +94,7 @@ const NavigationIconLink = forwardRef<
// Hover state (non-active items)
!isActive && "hover:bg-accent hover:text-accent-foreground",
// Active/selected state - solid background, no gradient overlay
- isActive && "bg-active text-active-foreground shadow-button-base",
+ isActive && "bg-active text-active-foreground dark:shadow-button-base",
"group/item"
];
diff --git a/apps/erp/app/hooks/useTheme.tsx b/apps/erp/app/hooks/useTheme.tsx
index c65201e47b..0009a0374d 100644
--- a/apps/erp/app/hooks/useTheme.tsx
+++ b/apps/erp/app/hooks/useTheme.tsx
@@ -21,7 +21,7 @@ export function useTheme() {
const optimisticTheme = useOptimisticTheme();
const routeData = useRouteData<{ theme: string }>(path.to.root);
- let theme = routeData?.theme ?? "carbon";
+ let theme = routeData?.theme ?? "zinc";
if (optimisticTheme) {
theme = optimisticTheme;
diff --git a/apps/erp/app/routes/x+/production+/_index.tsx b/apps/erp/app/routes/x+/production+/_index.tsx
index 1a864659c2..89d2d620f3 100644
--- a/apps/erp/app/routes/x+/production+/_index.tsx
+++ b/apps/erp/app/routes/x+/production+/_index.tsx
@@ -26,7 +26,8 @@ import {
Tooltip,
TooltipContent,
TooltipTrigger,
- useRealtimeChannel
+ useRealtimeChannel,
+ VStack
} from "@carbon/react";
import type { ChartConfig } from "@carbon/react/Chart";
import {
@@ -175,52 +176,63 @@ export default function ProductionDashboard() {
setInterval(value);
};
- const getTotal = (
- key: string,
- data?: { value: number }[] | { actual: number; estimate: number }[]
- ) => {
- if (!data) return 0;
- switch (key) {
- case "utilization":
- return data.reduce((acc, item) => {
- // @ts-expect-error
- return acc + item.value;
- }, 0);
- case "completionTime":
- return data.length === 0
- ? 0
- : data.reduce((acc, item) => {
- // @ts-expect-error
- return acc + item.value;
- }, 0) / data.length;
- case "estimate":
- return data.reduce((acc, item) => {
- // @ts-expect-error
- return acc + item.estimate;
- }, 0);
- case "actual":
- return data.reduce((acc, item) => {
- // @ts-expect-error
- return acc + item.actual;
- }, 0);
- default:
- return 0;
+ const totalData = useMemo(() => {
+ if (!kpiFetcher.data?.data) return null;
+ const data = kpiFetcher.data.data;
+
+ if (selectedKpi === "utilization") {
+ return {
+ // @ts-expect-error
+ value: data.reduce((acc, item) => acc + item.value, 0)
+ };
+ }
+ if (selectedKpi === "completionTime") {
+ if (data.length === 0) return { value: 0 };
+ return {
+ // @ts-expect-error
+ value: data.reduce((acc, item) => acc + item.value, 0) / data.length
+ };
+ }
+ if (selectedKpi === "estimatesVsActuals") {
+ return {
+ // @ts-expect-error
+ value: data.reduce((acc, item) => acc + item.actual, 0)
+ };
+ }
+ return { value: 0 };
+ }, [kpiFetcher.data?.data, selectedKpi]);
+
+ const previousTotalData = useMemo(() => {
+ if (selectedKpi === "estimatesVsActuals") {
+ if (!kpiFetcher.data?.data) return null;
+ return {
+ // @ts-expect-error
+ value: kpiFetcher.data.data.reduce(
+ (acc, item) => acc + item.estimate,
+ 0
+ )
+ };
}
- };
- const total = getTotal(
- selectedKpi === "estimatesVsActuals" ? "actual" : selectedKpi,
- kpiFetcher.data?.data
- );
+ if (!kpiFetcher.data?.previousPeriodData) return null;
+ const data = kpiFetcher.data.previousPeriodData as { value: number }[];
- const previousTotal = getTotal(
- selectedKpi === "estimatesVsActuals" ? "estimate" : selectedKpi,
- selectedKpi === "estimatesVsActuals"
- ? kpiFetcher.data?.data
- : (kpiFetcher.data?.previousPeriodData as {
- value: number;
- }[])
- );
+ if (selectedKpi === "utilization") {
+ return {
+ value: data.reduce((acc, item) => acc + item.value, 0)
+ };
+ }
+ if (selectedKpi === "completionTime") {
+ if (data.length === 0) return { value: 0 };
+ return {
+ value: data.reduce((acc, item) => acc + item.value, 0) / data.length
+ };
+ }
+ return { value: 0 };
+ }, [kpiFetcher.data?.data, kpiFetcher.data?.previousPeriodData, selectedKpi]);
+
+ const total = totalData?.value ?? 0;
+ const previousTotal = previousTotalData?.value ?? 0;
const percentageChange =
previousTotal === 0
@@ -229,6 +241,10 @@ export default function ProductionDashboard() {
: 0
: ((total - previousTotal) / previousTotal) * 100;
+ const formatValue = (value: number) => {
+ return formatDurationMilliseconds(value);
+ };
+
const csvData = useMemo(() => {
if (!kpiFetcher.data?.data) return [];
@@ -281,7 +297,7 @@ export default function ProductionDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{activeJobs}
</h3>
<Button
@@ -308,7 +324,7 @@ export default function ProductionDashboard() {
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{assignedJobs}
</h3>
<Button
@@ -414,15 +430,17 @@ export default function ProductionDashboard() {
</CardAction>
</HStack>
<CardContent className="max-h-[600px] min-h-[320px] flex-col gap-4">
- <HStack className="pl-[3px] pt-1">
+ <VStack className="pl-[3px]" spacing={0}>
{isFetching ? (
- <Skeleton className="h-8 w-1/2" />
+ <div className="flex flex-col gap-0.5 w-full">
+ <Skeleton className="h-8 w-[120px]" />
+ <Skeleton className="h-4 w-[50px]" />
+ </div>
) : (
<>
- <p className="text-xl font-semibold tracking-tight">
- {formatDurationMilliseconds(total)}
+ <p className="text-3xl font-medium tracking-tighter">
+ {formatValue(total)}
</p>
-
{percentageChange >= 0 ? (
<Badge variant="green">
+{percentageChange.toFixed(0)}%
@@ -432,7 +450,7 @@ export default function ProductionDashboard() {
)}
</>
)}
- </HStack>
+ </VStack>
{kpiFetcher.state === "idle" &&
kpiFetcher.data?.data?.length === 0 ? (
<div className="flex flex-col items-center justify-center h-full">
diff --git a/apps/erp/app/routes/x+/purchasing+/_index.tsx b/apps/erp/app/routes/x+/purchasing+/_index.tsx
index 19fb3a865c..0a4acc1f5f 100644
--- a/apps/erp/app/routes/x+/purchasing+/_index.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/_index.tsx
@@ -26,7 +26,8 @@ import {
Td,
Th,
Thead,
- Tr
+ Tr,
+ VStack
} from "@carbon/react";
import type { ChartConfig } from "@carbon/react/Chart";
import {
@@ -92,7 +93,11 @@ const OPEN_PURCHASE_ORDER_STATUSES = [
"To Invoice"
] as const;
-const chartConfig = {} satisfies ChartConfig;
+const chartConfig = {
+ value: {
+ color: "hsl(var(--primary))"
+ }
+} satisfies ChartConfig;
export async function loader({ request }: LoaderFunctionArgs) {
const { client, userId, companyId } = await requirePermissions(request, {
@@ -295,13 +300,26 @@ export default function PurchaseDashboard() {
setInterval(value);
};
- const total =
- kpiFetcher.data?.data.reduce((acc, curr) => acc + curr.value, 0) ?? 0;
- const previousTotal =
- kpiFetcher.data?.previousPeriodData.reduce(
- (acc, curr) => acc + curr.value,
- 0
- ) ?? 0;
+ const totalData = useMemo(() => {
+ if (!kpiFetcher.data?.data) return null;
+ return {
+ value: kpiFetcher.data.data.reduce((acc, curr) => acc + curr.value, 0)
+ };
+ }, [kpiFetcher.data?.data]);
+
+ const previousTotalData = useMemo(() => {
+ if (!kpiFetcher.data?.previousPeriodData) return null;
+ return {
+ value: kpiFetcher.data.previousPeriodData.reduce(
+ (acc, curr) => acc + curr.value,
+ 0
+ )
+ };
+ }, [kpiFetcher.data?.previousPeriodData]);
+
+ const total = totalData?.value ?? 0;
+ const previousTotal = previousTotalData?.value ?? 0;
+
const percentageChange =
previousTotal === 0
? total > 0
@@ -309,6 +327,17 @@ export default function PurchaseDashboard() {
: 0
: ((total - previousTotal) / previousTotal) * 100;
+ const formatValue = (value: number) => {
+ if (
+ ["purchaseOrderAmount", "purchaseInvoiceAmount"].includes(
+ selectedKpiData.key
+ )
+ ) {
+ return currencyFormatter.format(value);
+ }
+ return numberFormatter.format(value);
+ };
+
const csvData = useMemo(() => {
if (!kpiFetcher.data?.data) return [];
return [
@@ -335,7 +364,7 @@ export default function PurchaseDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openSupplierQuotes.count ?? 0}
</h3>
<Button
@@ -361,7 +390,7 @@ export default function PurchaseDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openPurchaseOrders.count ?? 0}
</h3>
<Button
@@ -387,7 +416,7 @@ export default function PurchaseDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openPurchaseInvoices.count ?? 0}
</h3>
<Button
@@ -505,17 +534,16 @@ export default function PurchaseDashboard() {
</CardAction>
</HStack>
<CardContent className="flex-col gap-4">
- <HStack className="pl-[3px] pt-1">
+ <VStack className="pl-[3px]" spacing={0}>
{isFetching ? (
- <Skeleton className="h-8 w-1/2" />
+ <div className="flex flex-col gap-0.5 w-full">
+ <Skeleton className="h-8 w-[120px]" />
+ <Skeleton className="h-4 w-[50px]" />
+ </div>
) : (
<>
- <p className="text-xl font-semibold tracking-tight">
- {["purchaseOrderAmount", "purchaseInvoiceAmount"].includes(
- selectedKpiData.key
- )
- ? currencyFormatter.format(total)
- : numberFormatter.format(total)}
+ <p className="text-3xl font-medium tracking-tighter">
+ {formatValue(total)}
</p>
{percentageChange >= 0 ? (
<Badge variant="green">+{percentageChange.toFixed(0)}%</Badge>
@@ -524,7 +552,7 @@ export default function PurchaseDashboard() {
)}
</>
)}
- </HStack>
+ </VStack>
<Loading
isLoading={isFetching}
className="h-[30dvw] md:h-[23dvw] w-full"
@@ -589,7 +617,7 @@ export default function PurchaseDashboard() {
/>
}
/>
- <Bar dataKey="value" className="fill-violet-600" radius={2} />
+ <Bar dataKey="value" fill="var(--color-value)" radius={2} />
</BarChart>
</ChartContainer>
</Loading>
diff --git a/apps/erp/app/routes/x+/resources+/_index.tsx b/apps/erp/app/routes/x+/resources+/_index.tsx
index 835491d821..680cbc4a77 100644
--- a/apps/erp/app/routes/x+/resources+/_index.tsx
+++ b/apps/erp/app/routes/x+/resources+/_index.tsx
@@ -25,7 +25,8 @@ import {
Td,
Th,
Thead,
- Tr
+ Tr,
+ VStack
} from "@carbon/react";
import type { ChartConfig } from "@carbon/react/Chart";
import {
@@ -63,7 +64,11 @@ import { path } from "~/utils/path";
const OPEN_STATUSES = ["Open", "Assigned", "In Progress"] as const;
-const chartConfig = {} satisfies ChartConfig;
+const chartConfig = {
+ value: {
+ color: "hsl(var(--primary))"
+ }
+} satisfies ChartConfig;
export async function loader({ request }: LoaderFunctionArgs) {
const { client, userId, companyId } = await requirePermissions(request, {
@@ -279,7 +284,7 @@ export default function MaintenanceDashboard() {
const formatValue = (value: number) => {
// Time-based KPIs (MTTR, MTBF) - value is in seconds
if (selectedKpi === "mttr" || selectedKpi === "mtbf") {
- return formatDurationMilliseconds(value * 1000);
+ return formatDurationMilliseconds(value * 1000, { style: "short" });
}
// Cost-based KPIs
if (selectedKpi === "sparePartCost") {
@@ -341,7 +346,7 @@ export default function MaintenanceDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openDispatches}
</h3>
<Button
@@ -367,7 +372,7 @@ export default function MaintenanceDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openScheduled}
</h3>
<Button
@@ -393,7 +398,7 @@ export default function MaintenanceDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openReactive}
</h3>
<Button
@@ -511,12 +516,15 @@ export default function MaintenanceDashboard() {
</CardAction>
</HStack>
<CardContent className="flex-col gap-4">
- <HStack className="pl-[3px] pt-1">
+ <VStack className="pl-[3px]" spacing={0}>
{isFetching ? (
- <Skeleton className="h-8 w-1/2" />
+ <div className="flex flex-col gap-0.5 w-full">
+ <Skeleton className="h-8 w-[120px]" />
+ <Skeleton className="h-4 w-[50px]" />
+ </div>
) : (
<>
- <p className="text-xl font-semibold tracking-tight">
+ <p className="text-3xl font-medium tracking-tighter">
{formatValue(total)}
</p>
{isBadgePositive ? (
@@ -532,7 +540,7 @@ export default function MaintenanceDashboard() {
)}
</>
)}
- </HStack>
+ </VStack>
<Loading
isLoading={isFetching}
className="h-[30dvw] md:h-[23dvw] w-full"
@@ -566,7 +574,7 @@ export default function MaintenanceDashboard() {
/>
}
/>
- <Bar dataKey="value" className="fill-red-500" radius={2} />
+ <Bar dataKey="value" fill="var(--color-value)" radius={2} />
</BarChart>
</ChartContainer>
) : (
@@ -637,19 +645,7 @@ export default function MaintenanceDashboard() {
/>
}
/>
- <Bar
- dataKey="value"
- className={
- ["mttr", "mtbf"].includes(selectedKpiData.key)
- ? "fill-blue-500"
- : ["sparePartCost", "sparePartConsumption"].includes(
- selectedKpiData.key
- )
- ? "fill-amber-500"
- : "fill-teal-500"
- }
- radius={2}
- />
+ <Bar dataKey="value" fill="var(--color-value)" radius={2} />
</BarChart>
</ChartContainer>
)}
diff --git a/apps/erp/app/routes/x+/sales+/_index.tsx b/apps/erp/app/routes/x+/sales+/_index.tsx
index 29d285f685..468b606278 100644
--- a/apps/erp/app/routes/x+/sales+/_index.tsx
+++ b/apps/erp/app/routes/x+/sales+/_index.tsx
@@ -8,7 +8,6 @@ import {
CardHeader,
CardTitle,
Combobox,
- cn,
DateRangePicker,
DropdownMenu,
DropdownMenuContent,
@@ -26,7 +25,8 @@ import {
Td,
Th,
Thead,
- Tr
+ Tr,
+ VStack
} from "@carbon/react";
import type { ChartConfig } from "@carbon/react/Chart";
import {
@@ -79,7 +79,11 @@ const OPEN_SALES_ORDER_STATUSES = [
"Draft"
] as const;
-const chartConfig = {} satisfies ChartConfig;
+const chartConfig = {
+ value: {
+ color: "hsl(var(--primary))"
+ }
+} satisfies ChartConfig;
export async function loader({ request }: LoaderFunctionArgs) {
const { client, userId, companyId } = await requirePermissions(request, {
@@ -307,6 +311,13 @@ export default function SalesDashboard() {
: 0
: ((total - previousTotal) / previousTotal) * 100;
+ const formatValue = (value: number) => {
+ if (["salesOrderRevenue", "salesFunnel"].includes(selectedKpiData.key)) {
+ return currencyFormatter.format(value);
+ }
+ return numberFormatter.format(value);
+ };
+
const csvData = useMemo(() => {
if (!kpiFetcher.data?.data) return [];
@@ -360,7 +371,7 @@ export default function SalesDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openRFQs.count ?? 0}
</h3>
<Button
@@ -386,7 +397,7 @@ export default function SalesDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openQuotes.count ?? 0}
</h3>
<Button
@@ -412,7 +423,7 @@ export default function SalesDashboard() {
</CardHeader>
<CardContent>
<HStack className="justify-between w-full items-center">
- <h3 className="text-5xl font-medium tracking-tight">
+ <h3 className="text-5xl font-medium tracking-tighter">
{openSalesOrders.count ?? 0}
</h3>
<Button
@@ -530,17 +541,16 @@ export default function SalesDashboard() {
</CardAction>
</HStack>
<CardContent className="flex-col gap-4">
- <HStack className="pl-[3px] pt-1">
+ <VStack className="pl-[3px]" spacing={0}>
{isFetching ? (
- <Skeleton className="h-8 w-1/2" />
+ <div className="flex flex-col gap-0.5 w-full">
+ <Skeleton className="h-8 w-[120px]" />
+ <Skeleton className="h-4 w-[50px]" />
+ </div>
) : (
<>
- <p className="text-xl font-semibold tracking-tight">
- {["salesOrderRevenue", "salesFunnel"].includes(
- selectedKpiData.key
- )
- ? currencyFormatter.format(total)
- : numberFormatter.format(total)}
+ <p className="text-3xl font-medium tracking-tighter">
+ {formatValue(total)}
</p>
{percentageChange >= 0 ? (
<Badge variant="green">+{percentageChange.toFixed(0)}%</Badge>
@@ -549,7 +559,7 @@ export default function SalesDashboard() {
)}
</>
)}
- </HStack>
+ </VStack>
<Loading
isLoading={isFetching}
className="h-[30dvw] md:h-[23dvw] w-full"
@@ -615,19 +625,7 @@ export default function SalesDashboard() {
/>
}
/>
- <Bar
- dataKey="value"
- className={cn(
- ["salesOrderRevenue", "salesOrderCount"].includes(
- selectedKpiData.key
- ) && "fill-teal-400",
- ["quoteCount"].includes(selectedKpiData.key) &&
- "fill-blue-600",
- ["rfqCount"].includes(selectedKpiData.key) &&
- "fill-violet-600"
- )}
- radius={2}
- />
+ <Bar dataKey="value" fill="var(--color-value)" radius={2} />
</BarChart>
</ChartContainer>
)}
diff --git a/apps/erp/app/stores/ui.ts b/apps/erp/app/stores/ui.ts
index 120ccdbcf7..9ad318ba10 100644
--- a/apps/erp/app/stores/ui.ts
+++ b/apps/erp/app/stores/ui.ts
@@ -5,6 +5,9 @@ interface UIStore {
openSearchModal: () => void;
closeSearchModal: () => void;
toggleSearchModal: () => void;
+ isSidebarOpen: boolean;
+ setSidebarOpen: (open: boolean) => void;
+ toggleSidebar: () => void;
}
export const useUIStore = create<UIStore>()((set) => ({
@@ -12,5 +15,8 @@ export const useUIStore = create<UIStore>()((set) => ({
openSearchModal: () => set({ isSearchModalOpen: true }),
closeSearchModal: () => set({ isSearchModalOpen: false }),
toggleSearchModal: () =>
- set((state) => ({ isSearchModalOpen: !state.isSearchModalOpen }))
+ set((state) => ({ isSearchModalOpen: !state.isSearchModalOpen })),
+ isSidebarOpen: true,
+ setSidebarOpen: (open) => set({ isSidebarOpen: open }),
+ toggleSidebar: () => set((state) => ({ isSidebarOpen: !state.isSidebarOpen }))
}));
diff --git a/llm/cache/coding-conventions.md b/llm/cache/coding-conventions.md
index e95449fbc4..b3dc056668 100644
--- a/llm/cache/coding-conventions.md
+++ b/llm/cache/coding-conventions.md
@@ -128,3 +128,22 @@ const { client, companyId, userId } = await requirePermissions(request, {
- Responsive design with Tailwind utilities
- Accessibility considerations (ARIA attributes)
- Dark mode support via theme system
+
+## Theme System
+
+Themes are defined in `packages/utils/src/themes.ts` with CSS variables for colors. The user's selected theme is stored in the database and accessed via the `useTheme()` hook in `apps/erp/app/hooks/useTheme.tsx`.
+
+Each theme defines a `primary` CSS variable that represents the theme's main color. To use the theme color dynamically:
+
+```typescript
+// In Recharts components, use hsl(var(--primary)) for theme-aware colors
+<Bar dataKey="value" fill="hsl(var(--primary))" radius={2} />
+```
+
+The theme CSS variables are applied to the body element and include:
+- `--primary` / `--primary-foreground`: Main theme color
+- `--background` / `--foreground`: Base colors
+- `--card`, `--popover`, `--secondary`, `--muted`, `--accent`: Component colors
+- `--destructive`, `--success`: Semantic colors
+
+Available themes: zinc (Modern), neutral (Brutal), red (Cherry), orange (Apricot), yellow (Lemon), green (Mint), blue (Blueberry), violet (Lavender)
diff --git a/packages/react/src/Button.tsx b/packages/react/src/Button.tsx
index a0a8112e9e..25651464c8 100644
--- a/packages/react/src/Button.tsx
+++ b/packages/react/src/Button.tsx
@@ -26,7 +26,7 @@ export const buttonVariants = cva(
active:
"bg-active text-active-foreground hover:bg-active/90 hover:text-active-foreground shadow-button-base before:hidden",
secondary:
- "bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 shadow-button-base",
+ "bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 shadow-button-base",
solid:
"bg-accent text-accent-foreground hover:bg-accent/90 shadow-button-base",
destructive:
diff --git a/packages/react/src/Command.tsx b/packages/react/src/Command.tsx
index 9d9cb4286d..a97ceb8d9c 100644
--- a/packages/react/src/Command.tsx
+++ b/packages/react/src/Command.tsx
@@ -274,7 +274,7 @@ const commandTriggerVariants = cva(
asButton: {
false:
"text-foreground flex w-full whitespace-nowrap rounded-md border border-input shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 overflow-hidden",
- true: "relative font-medium shrink-0 group inline-flex select-none transform-gpu initial:border-none disabled:opacity-50 focus:!outline-none focus:!ring-0 active:!outline-none active:!ring-0 after:pointer-events-none after:absolute after:-inset-[3px] after:rounded-lg after:border after:border-blue-500 after:opacity-0 after:ring-2 after:ring-blue-500/20 after:transition-opacity focus-visible:after:opacity-100 active:after:opacity-0 before:pointer-events-none before:bg-gradient-to-b before:transition-opacity before:from-white/[0.12] before:absolute before:inset-0 before:z-[1] before:rounded before:opacity-0 bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 shadow-button-base hover:scale-95 focus-visible:scale-95 transition-all duration-150 ease-in-out"
+ true: "text-foreground relative font-medium shrink-0 group inline-flex select-none transform-gpu initial:border-none disabled:opacity-50 focus:!outline-none focus:!ring-0 active:!outline-none active:!ring-0 after:pointer-events-none after:absolute after:-inset-[3px] after:rounded-lg after:border after:border-blue-500 after:opacity-0 after:ring-2 after:ring-blue-500/20 after:transition-opacity focus-visible:after:opacity-100 active:after:opacity-0 before:pointer-events-none before:bg-gradient-to-b before:transition-opacity before:from-white/[0.12] before:absolute before:inset-0 before:z-[1] before:rounded before:opacity-0 bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 shadow-button-base hover:scale-95 focus-visible:scale-95 transition-all duration-150 ease-in-out"
}
},
defaultVariants: {
diff --git a/packages/utils/src/themes.ts b/packages/utils/src/themes.ts
index 88b9147443..9e7290582a 100644
--- a/packages/utils/src/themes.ts
+++ b/packages/utils/src/themes.ts
@@ -16,8 +16,8 @@ export const themes = [
"card-foreground": "220 10% 3.9%",
popover: "0 0% 100%",
"popover-foreground": "220 10% 3.9%",
- active: "222 10% 98%",
- "active-foreground": "222 0 20%",
+ active: "222 10% 88%",
+ "active-foreground": "222 0 8%",
primary: "220 5.9% 10%",
"primary-foreground": "0 0% 98%",
secondary: "220 4.8% 95.9%",
@@ -79,8 +79,8 @@ export const themes = [
"popover-foreground": "0 0% 3.9%",
primary: "0 0% 9%",
"primary-foreground": "0 0% 98%",
- active: "0 0% 93%",
- "active-foreground": "0 0% 20%",
+ active: "0 0% 88%",
+ "active-foreground": "0 0% 12%",
secondary: "0 0% 96%",
"secondary-foreground": "0 0% 9%",
muted: "0 0% 85%",
@@ -139,8 +139,8 @@ export const themes = [
"popover-foreground": "0 0% 3.9%",
primary: "0 72.2% 50.6%",
"primary-foreground": "0 85.7% 97.3%",
- active: "0 0% 98%",
- "active-foreground": "0 0% 20%",
+ active: "0 55% 92%",
+ "active-foreground": "0 72% 50%",
secondary: "0 0% 96.1%",
"secondary-foreground": "0 0% 9%",
muted: "0 0% 96.1%",
@@ -200,8 +200,8 @@ export const themes = [
"popover-foreground": "20 14.3% 4.1%",
primary: "17 96% 57%",
"primary-foreground": "60 9.1% 97.8%",
- active: "20 5% 96%",
- "active-foreground": "20 5.3% 6%",
+ active: "11 55% 92%",
+ "active-foreground": "17 88% 51%",
secondary: "24 4.8% 95.9%",
"secondary-foreground": "24 9.8% 10%",
muted: "24 4.8% 95.9%",
@@ -260,8 +260,8 @@ export const themes = [
"popover-foreground": "20 14.3% 4.1%",
primary: "47.9 95.8% 53.1%",
"primary-foreground": "26 83.3% 14.1%",
- active: "47.9 0% 96%",
- "active-foreground": "0 0% 4.1%",
+ active: "47.9 95.8% 88%",
+ "active-foreground": "47.9 95.8% 4%",
secondary: "47.9 4.8% 95.9%",
"secondary-foreground": "24 9.8% 10%",
muted: "47.9 4.8% 95.9%",
@@ -321,8 +321,8 @@ export const themes = [
"popover-foreground": "171 10% 3.9%",
primary: "171 62% 41%",
"primary-foreground": "171 100% 97.3%",
- active: "171 0% 96%",
- "active-foreground": "0 0% 4.1%",
+ active: "171 62% 92%",
+ "active-foreground": "171 62% 22%",
secondary: "171 4.8% 95.9%",
"secondary-foreground": "171 5.9% 10%",
muted: "171 4.8% 95.9%",
@@ -346,7 +346,7 @@ export const themes = [
"card-foreground": "151 0% 95%",
primary: "171 98% 59%",
"primary-foreground": "144.9 80.4% 10%",
- active: "137 18% 15%",
+ active: "171 98% 15%",
"active-foreground": "171 98% 59%",
secondary: "151 3.7% 15.9%",
"secondary-foreground": "0 0% 98%",
@@ -381,8 +381,8 @@ export const themes = [
"popover-foreground": "237 98% 4.9%",
primary: "237 57% 30%",
"primary-foreground": "210 40% 98%",
- active: "237 10% 98%",
- "active-foreground": "237 0 20%",
+ active: "237 57% 88%",
+ "active-foreground": "237 57 30%",
secondary: "210 40% 96.1%",
"secondary-foreground": "237.2 47.4% 11.2%",
muted: "237 40% 96.1%",
@@ -441,8 +441,8 @@ export const themes = [
"popover-foreground": "224 71.4% 4.1%",
primary: "238 57% 50%",
"primary-foreground": "238 20% 98%",
- active: "238 57% 98%",
- "active-foreground": "238 57% 28%",
+ active: "238 57% 88%",
+ "active-foreground": "238 57% 44%",
secondary: "220 14.3% 95.9%",
"secondary-foreground": "220.9 39.3% 11%",
muted: "238 57% 95.9%",