feat: updating texts
This commit is contained in:
1 parent
36bbf5aba0
commit
db86753701
54 files changed
+530
-341
No files matched your search
@@ -1,118 +1,31 @@
|
||||
import { createTheme } from "@mui/material";
|
||||
import { baseTheme } from "./globalTheme";
|
||||
import { colors } from "./constants";
|
||||
import { colors, newSemanticColors } from "./constants";
|
||||
|
||||
/*
|
||||
TODO
|
||||
Next step: check if all keys here are being used in the codebase. e.g.: Search codebase for palette.primary; also check for destructuring palette ('= theme.palette')
|
||||
*/
|
||||
function extractThemeColors(themeType, colorObject) {
|
||||
if (!["light", "dark"].includes(themeType)) {
|
||||
throw new Error('Invalid theme type. Use "light" or "dark".');
|
||||
}
|
||||
|
||||
const {
|
||||
primary,
|
||||
secondary,
|
||||
success,
|
||||
error,
|
||||
warning,
|
||||
neutral,
|
||||
gradient: {
|
||||
color1: { light: color1 },
|
||||
color2: { light: color2 },
|
||||
color3: { light: color3 },
|
||||
color4: { light: color4 },
|
||||
color5: { light: color5 },
|
||||
},
|
||||
background,
|
||||
text,
|
||||
border,
|
||||
unresolved,
|
||||
other,
|
||||
} = colors;
|
||||
const extract = (obj) => {
|
||||
if (typeof obj !== "object" || obj === null) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
const palette = {
|
||||
/* TODO check if we need the addition of a new color gray150 for this. Also, this color would probably fit for primary contrastText */
|
||||
action: {
|
||||
disabled: border.light.disabled,
|
||||
},
|
||||
primary: { main: primary.main.light },
|
||||
secondary: {
|
||||
main: secondary.main.light,
|
||||
contrastText: secondary.contrastText.light,
|
||||
light: secondary.dark.light,
|
||||
dark: secondary.dark.light,
|
||||
},
|
||||
success: {
|
||||
main: success.main.light,
|
||||
contrastText: success.contrastText.light,
|
||||
light: success.light.light,
|
||||
dark: success.dark.light,
|
||||
},
|
||||
error: {
|
||||
main: error.main.light,
|
||||
contrastText: error.contrastText.light,
|
||||
light: error.light.light,
|
||||
dark: error.dark.light,
|
||||
},
|
||||
warning: {
|
||||
main: warning.main.light,
|
||||
light: warning.light.light,
|
||||
contrastText: warning.contrastText.light,
|
||||
dark: warning.dark.light,
|
||||
},
|
||||
neutral: {
|
||||
contrastText: neutral.contrastText.light,
|
||||
},
|
||||
/* From this part on, try to create semantic structure, not feature based structure */
|
||||
percentage: {
|
||||
uptimePoor: error.main.light,
|
||||
uptimeFair: warning.contrastText.light,
|
||||
uptimeGood: warning.main.light /* Change for a success color? */,
|
||||
uptimeExcellent: success.main.light,
|
||||
},
|
||||
unresolved: {
|
||||
main: unresolved.main.light,
|
||||
light: unresolved.light.light,
|
||||
bg: unresolved.bg.light,
|
||||
},
|
||||
divider: border.light.light,
|
||||
other: {
|
||||
icon: other.icon.light,
|
||||
line: other.line.light,
|
||||
fill: secondary.dark.light,
|
||||
grid: other.grid.light,
|
||||
autofill: other.autofill.light,
|
||||
},
|
||||
gradient: {
|
||||
color1,
|
||||
color2,
|
||||
color3,
|
||||
color4,
|
||||
color5,
|
||||
},
|
||||
text: {
|
||||
primary: text.primary.light,
|
||||
secondary: text.secondary.light,
|
||||
tertiary: text.tertiary.light,
|
||||
accent: text.accent.light,
|
||||
},
|
||||
background: {
|
||||
main: background.main.light,
|
||||
alt: background.alt.light,
|
||||
fill: background.fill.light,
|
||||
accent: background.accent.light,
|
||||
},
|
||||
border: {
|
||||
light: border.light.light,
|
||||
dark: border.dark.light,
|
||||
},
|
||||
info: {
|
||||
text: text.primary.light,
|
||||
main: text.tertiary.light,
|
||||
bg: background.main.light,
|
||||
light: background.main.light,
|
||||
border: border.dark.light,
|
||||
},
|
||||
};
|
||||
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,
|
||||
@@ -120,3 +33,114 @@ const lightTheme = createTheme({
|
||||
});
|
||||
|
||||
export default lightTheme;
|
||||
|
||||
/*
|
||||
TODO
|
||||
Next step: check if all keys here are being used in the codebase. e.g.: Search codebase for palette.primary; also check for destructuring palette ('= theme.palette')
|
||||
*/
|
||||
|
||||
// const {
|
||||
// primary,
|
||||
// secondary,
|
||||
// success,
|
||||
// error,
|
||||
// warning,
|
||||
// neutral,
|
||||
// gradient: {
|
||||
// color1: { light: color1 },
|
||||
// color2: { light: color2 },
|
||||
// color3: { light: color3 },
|
||||
// color4: { light: color4 },
|
||||
// color5: { light: color5 },
|
||||
// },
|
||||
// background,
|
||||
// text,
|
||||
// border,
|
||||
// unresolved,
|
||||
// other,
|
||||
// } = colors;
|
||||
|
||||
// const palette = {
|
||||
// /* TODO check if we need the addition of a new color gray150 for this. Also, this color would probably fit for primary contrastText */
|
||||
// action: {
|
||||
// disabled: border.light.disabled,
|
||||
// },
|
||||
// primary: { main: primary.main.light },
|
||||
// secondary: {
|
||||
// main: secondary.main.light,
|
||||
// contrastText: secondary.contrastText.light,
|
||||
// light: secondary.dark.light,
|
||||
// dark: secondary.dark.light,
|
||||
// },
|
||||
// success: {
|
||||
// main: success.main.light,
|
||||
// contrastText: success.contrastText.light,
|
||||
// light: success.light.light,
|
||||
// dark: success.dark.light,
|
||||
// },
|
||||
// error: {
|
||||
// main: error.main.light,
|
||||
// contrastText: error.contrastText.light,
|
||||
// light: error.light.light,
|
||||
// dark: error.dark.light,
|
||||
// },
|
||||
// warning: {
|
||||
// main: warning.main.light,
|
||||
// light: warning.light.light,
|
||||
// contrastText: warning.contrastText.light,
|
||||
// dark: warning.dark.light,
|
||||
// },
|
||||
// neutral: {
|
||||
// contrastText: neutral.contrastText.light,
|
||||
// },
|
||||
// /* From this part on, try to create semantic structure, not feature based structure */
|
||||
// percentage: {
|
||||
// uptimePoor: error.main.light,
|
||||
// uptimeFair: warning.contrastText.light,
|
||||
// uptimeGood: warning.main.light /* Change for a success color? */,
|
||||
// uptimeExcellent: success.main.light,
|
||||
// },
|
||||
// unresolved: {
|
||||
// main: unresolved.main.light,
|
||||
// light: unresolved.light.light,
|
||||
// bg: unresolved.bg.light,
|
||||
// },
|
||||
// divider: border.light.light,
|
||||
// other: {
|
||||
// icon: other.icon.light,
|
||||
// line: other.line.light,
|
||||
// fill: secondary.dark.light,
|
||||
// grid: other.grid.light,
|
||||
// autofill: other.autofill.light,
|
||||
// },
|
||||
// gradient: {
|
||||
// color1,
|
||||
// color2,
|
||||
// color3,
|
||||
// color4,
|
||||
// color5,
|
||||
// },
|
||||
// text: {
|
||||
// primary: text.primary.light,
|
||||
// secondary: text.secondary.light,
|
||||
// tertiary: text.tertiary.light,
|
||||
// accent: text.accent.light,
|
||||
// },
|
||||
// background: {
|
||||
// main: background.main.light,
|
||||
// alt: background.alt.light,
|
||||
// fill: background.fill.light,
|
||||
// accent: background.accent.light,
|
||||
// },
|
||||
// border: {
|
||||
// light: border.light.light,
|
||||
// dark: border.dark.light,
|
||||
// },
|
||||
// info: {
|
||||
// text: text.primary.light,
|
||||
// main: text.tertiary.light,
|
||||
// bg: background.main.light,
|
||||
// light: background.main.light,
|
||||
// border: border.dark.light,
|
||||
// },
|
||||
// };
|
||||
Reference in new issue
Block a user