Merge pull request #1556 from bluewave-labs/fix/colors-general

Fix/colors general
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-01-21 13:26:13 -08:00
commit c4d223aee5
108 files changed
+1479 -1129

No files matched your search

+135 -140
View File
@@ -1,3 +1,5 @@
import { lighten, darken } from "@mui/material/styles"; // CAIO_REVIEW
const typographyBase = 14;
/* TODO
@@ -65,92 +67,163 @@ const paletteColors = {
};
const semanticColors = {
unresolved: {
main: {
light: paletteColors.blue700,
dark: paletteColors.purple300,
},
light: {
light: paletteColors.blueGray20,
dark: paletteColors.purple400,
},
bg: {
light: paletteColors.gray100,
dark: paletteColors.gray100,
},
},
};
const newColors = {
offWhite: "#FEFEFE",
offBlack: "#131315",
gray100: "#F3F3F3",
gray200: "#EFEFEF",
gray500: "#A2A3A3",
blueGray50: "#E8F0FE",
blueGray500: "#475467",
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",
green700: "#026513",
orange100: "#FD8F22",
orange200: "#D69A5D",
orange600: "#9B734B",
orange700: "#884605",
red100: "#F27C7C",
red400: "#D92020",
red600: "#9B4B4B",
red700: "#980303",
};
/*
Structure:
main: background color
contrastText: color for main contrast text
contrastTextSecondary: if needed
contrastTextTertiary: if needed
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: {
light: newColors.blueBlueWave,
dark: newColors.blueBlueWave,
},
light: {
light: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW
dark: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW
},
darker: {
// CAIO_REVIEW
light: darken(newColors.blueBlueWave, 0.2), // CAIO_REVIEW
dark: darken(newColors.blueBlueWave, 0.2), // CAIO_REVIEW
},
contrastText: {
light: newColors.offWhite,
dark: newColors.offWhite,
},
},
primary: {
main: {
light: paletteColors.blueBlueWave,
dark: paletteColors.blueBlueWave,
light: newColors.offWhite,
dark: newColors.offBlack,
},
contrastText: {
light: newColors.blueGray800,
dark: newColors.blueGray50,
},
contrastTextSecondary: {
light: newColors.blueGray600,
dark: newColors.gray200,
},
contrastTextTertiary: {
light: newColors.blueGray500,
dark: newColors.gray500,
},
lowContrast: {
light: newColors.gray200,
dark: newColors.blueGray600,
},
// TODO we dont have primary light, dark or contrast text
},
secondary: {
main: {
light: paletteColors.gray100,
dark: paletteColors.gray800,
light: newColors.gray200,
dark: "#313131" /* newColors.blueGray600 */,
},
contrastText: {
light: paletteColors.blueGray200,
dark: paletteColors.blueGray200,
light: newColors.blueGray600,
dark: newColors.gray200,
},
light: {
light: paletteColors.gray200,
dark: paletteColors.gray200,
},
tertiary: {
main: {
light: newColors.gray100,
dark: newColors.blueGray800,
},
dark: {
light: paletteColors.gray200,
dark: paletteColors.gray200,
contrastText: {
light: newColors.blueGray800,
dark: newColors.gray100,
},
},
success: {
main: {
light: paletteColors.green400,
dark: paletteColors.green400,
light: newColors.green700,
dark: newColors.green100,
},
contrastText: {
light: paletteColors.green50,
dark: paletteColors.green50,
light: newColors.offWhite,
dark: newColors.offBlack,
},
light: {
light: paletteColors.green500,
dark: paletteColors.green800,
},
dark: {
light: paletteColors.green400,
dark: paletteColors.green900,
},
},
neutral: {
contrastText: {
light: paletteColors.blueGray900,
dark: paletteColors.gray100,
},
},
error: {
main: {
light: paletteColors.red300,
dark: paletteColors.red300,
},
contrastText: {
light: paletteColors.gray50,
dark: paletteColors.gray50,
},
light: {
light: paletteColors.red100,
dark: paletteColors.red700,
},
dark: {
light: paletteColors.red800,
dark: paletteColors.red800,
lowContrast: {
light: newColors.green400,
dark: newColors.green200,
},
},
warning: {
main: {
light: paletteColors.orange300,
dark: paletteColors.orange400,
light: newColors.orange700,
dark: newColors.orange200,
},
contrastText: {
light: paletteColors.orange600,
dark: paletteColors.orange500,
light: newColors.offWhite,
dark: newColors.offBlack,
},
light: {
light: paletteColors.orange100,
dark: paletteColors.orange800,
},
dark: {
light: paletteColors.orange50,
dark: paletteColors.gray800,
lowContrast: {
light: newColors.orange100,
dark: newColors.orange600,
},
},
/* From this part on, try to create semantic structure, not feature based structure */
error: {
main: {
light: newColors.red700,
dark: newColors.red100,
},
contrastText: {
light: newColors.offWhite,
dark: newColors.offBlack,
},
lowContrast: {
light: newColors.red400,
dark: newColors.red600,
},
},
/* These are temporary, just for everything not to break */
gradient: {
color1: {
light: paletteColors.gray90,
@@ -173,84 +246,6 @@ const semanticColors = {
dark: paletteColors.gray850,
},
},
background: {
main: {
light: paletteColors.white,
dark: paletteColors.gray890,
},
alt: {
light: paletteColors.gray90,
dark: paletteColors.gray890,
},
fill: {
light: paletteColors.gray100,
dark: paletteColors.gray800,
},
accent: {
light: paletteColors.gray100,
dark: paletteColors.gray850,
},
},
text: {
primary: {
light: paletteColors.blueGray900,
dark: paletteColors.gray100,
},
secondary: {
light: paletteColors.blueGray400,
dark: paletteColors.gray200,
},
tertiary: {
light: paletteColors.blueGray200,
dark: paletteColors.gray300,
},
accent: {
light: paletteColors.gray500,
dark: paletteColors.gray500,
},
},
border: {
light: {
light: paletteColors.gray200,
dark: paletteColors.gray800,
/* TODO this should live in a different key (border.disabled.light and .dark) */
disabled: paletteColors.gray150,
},
dark: {
light: paletteColors.gray200,
dark: paletteColors.gray750,
/* TODO this should live in a different key (border.disabled.light and .dark) */
disabled: paletteColors.gray150,
},
},
unresolved: {
main: {
light: paletteColors.blue700,
dark: paletteColors.purple300,
},
light: {
light: paletteColors.blueGray20,
dark: paletteColors.purple400,
},
bg: {
light: paletteColors.gray100,
dark: paletteColors.gray100,
},
},
other: {
icon: {
light: paletteColors.blueGray150,
},
line: {
light: paletteColors.gray200,
},
grid: {
light: paletteColors.gray300,
dark: paletteColors.gray600,
},
autofill: {
light: paletteColors.blueGray20,
},
},
};
export { typographyLevels, semanticColors as colors };
export { typographyLevels, semanticColors as colors, newSemanticColors };
+3 -105
View File
@@ -1,111 +1,9 @@
import { createTheme } from "@mui/material";
import { baseTheme } from "./globalTheme";
import { colors } from "./constants";
import { /* colors, */ newSemanticColors } from "./constants";
import { extractThemeColors } from "./extractColorObject";
const {
primary,
secondary,
success,
error,
warning,
neutral,
gradient: {
color1: { dark: color1 },
color2: { dark: color2 },
color3: { dark: color3 },
color4: { dark: color4 },
color5: { dark: color5 },
},
background,
text,
border,
unresolved,
other,
} = colors;
const palette = {
action: {
disabled: border.dark.disabled,
},
primary: { main: primary.main.dark },
secondary: {
main: secondary.main.dark,
contrastText: secondary.contrastText.dark,
light: secondary.dark.dark,
dark: secondary.dark.dark,
},
success: {
main: success.main.dark,
contrastText: success.contrastText.dark,
light: success.light.dark,
dark: success.dark.dark,
},
error: {
main: error.main.dark,
contrastText: error.contrastText.dark,
light: error.light.dark,
dark: error.dark.dark,
},
warning: {
main: warning.main.dark,
light: warning.light.dark,
contrastText: warning.contrastText.dark,
dark: warning.dark.dark,
},
neutral: {
contrastText: neutral.contrastText.dark,
},
/* From this part on, try to create semantic structure, not feature based structure */
percentage: {
uptimePoor: error.main.dark,
uptimeFair: warning.contrastText.dark,
uptimeGood: warning.main.dark /* Change for a success color? ?*/,
uptimeExcellent: success.main.dark,
},
unresolved: {
main: unresolved.main.dark,
light: unresolved.light.dark,
bg: unresolved.bg.dark,
},
divider: border.light.dark,
other: {
icon: text.secondary.dark,
line: border.light.dark,
fill: background.accent.dark,
grid: other.grid.dark,
autofill: secondary.main.dark,
},
gradient: {
color1,
color2,
color3,
color4,
color5,
},
text: {
primary: text.primary.dark,
secondary: text.secondary.dark,
tertiary: text.tertiary.dark,
accent: text.accent.dark,
},
background: {
main: background.main.dark,
alt: background.alt.dark,
fill: background.fill.dark,
accent: background.accent.dark,
},
border: {
light: border.light.dark,
dark: border.dark.dark,
},
info: {
text: text.primary.dark,
main: text.secondary.dark,
bg: background.main.dark,
light: background.main.dark,
border: border.light.dark,
},
};
const palette = extractThemeColors("dark", newSemanticColors);
const darkTheme = createTheme({
palette,
@@ -0,0 +1,25 @@
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) {
// CAIO_REVIEW: This will break if the root object has light and dark properties
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 };
+62 -28
View File
@@ -13,46 +13,55 @@ const baseTheme = (palette) => ({
fontSize: 14,
h1: {
fontSize: typographyLevels.xl,
color: palette.text.primary,
color: palette.primary.contrastText,
fontWeight: 500,
},
h2: {
fontSize: typographyLevels.l,
color: palette.text.secondary,
color: palette.primary.contrastTextSecondary,
fontWeight: 400,
},
body1: {
fontSize: typographyLevels.m,
color: palette.text.tertiary,
color: palette.primary.contrastTextTertiary,
fontWeight: 400,
},
body2: {
fontSize: typographyLevels.s,
color: palette.text.tertiary,
color: palette.primary.contrastTextTertiary,
fontWeight: 400,
},
},
/* TODO we can skip using the callback functions on the next lines since we are already accessing it on line 10. That was the last thing I managed to do, so we are sort of doing it twice*/
/* TODO change to 4 */
spacing: 2,
/* TODO we can skip using the callback functions on the next lines since we are already accessing it on line 10. That was the last thing I managed to do, so we are sort of doing it twice*/
/* TODO All these should live inside of a component*/
components: {
MuiButton: {
defaultProps: {
disableRipple: true,
},
styleOverrides: {
root: ({ theme }) => ({
variants: [
{
props: (props) => props.color === "accent",
style: {
"&:hover": {
backgroundColor: theme.palette.accent.darker,
},
},
},
{
props: (props) => props.variant === "group",
style: {
/* color: theme.palette.secondary.contrastText, */
color: theme.palette.neutral.contrastText,
backgroundColor: theme.palette.background.main,
color: theme.palette.primary.contrastText,
backgroundColor: theme.palette.primary.main,
border: 1,
borderStyle: "solid",
borderColor: theme.palette.border.light,
borderColor: theme.palette.primary.lowContrast,
},
},
{
@@ -61,13 +70,20 @@ const baseTheme = (palette) => ({
backgroundColor: theme.palette.secondary.main,
},
},
/* {
props: (props) => props.variant === "contained",
style: {
backgroundColor: `${theme.palette.accent.main} !important`,
},
}, */
{
props: (props) =>
props.variant === "contained" && props.color === "secondary",
style: {
border: 1,
borderStyle: "solid",
borderColor: theme.palette.border.light,
borderColor: theme.palette.primary.lowContrast,
},
},
{
@@ -97,7 +113,10 @@ const baseTheme = (palette) => ({
"&.MuiLoadingButton-root": {
"&:disabled": {
backgroundColor: theme.palette.secondary.main,
color: theme.palette.text.primary,
color: theme.palette.primary.contrastText,
},
"&.MuiButton-colorAccent:hover": {
boxShadow: `0 0 0 1px ${theme.palette.accent.main}`, // CAIO_REVIEW, this should really have a solid BG color
},
},
"&.MuiLoadingButton-loading": {
@@ -118,7 +137,7 @@ const baseTheme = (palette) => ({
padding: 4,
transition: "none",
"&:hover": {
backgroundColor: theme.palette.background.fill,
backgroundColor: theme.palette.primary.lowContrast,
},
}),
},
@@ -131,10 +150,10 @@ const baseTheme = (palette) => ({
padding: 0,
border: 1,
borderStyle: "solid",
borderColor: theme.palette.border.light,
borderColor: theme.palette.primary.lowContrast,
borderRadius: 4,
boxShadow: shadow,
backgroundColor: theme.palette.background.main,
backgroundColor: theme.palette.primary.main,
backgroundImage: "none",
};
},
@@ -160,13 +179,13 @@ const baseTheme = (palette) => ({
borderRadius: 4,
backgroundColor: "inherit",
padding: "4px 6px",
color: theme.palette.text.secondary,
color: theme.palette.primary.contrastTextSecondary,
fontSize: 13,
margin: 2,
minWidth: 100,
"&:hover, &.Mui-selected, &.Mui-selected:hover, &.Mui-selected.Mui-focusVisible":
{
backgroundColor: theme.palette.background.fill,
backgroundColor: theme.palette.primary.lowContrast,
},
}),
},
@@ -174,32 +193,32 @@ const baseTheme = (palette) => ({
MuiTableCell: {
styleOverrides: {
root: ({ theme }) => ({
borderBottomColor: theme.palette.border.light,
borderBottomColor: theme.palette.primary.lowContrast,
}),
},
},
MuiTableHead: {
styleOverrides: {
root: ({ theme }) => ({
backgroundColor: theme.palette.background.accent,
backgroundColor: theme.palette.tertiary.main,
}),
},
},
MuiPagination: {
styleOverrides: {
root: ({ theme }) => ({
backgroundColor: theme.palette.background.main,
backgroundColor: theme.palette.primary.main,
border: 1,
borderStyle: "solid",
borderColor: theme.palette.border.light,
borderColor: theme.palette.primary.lowContrast,
"& button": {
color: theme.palette.text.tertiary,
color: theme.palette.primary.contrastTextTertiary,
borderRadius: 4,
},
"& li:first-of-type button, & li:last-of-type button": {
border: 1,
borderStyle: "solid",
borderColor: theme.palette.border.light,
borderColor: theme.palette.primary.lowContrast,
},
}),
},
@@ -208,7 +227,7 @@ const baseTheme = (palette) => ({
styleOverrides: {
root: ({ theme }) => ({
"&:not(.MuiPaginationItem-ellipsis):hover, &.Mui-selected": {
backgroundColor: theme.palette.background.fill,
backgroundColor: theme.palette.primary.lowContrast,
},
}),
},
@@ -216,7 +235,7 @@ const baseTheme = (palette) => ({
MuiSkeleton: {
styleOverrides: {
root: ({ theme }) => ({
backgroundColor: theme.palette.unresolved.bg,
backgroundColor: theme.palette.primary.lowContrast,
}),
},
},
@@ -224,7 +243,7 @@ const baseTheme = (palette) => ({
styleOverrides: {
root: ({ theme }) => ({
"& fieldset": {
borderColor: theme.palette.border.dark,
borderColor: theme.palette.primary.lowContrast,
borderRadius: theme.shape.borderRadius,
},
"& .MuiInputBase-input": {
@@ -232,21 +251,26 @@ const baseTheme = (palette) => ({
minHeight: "var(--env-var-height-2)",
fontSize: "var(--env-var-font-size-medium)",
fontWeight: 400,
color: palette.text.secondary,
color: palette.primary.contrastTextSecondary,
"&.Mui-disabled": {
opacity: 0.3,
WebkitTextFillColor: "unset",
},
"& .Mui-focused": {
/* color: "#ff0000", */
/* borderColor: theme.palette.primary.contrastText, */
},
},
"& .MuiInputBase-input:-webkit-autofill": {
transition: "background-color 5000s ease-in-out 0s",
WebkitBoxShadow: `0 0 0px 1000px ${theme.palette.background.main} inset`,
WebkitTextFillColor: theme.palette.text.primary,
WebkitBoxShadow: `0 0 0px 1000px ${theme.palette.primary.main} inset`,
WebkitTextFillColor: theme.palette.primary.contrastText,
},
"& .MuiInputBase-input.MuiOutlinedInput-input": {
padding: "0 var(--env-var-spacing-1-minus) !important",
},
"& .MuiOutlinedInput-root": {
color: theme.palette.primary.contrastTextSecondary,
borderRadius: 4,
},
"& .MuiOutlinedInput-notchedOutline": {
@@ -268,6 +292,16 @@ const baseTheme = (palette) => ({
}),
},
},
MuiOutlinedInput: {
styleOverrides: {
root: {
color: palette.primary.contrastTextTertiary,
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
borderColor: palette.primary.contrastTextTertiary,
},
},
},
},
},
shape: {
borderRadius: 2,
+3 -113
View File
@@ -1,119 +1,9 @@
import { createTheme } from "@mui/material";
import { baseTheme } from "./globalTheme";
import { colors } from "./constants";
import { /* colors, */ newSemanticColors } from "./constants";
import { extractThemeColors } from "./extractColorObject";
/*
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,
},
};
/* TODO I figured out we could have just one theme by passing mode as parameter for theme function. Implement later */
const palette = extractThemeColors("light", newSemanticColors);
const lightTheme = createTheme({
palette,
...baseTheme(palette),
+3 -2
View File
@@ -163,6 +163,7 @@ const Greeting = ({ type = "" }) => {
<Typography
component="span"
fontSize="inherit"
color={theme.palette.primary.contrastTextTertiary}
>
{prepend},{" "}
</Typography>
@@ -170,7 +171,7 @@ const Greeting = ({ type = "" }) => {
component="span"
fontSize="inherit"
fontWeight="inherit"
color={theme.palette.text.secondary}
color={theme.palette.primary.contrastTextSecondary}
>
{firstName} {emoji}
</Typography>
@@ -178,7 +179,7 @@ const Greeting = ({ type = "" }) => {
<Typography
variant="h2"
lineHeight={1}
color={theme.palette.text.accent}
color={theme.palette.primary.contrastTextTertiary}
>
{append} — Here’s an overview of your {type} monitors.
</Typography>
+1 -1
View File
@@ -12,7 +12,7 @@ import Alert from "../Components/Alert";
*/
export const createToast = ({
variant = "info",
variant = "secondary",
title,
body,
hasIcon = false,