diff --git a/Client/src/Utils/Theme/constants.js b/Client/src/Utils/Theme/constants.js index 1992e0e75..52222e4de 100644 --- a/Client/src/Utils/Theme/constants.js +++ b/Client/src/Utils/Theme/constants.js @@ -267,6 +267,7 @@ const newColors = { blueGray600: "#344054", blueGray800: "#1C2130", blueBlueWave: "#1570EF", + /* I changed green 100 and green 700. Need to change red and warning as well, and refactor the object following the structure */ green100: "#67cd78", green200: "#4B9B77", green400: "#079455", @@ -281,6 +282,15 @@ const newColors = { red700: "#791515", }; +/* Structure: +Key: +main: background color +contrastText: color for main contrast text +light and dark: should be transparent (since we don't want MUI to make the light dark automatic calculations for us) +lowerContrastText: if there are any, use nested keys secondary and tertiary +lowContrast: if we need some low contrast for that color (for borders, and decorative elements). This should never be usend in text + +*/ const newSemanticColors = { accent: { main: { diff --git a/Client/src/Utils/Theme/darkTheme.js b/Client/src/Utils/Theme/darkTheme.js index c0a5eb95f..8813adb54 100644 --- a/Client/src/Utils/Theme/darkTheme.js +++ b/Client/src/Utils/Theme/darkTheme.js @@ -1,30 +1,8 @@ import { createTheme } from "@mui/material"; import { baseTheme } from "./globalTheme"; import { /* colors, */ newSemanticColors } from "./constants"; +import { extractThemeColors } from "./extractColorObject"; -function extractThemeColors(themeType, colorObject) { - if (!["light", "dark"].includes(themeType)) { - throw new Error('Invalid theme type. Use "light" or "dark".'); - } - - const extract = (obj) => { - if (typeof obj !== "object" || obj === null) { - return obj; - } - - if ("light" in obj && "dark" in obj) { - return obj[themeType]; // Return the value for the specified theme - } - - // Reduce the object, keeping only the extracted themeType values - return Object.keys(obj).reduce((acc, key) => { - acc[key] = extract(obj[key]); - return acc; - }, {}); - }; - - return extract(colorObject); -} const palette = extractThemeColors("dark", newSemanticColors); const darkTheme = createTheme({ diff --git a/Client/src/Utils/Theme/extractColorObject.js b/Client/src/Utils/Theme/extractColorObject.js new file mode 100644 index 000000000..09b6d66dc --- /dev/null +++ b/Client/src/Utils/Theme/extractColorObject.js @@ -0,0 +1,24 @@ +function extractThemeColors(themeType, colorObject) { + if (!["light", "dark"].includes(themeType)) { + throw new Error('Invalid theme type. Use "light" or "dark".'); + } + + const extract = (obj) => { + if (typeof obj !== "object" || obj === null) { + return obj; + } + + if ("light" in obj && "dark" in obj) { + return obj[themeType]; // Return the value for the specified theme + } + + // Reduce the object, keeping only the extracted themeType values + return Object.keys(obj).reduce((acc, key) => { + acc[key] = extract(obj[key]); + return acc; + }, {}); + }; + return extract(colorObject); +} + +export { extractThemeColors }; diff --git a/Client/src/Utils/Theme/lightTheme.js b/Client/src/Utils/Theme/lightTheme.js index ab9c1dc78..d4cfa4ffd 100644 --- a/Client/src/Utils/Theme/lightTheme.js +++ b/Client/src/Utils/Theme/lightTheme.js @@ -1,31 +1,10 @@ import { createTheme } from "@mui/material"; import { baseTheme } from "./globalTheme"; import { /* colors, */ newSemanticColors } from "./constants"; +import { extractThemeColors } from "./extractColorObject"; -function extractThemeColors(themeType, colorObject) { - if (!["light", "dark"].includes(themeType)) { - throw new Error('Invalid theme type. Use "light" or "dark".'); - } - - const extract = (obj) => { - if (typeof obj !== "object" || obj === null) { - return obj; - } - - if ("light" in obj && "dark" in obj) { - return obj[themeType]; // Return the value for the specified theme - } - - // Reduce the object, keeping only the extracted themeType values - return Object.keys(obj).reduce((acc, key) => { - acc[key] = extract(obj[key]); - return acc; - }, {}); - }; - - return extract(colorObject); -} const palette = extractThemeColors("light", newSemanticColors); + /* TODO I figured out we could have just one theme by passing mode as parameter for theme function. Implement later */ const lightTheme = createTheme({ palette,