From 5070588a71fc78f504c4f3a0aad2d58ee53a22ba Mon Sep 17 00:00:00 2001 From: Max Frederiksen <max.frederiksen@ess.eu> Date: Wed, 5 Mar 2025 11:25:41 +0100 Subject: [PATCH] CE-3691: Add lab instance color --- .../navigation/ButtonAppBar/ButtonAppBar.tsx | 15 +++++++++++++-- src/components/navigation/Environment.ts | 3 ++- src/style/Theme.ts | 8 ++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/navigation/ButtonAppBar/ButtonAppBar.tsx b/src/components/navigation/ButtonAppBar/ButtonAppBar.tsx index 8b2c706f..194b5cc6 100644 --- a/src/components/navigation/ButtonAppBar/ButtonAppBar.tsx +++ b/src/components/navigation/ButtonAppBar/ButtonAppBar.tsx @@ -34,6 +34,18 @@ const defaultStyle = ({ theme }: StyleProps) => ({ } }); +const getEnvColor = (theme: Theme, environment: Environment) => { + if (environment === "PROD") { + return theme.palette.environment.production.main; + } + + if (environment === "LAB") { + return theme.palette.environment.lab.main; + } + + return theme.palette.environment.development.main; +}; + export const ButtonAppBar = styled( ({ title, @@ -53,8 +65,7 @@ export const ButtonAppBar = styled( <Toolbar className="CeuiButtonAppBar-Toolbar" sx={{ - background: (theme) => - `${environment === "PROD" ? theme.palette.environment.production.main : theme.palette.environment.development.main}` + background: (theme) => getEnvColor(theme, environment) }} > <div className="CeuiButtonAppBar-HomeBox">{defaultHomeButton}</div> diff --git a/src/components/navigation/Environment.ts b/src/components/navigation/Environment.ts index a60cde18..319099a7 100644 --- a/src/components/navigation/Environment.ts +++ b/src/components/navigation/Environment.ts @@ -2,5 +2,6 @@ export enum Environment { LOCAL = "LOCAL", DEMO = "DEMO", TEST = "TEST", - PROD = "PROD" + PROD = "PROD", + LAB = "LAB" } diff --git a/src/style/Theme.ts b/src/style/Theme.ts index 2704f2f7..4209adb5 100644 --- a/src/style/Theme.ts +++ b/src/style/Theme.ts @@ -32,6 +32,7 @@ declare module "@mui/material/styles" { essNavy: Palette["primary"]; environment: { production: Palette["primary"]; + lab: Palette["primary"]; development: Palette["primary"]; }; } @@ -47,6 +48,7 @@ declare module "@mui/material/styles" { essNavy: Palette["primary"]; environment: { production: Palette["primary"]; + lab: Palette["primary"]; development: Palette["primary"]; }; } @@ -128,6 +130,12 @@ theme = createTheme(theme, { }, name: "production" }), + lab: theme.palette.augmentColor({ + color: { + main: theme.palette.essNavy.main + }, + name: "lab" + }), development: theme.palette.augmentColor({ color: { main: theme.palette.essOrange.main -- GitLab