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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
build: set css variables inline in html
Brad Barbin856d4aff7155
diff --git a/apps/carbon/app/root.tsx b/apps/carbon/app/root.tsxindex 98d857f7cd..ef6ab3721b 100644--- a/apps/carbon/app/root.tsx+++ b/apps/carbon/app/root.tsx@@ -2,6 +2,8 @@ import { error, getBrowserEnv } from "@carbon/auth";import { getSessionFlash } from "@carbon/auth/session.server";import { validator } from "@carbon/form";import { Button, Heading, toast, Toaster } from "@carbon/react";+import type { Theme } from "@carbon/utils";+import { themes } from "@carbon/utils";import {isRouteErrorResponse,Links,@@ -36,7 +38,6 @@ export const links: LinksFunction = () => {{ rel: "stylesheet", href: Tailwind },{ rel: "stylesheet", href: Background },{ rel: "stylesheet", href: NProgress },- { rel: "stylesheet", href: "/assets/theme.css" },];};@@ -97,17 +98,51 @@ export async function action({ request }: ActionFunctionArgs) {);}-function Document({+export function Document({children,title = "CarbonOS",mode = "dark",+ theme = "zinc",}: {children: React.ReactNode;title?: string;mode?: "light" | "dark";+ theme?: string;}) {+ const selectedTheme = themes.find((t) => t.name === theme) as+ | Theme+ | undefined;++ // Create style objects for both light and dark modes+ const lightVars: Record<string, string> = {};+ const darkVars: Record<string, string> = {};++ if (selectedTheme) {+ // Set light mode variables+ Object.entries(selectedTheme.cssVars.light).forEach(([key, value]) => {+ const cssKey = `--${key}`;+ lightVars[cssKey] = `${value}`;+ });++ // Set dark mode variables+ Object.entries(selectedTheme.cssVars.dark).forEach(([key, value]) => {+ const cssKey = `--${key}`;+ darkVars[cssKey] = `${value}`;+ });+ }++ // Combine the styles with proper selectors+ const themeStyle = {+ ...(mode === "dark" ? darkVars : lightVars),+ "--radius": "0.5rem",+ } as React.CSSProperties;+return (- <html lang="en" className={`${mode} h-full overflow-x-hidden`}>+ <html+ lang="en"+ className={`${mode} h-full overflow-x-hidden`}+ style={themeStyle}+ ><head><meta charSet="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />@@ -131,6 +166,8 @@ export default function App() {const loaderData = useLoaderData<typeof loader>();const env = loaderData?.env ?? {};const result = loaderData?.result;+ const theme = loaderData?.theme ?? "zinc";+ const mode = useMode();/* Toast Messages */useEffect(() => {@@ -141,12 +178,9 @@ export default function App() {}}, [result]);- const mode = useMode();-return (- <Document mode={mode}>+ <Document mode={mode} theme={theme}><Outlet />-<scriptdangerouslySetInnerHTML={{__html: `window.env = ${JSON.stringify(env)}`,diff --git a/apps/carbon/app/routes/assets+/theme[.]css.ts b/apps/carbon/app/routes/assets+/theme[.]css.tsdeleted file mode 100644index 05a4fd4e05..0000000000--- a/apps/carbon/app/routes/assets+/theme[.]css.ts+++ /dev/null@@ -1,27 +0,0 @@-import { getThemeCode, themes } from "@carbon/utils";-import type { LoaderFunctionArgs } from "@vercel/remix";-import { getTheme } from "~/services/theme.server";--export async function loader({ request }: LoaderFunctionArgs) {- const theme = getTheme(request) as string;-- const selectedTheme = themes.find((t) => t.name === theme);-- if (!selectedTheme) {- return new Response("", {- headers: {- "Content-Type": "text/css",- "Cache-Control": "no-store, max-age=0",- },- });- }-- const css = getThemeCode(selectedTheme);-- return new Response(css, {- headers: {- "Content-Type": "text/css",- "Cache-Control": "no-store, max-age=0",- },- });-}diff --git a/apps/carbon/app/styles/tailwind.css b/apps/carbon/app/styles/tailwind.cssindex 6cc5e3d18d..c39b594a74 100644--- a/apps/carbon/app/styles/tailwind.css+++ b/apps/carbon/app/styles/tailwind.css@@ -14,57 +14,6 @@background: transparent;}-@layer base {- :root {- --background: 0 0% 100%;- --foreground: 240 10% 3.9%;- --card: 0 0% 100%;- --card-foreground: 240 10% 3.9%;- --popover: 0 0% 100%;- --popover-foreground: 240 10% 3.9%;- --active: 240 5.9% 10%;- --active-foreground: 0 0% 98%;- --primary: 240 5.9% 10%;- --primary-foreground: 0 0% 98%;- --secondary: 240 4.8% 95.9%;- --secondary-foreground: 240 5.9% 10%;- --muted: 240 4.8% 95.9%;- --muted-foreground: 240 3.8% 46.1%;- --accent: 240 4.8% 89.9%;- --accent-foreground: 240 5.9% 10%;- --destructive: 0 72.22% 50.59%;- --destructive-foreground: 0 0% 98%;- --border: 240 5.9% 90%;- --input: 240 5.9% 90%;- --ring: 240 5% 64.9%;- --radius: 0.5rem;- }-- .dark {- --background: 240 10% 3.9%;- --foreground: 0 0% 98%;- --card: 240 10% 3.9%;- --card-foreground: 0 0% 98%;- --popover: 240 10% 3.9%;- --popover-foreground: 0 0% 98%;- --primary: 0 0% 98%;- --primary-foreground: 240 5.9% 10%;- --active: 0 0% 98%;- --active-foreground: 240 5.9% 10%;- --secondary: 240 3.7% 15.9%;- --secondary-foreground: 0 0% 98%;- --muted: 240 3.7% 15.9%;- --muted-foreground: 240 5% 64.9%;- --accent: 240 3.7% 15.9%;- --accent-foreground: 0 0% 98%;- --destructive: 0 62.8% 30.6%;- --destructive-foreground: 0 85.7% 97.3%;- --border: 240 3.7% 15.9%;- --input: 240 3.7% 15.9%;- --ring: 240 4.9% 83.9%;- }-}-@layer base {* {@apply border-border;diff --git a/apps/developers/app/root.tsx b/apps/developers/app/root.tsxindex a3874b287d..3e8ff4ffed 100644--- a/apps/developers/app/root.tsx+++ b/apps/developers/app/root.tsx@@ -1,14 +1,16 @@import { error, getBrowserEnv } from "@carbon/auth";import { getSessionFlash } from "@carbon/auth/session.server";import { validator } from "@carbon/form";-import { Button, Heading, toast } from "@carbon/react";+import { Button, Heading, toast, Toaster } from "@carbon/react";+import type { Theme } from "@carbon/utils";+import { themes } from "@carbon/utils";import {+ isRouteErrorResponse,Links,Meta,Outlet,Scripts,ScrollRestoration,- isRouteErrorResponse,useLoaderData,useRouteError,} from "@remix-run/react";@@ -26,6 +28,7 @@ import NProgress from "~/styles/nprogress.css?url";import Tailwind from "~/styles/tailwind.css?url";import { useMode } from "./hooks/useMode";+import { getTheme } from "./services/theme.server";import { modeValidator } from "./types/validators";export const config = { runtime: "edge", regions: ["iad1"] };@@ -35,7 +38,6 @@ export function links() {{ rel: "stylesheet", href: Tailwind },{ rel: "stylesheet", href: Background },{ rel: "stylesheet", href: NProgress },- { rel: "stylesheet", href: "/assets/theme.css" },];}@@ -66,6 +68,7 @@ export async function loader({ request }: LoaderFunctionArgs) {SUPABASE_ANON_PUBLIC,},mode: getMode(request),+ theme: getTheme(request),result: sessionFlash?.result,},{@@ -97,13 +100,47 @@ function Document({children,title = "CarbonOS",mode = "dark",+ theme = "zinc",}: {children: React.ReactNode;title?: string;mode?: "light" | "dark";+ theme?: string;}) {+ const selectedTheme = themes.find((t) => t.name === theme) as+ | Theme+ | undefined;++ // Create style objects for both light and dark modes+ const lightVars: Record<string, string> = {};+ const darkVars: Record<string, string> = {};++ if (selectedTheme) {+ // Set light mode variables+ Object.entries(selectedTheme.cssVars.light).forEach(([key, value]) => {+ const cssKey = `--${key}`;+ lightVars[cssKey] = `${value}`;+ });++ // Set dark mode variables+ Object.entries(selectedTheme.cssVars.dark).forEach(([key, value]) => {+ const cssKey = `--${key}`;+ darkVars[cssKey] = `${value}`;+ });+ }++ // Combine the styles with proper selectors+ const themeStyle = {+ ...(mode === "dark" ? darkVars : lightVars),+ "--radius": "0.5rem",+ } as React.CSSProperties;+return (- <html lang="en" className={`${mode} h-full overflow-x-hidden`}>+ <html+ lang="en"+ className={`${mode} h-full overflow-x-hidden`}+ style={themeStyle}+ ><head><meta charSet="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />@@ -113,7 +150,7 @@ function Document({</head><body className="h-full bg-background antialiased selection:bg-primary/10 selection:text-primary">{children}-+ <Toaster position="bottom-right" visibleToasts={5} /><ScrollRestoration /><Scripts /><Analytics />@@ -126,6 +163,7 @@ export default function App() {const loaderData = useLoaderData<typeof loader>();const env = loaderData?.env ?? {};const result = loaderData?.result;+ const theme = loaderData?.theme ?? "zinc";/* Toast Messages */useEffect(() => {@@ -140,7 +178,7 @@ export default function App() {const mode = useMode();return (- <Document mode={mode}>+ <Document mode={mode} theme={theme}><Outlet /><scriptdangerouslySetInnerHTML={{diff --git a/apps/developers/app/routes/assets+/theme[.]css.ts b/apps/developers/app/routes/assets+/theme[.]css.tsdeleted file mode 100644index 34c87a412c..0000000000--- a/apps/developers/app/routes/assets+/theme[.]css.ts+++ /dev/null@@ -1,29 +0,0 @@-import { getThemeCode, themes } from "@carbon/utils";-import type { LoaderFunctionArgs } from "@vercel/remix";-import { getTheme } from "~/services/theme.server";--export const config = { runtime: "nodejs" };--export async function loader({ request }: LoaderFunctionArgs) {- const theme = getTheme(request) as string;-- const selectedTheme = themes.find((t) => t.name === theme);-- if (!selectedTheme) {- return new Response("", {- headers: {- "Content-Type": "text/css",- "Cache-Control": "no-store, max-age=0",- },- });- }-- const css = getThemeCode(selectedTheme);-- return new Response(css, {- headers: {- "Content-Type": "text/css",- "Cache-Control": "no-store, max-age=0",- },- });-}diff --git a/apps/mes/app/root.tsx b/apps/mes/app/root.tsxindex 3c0dd2818f..83c05b77d0 100644--- a/apps/mes/app/root.tsx+++ b/apps/mes/app/root.tsx@@ -2,6 +2,8 @@ import { error, getBrowserEnv } from "@carbon/auth";import { getSessionFlash } from "@carbon/auth/session.server";import { validator } from "@carbon/form";import { Button, Heading, toast } from "@carbon/react";+import type { Theme } from "@carbon/utils";+import { themes } from "@carbon/utils";import {Links,Meta,@@ -26,6 +28,7 @@ import NProgress from "~/styles/nprogress.css?url";import Tailwind from "~/styles/tailwind.css?url";import { useMode } from "./hooks/useMode";+import { getTheme } from "./services/theme.server";import { modeValidator } from "./types/validators";export const config = { runtime: "edge", regions: ["iad1"] };@@ -35,7 +38,6 @@ export function links() {{ rel: "stylesheet", href: Tailwind },{ rel: "stylesheet", href: Background },{ rel: "stylesheet", href: NProgress },- { rel: "stylesheet", href: "/assets/theme.css" },];}@@ -66,6 +68,7 @@ export async function loader({ request }: LoaderFunctionArgs) {SUPABASE_ANON_PUBLIC,},mode: getMode(request),+ theme: getTheme(request),result: sessionFlash?.result,},{@@ -97,13 +100,47 @@ function Document({children,title = "CarbonOS",mode = "dark",+ theme = "zinc",}: {children: React.ReactNode;title?: string;mode?: "light" | "dark";+ theme?: string;}) {+ const selectedTheme = themes.find((t) => t.name === theme) as+ | Theme+ | undefined;++ // Create style objects for both light and dark modes+ const lightVars: Record<string, string> = {};+ const darkVars: Record<string, string> = {};++ if (selectedTheme) {+ // Set light mode variables+ Object.entries(selectedTheme.cssVars.light).forEach(([key, value]) => {+ const cssKey = `--${key}`;+ lightVars[cssKey] = `${value}`;+ });++ // Set dark mode variables+ Object.entries(selectedTheme.cssVars.dark).forEach(([key, value]) => {+ const cssKey = `--${key}`;+ darkVars[cssKey] = `${value}`;+ });+ }++ // Combine the styles with proper selectors+ const themeStyle = {+ ...(mode === "dark" ? darkVars : lightVars),+ "--radius": "0.5rem",+ } as React.CSSProperties;+return (- <html lang="en" className={`${mode} h-full overflow-x-hidden`}>+ <html+ lang="en"+ className={`${mode} h-full overflow-x-hidden`}+ style={themeStyle}+ ><head><meta charSet="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />@@ -130,6 +167,7 @@ export default function App() {const loaderData = useLoaderData<typeof loader>();const env = loaderData?.env ?? {};const result = loaderData?.result;+ const theme = loaderData?.theme ?? "zinc";/* Toast Messages */useEffect(() => {@@ -144,7 +182,7 @@ export default function App() {const mode = useMode();return (- <Document mode={mode}>+ <Document mode={mode} theme={theme}><Outlet /><scriptdangerouslySetInnerHTML={{diff --git a/apps/mes/app/routes/assets+/theme[.]css.ts b/apps/mes/app/routes/assets+/theme[.]css.tsdeleted file mode 100644index 34c87a412c..0000000000--- a/apps/mes/app/routes/assets+/theme[.]css.ts+++ /dev/null@@ -1,29 +0,0 @@-import { getThemeCode, themes } from "@carbon/utils";-import type { LoaderFunctionArgs } from "@vercel/remix";-import { getTheme } from "~/services/theme.server";--export const config = { runtime: "nodejs" };--export async function loader({ request }: LoaderFunctionArgs) {- const theme = getTheme(request) as string;-- const selectedTheme = themes.find((t) => t.name === theme);-- if (!selectedTheme) {- return new Response("", {- headers: {- "Content-Type": "text/css",- "Cache-Control": "no-store, max-age=0",- },- });- }-- const css = getThemeCode(selectedTheme);-- return new Response(css, {- headers: {- "Content-Type": "text/css",- "Cache-Control": "no-store, max-age=0",- },- });-}diff --git a/apps/mes/app/styles/tailwind.css b/apps/mes/app/styles/tailwind.cssindex 07717623c1..40a91757ae 100644--- a/apps/mes/app/styles/tailwind.css+++ b/apps/mes/app/styles/tailwind.css@@ -7,63 +7,8 @@@layer base {:root {- --background: 0 0% 100%;- --foreground: 240 10% 3.9%;- --card: 0 0% 100%;- --card-foreground: 240 10% 3.9%;- --popover: 0 0% 100%;- --popover-foreground: 240 10% 3.9%;- --active: 240 5.9% 10%;- --active-foreground: 0 0% 98%;- --primary: 240 5.9% 10%;- --primary-foreground: 0 0% 98%;- --secondary: 240 4.8% 95.9%;- --secondary-foreground: 240 5.9% 10%;- --muted: 240 4.8% 95.9%;- --muted-foreground: 240 3.8% 46.1%;- --accent: 240 4.8% 89.9%;- --accent-foreground: 240 5.9% 10%;- --destructive: 0 72.22% 50.59%;- --destructive-foreground: 0 0% 98%;- --border: 240 5.9% 90%;- --input: 240 5.9% 90%;- --ring: 240 5% 64.9%;- --radius: 0.5rem;- --gradient-opacity: 0.85;- --ray-gradient: radial-gradient(- hsl(var(--primary)) 0%,- hsl(var(--background)) 100%- );--header-height: 52px;}-- .dark {- --background: 240 10% 3.9%;- --foreground: 0 0% 98%;- --card: 240 10% 3.9%;- --card-foreground: 0 0% 98%;- --popover: 240 10% 3.9%;- --popover-foreground: 0 0% 98%;- --primary: 0 0% 98%;- --primary-foreground: 240 5.9% 10%;- --active: 0 0% 98%;- --active-foreground: 240 5.9% 10%;- --secondary: 240 3.7% 15.9%;- --secondary-foreground: 0 0% 98%;- --muted: 240 3.7% 15.9%;- --muted-foreground: 240 5% 64.9%;- --accent: 240 3.7% 15.9%;- --accent-foreground: 0 0% 98%;- --destructive: 0 62.8% 30.6%;- --destructive-foreground: 0 85.7% 97.3%;- --border: 240 3.7% 15.9%;- --input: 240 3.7% 15.9%;- --ring: 240 4.9% 83.9%;- --ray-gradient: radial-gradient(- hsl(var(--primary)) 0%,- hsl(var(--background)) 100%- );- }}@layer base {diff --git a/apps/www/app/routes/assets+/theme[.]css.ts b/apps/www/app/routes/assets+/theme[.]css.tsdeleted file mode 100644index 1d67fb9b0a..0000000000--- a/apps/www/app/routes/assets+/theme[.]css.ts+++ /dev/null@@ -1,26 +0,0 @@-import { getThemeCode, themes } from "@carbon/utils";-import type { LoaderFunctionArgs } from "@vercel/remix";--export const config = { runtime: "nodejs" };--export async function loader({ request }: LoaderFunctionArgs) {- const selectedTheme = themes.find((t) => t.name === "zinc");-- if (!selectedTheme) {- return new Response("", {- headers: {- "Content-Type": "text/css",- "Cache-Control": "public, max-age=31536000, immutable",- },- });- }-- const css = getThemeCode(selectedTheme);-- return new Response(css, {- headers: {- "Content-Type": "text/css",- "Cache-Control": "public, max-age=31536000, immutable",- },- });-}