Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Inline

Manav Rathi81d031d03e0a
diff --git a/web/apps/accounts/src/pages/_app.tsx b/web/apps/accounts/src/pages/_app.tsx
index 3b425cb965..f5a46cab17 100644
--- a/web/apps/accounts/src/pages/_app.tsx
+++ b/web/apps/accounts/src/pages/_app.tsx
@@ -8,8 +8,7 @@ import { useAttributedMiniDialog } from "@/base/components/utils/dialog";
import { setupI18n } from "@/base/i18n";
import { disableDiskLogs } from "@/base/log";
import { logUnhandledErrorsAndRejections } from "@/base/log-web";
-import { getTheme } from "@ente/shared/themes";
-import { THEME_COLOR } from "@ente/shared/themes/constants";
+import { getTheme, THEME_COLOR } from "@ente/shared/themes";
import { CssBaseline } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
import { t } from "i18next";
diff --git a/web/apps/auth/src/pages/_app.tsx b/web/apps/auth/src/pages/_app.tsx
index 6083f0dcbb..0b916f5ead 100644
--- a/web/apps/auth/src/pages/_app.tsx
+++ b/web/apps/auth/src/pages/_app.tsx
@@ -18,8 +18,7 @@ import {
getData,
migrateKVToken,
} from "@ente/shared/storage/localStorage";
-import { getTheme } from "@ente/shared/themes";
-import { THEME_COLOR } from "@ente/shared/themes/constants";
+import { THEME_COLOR, getTheme } from "@ente/shared/themes";
import type { User } from "@ente/shared/user/types";
import { CssBaseline } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
diff --git a/web/apps/auth/src/types/context.ts b/web/apps/auth/src/types/context.ts
index c5f95ba5c7..cf5ebfb1ca 100644
--- a/web/apps/auth/src/types/context.ts
+++ b/web/apps/auth/src/types/context.ts
@@ -1,5 +1,5 @@
import type { AccountsContextT } from "@/accounts/types/context";
-import { THEME_COLOR } from "@ente/shared/themes/constants";
+import { THEME_COLOR } from "@ente/shared/themes";
import { createContext, useContext } from "react";
/**
diff --git a/web/apps/cast/src/pages/_app.tsx b/web/apps/cast/src/pages/_app.tsx
index 4324431b61..da26ac1189 100644
--- a/web/apps/cast/src/pages/_app.tsx
+++ b/web/apps/cast/src/pages/_app.tsx
@@ -2,8 +2,7 @@ import { staticAppTitle } from "@/base/app";
import { CustomHead } from "@/base/components/Head";
import { disableDiskLogs } from "@/base/log";
import { logUnhandledErrorsAndRejections } from "@/base/log-web";
-import { getTheme } from "@ente/shared/themes";
-import { THEME_COLOR } from "@ente/shared/themes/constants";
+import { getTheme, THEME_COLOR } from "@ente/shared/themes";
import { CssBaseline, ThemeProvider } from "@mui/material";
import type { AppProps } from "next/app";
import React, { useEffect } from "react";
diff --git a/web/apps/photos/src/components/Sidebar/index.tsx b/web/apps/photos/src/components/Sidebar/index.tsx
index 4968f7c952..b76b11a477 100644
--- a/web/apps/photos/src/components/Sidebar/index.tsx
+++ b/web/apps/photos/src/components/Sidebar/index.tsx
@@ -47,7 +47,7 @@ import {
} from "@ente/shared/components/Container";
import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";
import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
-import { THEME_COLOR } from "@ente/shared/themes/constants";
+import { THEME_COLOR } from "@ente/shared/themes";
import ArchiveOutlinedIcon from "@mui/icons-material/ArchiveOutlined";
import CategoryIcon from "@mui/icons-material/Category";
import CloseIcon from "@mui/icons-material/Close";
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index d7d634e963..62f0fa44db 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -33,8 +33,7 @@ import {
getData,
migrateKVToken,
} from "@ente/shared/storage/localStorage";
-import { getTheme } from "@ente/shared/themes";
-import { THEME_COLOR } from "@ente/shared/themes/constants";
+import { THEME_COLOR, getTheme } from "@ente/shared/themes";
import type { User } from "@ente/shared/user/types";
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
import { CssBaseline, styled } from "@mui/material";
diff --git a/web/packages/new/photos/types/context.ts b/web/packages/new/photos/types/context.ts
index 65dd7ad76e..77f83ccff0 100644
--- a/web/packages/new/photos/types/context.ts
+++ b/web/packages/new/photos/types/context.ts
@@ -1,5 +1,5 @@
import type { AccountsContextT } from "@/accounts/types/context";
-import { THEME_COLOR } from "@ente/shared/themes/constants";
+import { THEME_COLOR } from "@ente/shared/themes";
import { createContext, useContext } from "react";
import type { SetNotificationAttributes } from "./notification";
diff --git a/web/packages/shared/themes/colors.ts b/web/packages/shared/themes/colors.ts
deleted file mode 100644
index 0825dc71aa..0000000000
--- a/web/packages/shared/themes/colors.ts
+++ /dev/null
@@ -1,187 +0,0 @@
-import type { FixedColors, ThemeColorsOptions } from "@mui/material";
-import { THEME_COLOR } from "./constants";
-
-export type ColorAccentType = "auth" | "photos";
-
-export const getColors = (
- themeColor: THEME_COLOR,
- accentType: ColorAccentType,
-): ThemeColorsOptions => {
- switch (themeColor) {
- case THEME_COLOR.LIGHT:
- return { ...fixedColors(accentType), ...lightThemeColors };
- default:
- return { ...fixedColors(accentType), ...darkThemeColors };
- }
-};
-
-const fixedColors = (
- accentType: "auth" | "photos",
-): Pick<ThemeColorsOptions, keyof FixedColors> => {
- switch (accentType) {
- case "auth":
- return {
- ...commonFixedColors,
- accent: authAccentColor,
- };
- default:
- return {
- ...commonFixedColors,
- accent: photosAccentColor,
- };
- }
-};
-
-const commonFixedColors: Partial<Pick<ThemeColorsOptions, keyof FixedColors>> =
- {
- accent: {
- A700: "#00B33C",
- A500: "#1DB954",
- A400: "#26CB5F",
- A300: "#01DE4D",
- },
- warning: {
- A500: "#FFC247",
- },
- danger: {
- A800: "#F53434",
- A700: "#EA3F3F",
- A500: "#FF6565",
- A400: "#FF6F6F",
- },
- white: { base: "#fff", muted: "rgba(255, 255, 255, 0.48)" },
- black: { base: "#000", muted: "rgba(0, 0, 0, 0.65)" },
- };
-
-const authAccentColor = {
- A700: "rgb(164, 0, 182)",
- A500: "rgb(150, 13, 214)",
- A400: "rgb(122, 41, 193)",
- A300: "rgb(152, 77, 244)",
-};
-
-const photosAccentColor = {
- A700: "#00B33C",
- A500: "#1DB954",
- A400: "#26CB5F",
- A300: "#01DE4D",
-};
-
-const lightThemeColors: Omit<ThemeColorsOptions, keyof FixedColors> = {
- background: {
- base: "#fff",
- elevated: "#fff",
- elevated2: "rgba(153, 153, 153, 0.04)",
- },
- backdrop: {
- base: "rgba(255, 255, 255, 0.92)",
- muted: "rgba(255, 255, 255, 0.75)",
- faint: "rgba(255, 255, 255, 0.30)",
- },
- text: {
- base: "#000",
- muted: "rgba(0, 0, 0, 0.60)",
- faint: "rgba(0, 0, 0, 0.50)",
- },
- fill: {
- base: "#000",
- muted: "rgba(0, 0, 0, 0.12)",
- faint: "rgba(0, 0, 0, 0.04)",
- basePressed: "rgba(0, 0, 0, 0.87))",
- faintPressed: "rgba(0, 0, 0, 0.08)",
- },
- stroke: {
- base: "#000",
- muted: "rgba(0, 0, 0, 0.24)",
- faint: "rgba(0, 0, 0, 0.12)",
- },
-
- shadows: {
- float: [{ x: 0, y: 0, blur: 10, color: "rgba(0, 0, 0, 0.25)" }],
- menu: [
- {
- x: 0,
- y: 0,
- blur: 6,
- color: "rgba(0, 0, 0, 0.16)",
- },
- {
- x: 0,
- y: 3,
- blur: 6,
- color: "rgba(0, 0, 0, 0.12)",
- },
- ],
- button: [
- {
- x: 0,
- y: 4,
- blur: 4,
- color: "rgba(0, 0, 0, 0.25)",
- },
- ],
- },
-};
-
-const darkThemeColors: Omit<ThemeColorsOptions, keyof FixedColors> = {
- background: {
- base: "#000000",
- elevated: "#1b1b1b",
- elevated2: "#252525",
- },
- backdrop: {
- base: "rgba(0, 0, 0, 0.90)",
- muted: "rgba(0, 0, 0, 0.65)",
- faint: "rgba(0, 0, 0,0.20)",
- },
- text: {
- base: "#fff",
- muted: "rgba(255, 255, 255, 0.70)",
- faint: "rgba(255, 255, 255, 0.50)",
- },
- fill: {
- base: "#fff",
- muted: "rgba(255, 255, 255, 0.16)",
- faint: "rgba(255, 255, 255, 0.12)",
- basePressed: "rgba(255, 255, 255, 0.90)",
- faintPressed: "rgba(255, 255, 255, 0.06)",
- },
- stroke: {
- base: "#ffffff",
- muted: "rgba(255,255,255,0.24)",
- faint: "rgba(255,255,255,0.16)",
- },
-
- shadows: {
- float: [
- {
- x: 0,
- y: 2,
- blur: 12,
- color: "rgba(0, 0, 0, 0.75)",
- },
- ],
- menu: [
- {
- x: 0,
- y: 0,
- blur: 6,
- color: "rgba(0, 0, 0, 0.50)",
- },
- {
- x: 0,
- y: 3,
- blur: 6,
- color: "rgba(0, 0, 0, 0.25)",
- },
- ],
- button: [
- {
- x: 0,
- y: 4,
- blur: 4,
- color: "rgba(0, 0, 0, 0.75)",
- },
- ],
- },
-};
diff --git a/web/packages/shared/themes/components.ts b/web/packages/shared/themes/components.ts
deleted file mode 100644
index d5c141def2..0000000000
--- a/web/packages/shared/themes/components.ts
+++ /dev/null
@@ -1,277 +0,0 @@
-import type { Shadow, ThemeColorsOptions } from "@mui/material";
-import type { Components } from "@mui/material/styles/components";
-import type { TypographyOptions } from "@mui/material/styles/createTypography";
-
-export const getComponents = (
- colors: ThemeColorsOptions,
- typography: TypographyOptions,
-): Components => ({
- MuiCssBaseline: {
- styleOverrides: {
- body: {
- fontFamily: typography.fontFamily,
- // MUI has different letter spacing for each variant, but those
- // are values arrived at for the default Material font, and
- // don't work for the font that we're using, so reset it to a
- // reasonable value that works for our font.
- letterSpacing: "-0.011em",
- },
- strong: { fontWeight: 700 },
- },
- },
-
- MuiTypography: {
- defaultProps: {
- // MUI has body1 as the default variant for Typography, but our
- // variant scheme is different, instead of body1/2, we have
- // large/body/small etc. So reset the default to our equivalent of
- // body1, which is "body".
- variant: "body",
- // Map all our custom variants to <p>.
- variantMapping: {
- large: "p",
- body: "p",
- small: "p",
- mini: "p",
- tiny: "p",
- },
- },
- },
-
- MuiDrawer: {
- styleOverrides: {
- root: {
- ".MuiBackdrop-root": {
- backgroundColor: colors.backdrop?.faint,
- },
- },
- },
- },
- MuiDialog: {
- defaultProps: {
- // This is required to prevent console errors about aria-hiding a
- // focused button when the dialog is closed.
- //
- // https://github.com/mui/material-ui/issues/43106#issuecomment-2314809028
- closeAfterTransition: false,
- },
- styleOverrides: {
- root: {
- ".MuiBackdrop-root": {
- backgroundColor: colors.backdrop?.faint,
- },
- "& .MuiDialog-paper": {
- filter: getDropShadowStyle(colors.shadows?.float),
- },
- // Reset the MUI default paddings to 16px everywhere.
- //
- // This is not a great choice either, usually most dialogs, for
- // one reason or the other, will need to customize this padding
- // anyway. But not resetting it to 16px leaves it at the MUI
- // defaults, which just doesn't work well with our designs.
- "& .MuiDialogTitle-root": {
- // MUI default is '16px 24px'.
- padding: "16px",
- },
- "& .MuiDialogContent-root": {
- // MUI default is '20px 24px'.
- padding: "16px",
- // If the contents of the dialog's contents exceed the
- // available height, show a scrollbar just for the contents
- // instead of the entire dialog.
- overflowY: "auto",
- },
- "& .MuiDialogActions-root": {
- // MUI default is way off for us since they cluster the
- // buttons to the right, while our designs usually want the
- // buttons to align with the heading / content.
- padding: "16px",
- },
- ".MuiDialogTitle-root + .MuiDialogContent-root": {
- // MUI resets this to 0 when the content doesn't use
- // dividers (none of ours do). I feel that is a better
- // default, since unlike margins, padding doesn't collapse,
- // but changing this now would break existing layouts.
- paddingTop: "16px",
- },
- },
- },
- },
- MuiPaper: {
- styleOverrides: { root: { backgroundImage: "none" } },
- },
- MuiLink: {
- defaultProps: {
- color: colors.accent?.A500,
- underline: "none",
- },
- styleOverrides: {
- root: {
- "&:hover": {
- underline: "always",
- color: colors.accent?.A500,
- },
- },
- },
- },
-
- MuiButton: {
- defaultProps: {
- // Change the default button variant from "text" to "contained".
- variant: "contained",
- },
- styleOverrides: {
- // We don't use the size prop for the MUI button, or rather it
- // cannot be used, since we have fixed the paddings and font sizes
- // unconditionally here (which are all that the size prop changes).
- root: {
- padding: "12px 16px",
- borderRadius: "4px",
- textTransform: "none",
- fontWeight: "bold",
- fontSize: typography.body?.fontSize,
- lineHeight: typography.body?.lineHeight,
- },
- startIcon: {
- marginRight: "12px",
- "&& >svg": {
- fontSize: "20px",
- },
- },
- endIcon: {
- marginLeft: "12px",
- "&& >svg": {
- fontSize: "20px",
- },
- },
- },
- },
- MuiInputBase: {
- styleOverrides: {
- formControl: {
- // Give a symmetric border to the input field, by default the
- // border radius is only applied to the top for the "filled"
- // variant of input used inside TextFields.
- borderRadius: "8px",
- // TODO: Should we also add overflow hidden so that there is no
- // gap between the filled area and the (full width) border. Not
- // sure how this might interact with selects.
- // overflow: "hidden",
-
- // Hide the bottom border that always appears for the "filled"
- // variant of input used inside TextFields.
- "::before": {
- borderBottom: "none !important",
- },
- },
- },
- },
- MuiFilledInput: {
- styleOverrides: {
- input: {
- "&:autofill": {
- boxShadow: "#c7fd4f",
- },
- },
- },
- },
- MuiTextField: {
- defaultProps: {
- // The MUI default variant is "outlined", override it to use the
- // "filled" one by default.
- variant: "filled",
- // Reduce the vertical margins that MUI adds to the TextField.
- //
- // Note that this causes things to be too tight when the helper text
- // is shown, so this is not recommended for new code that we write.
- margin: "dense",
- },
- styleOverrides: {
- root: {
- "& .MuiInputAdornment-root": {
- marginRight: "8px",
- },
- },
- },
- },
- MuiSvgIcon: {
- styleOverrides: {
- root: ({ ownerState }) => ({
- ...getIconColor(ownerState, colors),
- }),
- },
- },
-
- MuiIconButton: {
- styleOverrides: {
- root: ({ ownerState }) => ({
- ...getIconColor(ownerState, colors),
- padding: "12px",
- }),
- },
- },
- MuiSnackbar: {
- styleOverrides: {
- root: {
- // Set a default border radius for all snackbar's (e.g.
- // notification popups).
- borderRadius: "8px",
- },
- },
- },
- MuiModal: {
- styleOverrides: {
- root: {
- '&:has(> div[style*="opacity: 0"])': {
- pointerEvents: "none",
- },
- },
- },
- },
- MuiMenuItem: {
- styleOverrides: {
- // don't reduce opacity of disabled items
- root: {
- "&.Mui-disabled": {
- opacity: 1,
- },
- },
- },
- },
-});
-
-const getDropShadowStyle = (shadows: Shadow[] | undefined) => {
- return (shadows ?? [])
- .map(
- (shadow) =>
- `drop-shadow(${shadow.x}px ${shadow.y}px ${shadow.blur}px ${shadow.color})`,
- )
- .join(" ");
-};
-
-interface IconColorableOwnerState {
- color?: string;
- disabled?: boolean;
-}
-
-function getIconColor(
- ownerState: IconColorableOwnerState,
- colors: ThemeColorsOptions,
-) {
- switch (ownerState.color) {
- case "primary":
- return {
- color: colors.stroke?.base,
- };
- case "secondary":
- return {
- color: colors.stroke?.muted,
- };
- }
- if (ownerState.disabled) {
- return {
- color: colors.stroke?.faint,
- };
- }
- return {};
-}
diff --git a/web/packages/shared/themes/constants.ts b/web/packages/shared/themes/constants.ts
deleted file mode 100644
index 70e42f235d..0000000000
--- a/web/packages/shared/themes/constants.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export enum THEME_COLOR {
- LIGHT = "light",
- DARK = "dark",
-}
diff --git a/web/packages/shared/themes/index.ts b/web/packages/shared/themes/index.ts
index 80a4c6fe3e..013ac59fc5 100644
--- a/web/packages/shared/themes/index.ts
+++ b/web/packages/shared/themes/index.ts
@@ -1,9 +1,17 @@
+import type {
+ FixedColors,
+ PaletteOptions,
+ Shadow,
+ ThemeColorsOptions,
+} from "@mui/material";
import { createTheme } from "@mui/material";
-import { getColors, type ColorAccentType } from "./colors";
-import { getComponents } from "./components";
-import { THEME_COLOR } from "./constants";
-import { getPallette } from "./palette";
-import { typography } from "./typography";
+import type { Components } from "@mui/material/styles/components";
+import type { TypographyOptions } from "@mui/material/styles/createTypography";
+
+export enum THEME_COLOR {
+ LIGHT = "light",
+ DARK = "dark",
+}
export const getTheme = (
themeColor: THEME_COLOR,
@@ -28,3 +36,586 @@ export const getTheme = (
});
return theme;
};
+
+const typography: TypographyOptions = {
+ h1: {
+ fontSize: "48px",
+ lineHeight: "58px",
+ // [Note: Bold headings]
+ //
+ // Browser default is bold, but MUI resets it to 500 which is too light
+ // for our chosen font.
+ fontWeight: "bold",
+ },
+ h2: {
+ fontSize: "32px",
+ lineHeight: "39px",
+ },
+ h3: {
+ fontSize: "24px",
+ lineHeight: "29px",
+ },
+ h4: {
+ fontSize: "22px",
+ lineHeight: "27px",
+ },
+ h5: {
+ fontSize: "20px",
+ lineHeight: "25px",
+ // See: [Note: Bold headings]
+ fontWeight: "bold",
+ },
+ // h6 is the default variant used by MUI's DialogTitle.
+ h6: {
+ // The font size and line height below is the same as large.
+ fontSize: "18px",
+ lineHeight: "22px",
+ // See: [Note: Bold headings]
+ fontWeight: "bold",
+ },
+ large: {
+ fontSize: "18px",
+ lineHeight: "22px",
+ },
+ body: {
+ fontSize: "16px",
+ lineHeight: "20px",
+ },
+ small: {
+ fontSize: "14px",
+ lineHeight: "17px",
+ },
+ mini: {
+ fontSize: "12px",
+ lineHeight: "15px",
+ },
+ tiny: {
+ fontSize: "10px",
+ lineHeight: "12px",
+ },
+ fontFamily: ["Inter", "sans-serif"].join(","),
+};
+
+export type ColorAccentType = "auth" | "photos";
+
+const getColors = (
+ themeColor: THEME_COLOR,
+ accentType: ColorAccentType,
+): ThemeColorsOptions => {
+ switch (themeColor) {
+ case THEME_COLOR.LIGHT:
+ return { ...fixedColors(accentType), ...lightThemeColors };
+ default:
+ return { ...fixedColors(accentType), ...darkThemeColors };
+ }
+};
+
+const fixedColors = (
+ accentType: "auth" | "photos",
+): Pick<ThemeColorsOptions, keyof FixedColors> => {
+ switch (accentType) {
+ case "auth":
+ return {
+ ...commonFixedColors,
+ accent: authAccentColor,
+ };
+ default:
+ return {
+ ...commonFixedColors,
+ accent: photosAccentColor,
+ };
+ }
+};
+
+const commonFixedColors: Partial<Pick<ThemeColorsOptions, keyof FixedColors>> =
+ {
+ accent: {
+ A700: "#00B33C",
+ A500: "#1DB954",
+ A400: "#26CB5F",
+ A300: "#01DE4D",
+ },
+ warning: {
+ A500: "#FFC247",
+ },
+ danger: {
+ A800: "#F53434",
+ A700: "#EA3F3F",
+ A500: "#FF6565",
+ A400: "#FF6F6F",
+ },
+ white: { base: "#fff", muted: "rgba(255, 255, 255, 0.48)" },
+ black: { base: "#000", muted: "rgba(0, 0, 0, 0.65)" },
+ };
+
+const authAccentColor = {
+ A700: "rgb(164, 0, 182)",
+ A500: "rgb(150, 13, 214)",
+ A400: "rgb(122, 41, 193)",
+ A300: "rgb(152, 77, 244)",
+};
+
+const photosAccentColor = {
+ A700: "#00B33C",
+ A500: "#1DB954",
+ A400: "#26CB5F",
+ A300: "#01DE4D",
+};
+
+const lightThemeColors: Omit<ThemeColorsOptions, keyof FixedColors> = {
+ background: {
+ base: "#fff",
+ elevated: "#fff",
+ elevated2: "rgba(153, 153, 153, 0.04)",
+ },
+ backdrop: {
+ base: "rgba(255, 255, 255, 0.92)",
+ muted: "rgba(255, 255, 255, 0.75)",
+ faint: "rgba(255, 255, 255, 0.30)",
+ },
+ text: {
+ base: "#000",
+ muted: "rgba(0, 0, 0, 0.60)",
+ faint: "rgba(0, 0, 0, 0.50)",
+ },
+ fill: {
+ base: "#000",
+ muted: "rgba(0, 0, 0, 0.12)",
+ faint: "rgba(0, 0, 0, 0.04)",
+ basePressed: "rgba(0, 0, 0, 0.87))",
+ faintPressed: "rgba(0, 0, 0, 0.08)",
+ },
+ stroke: {
+ base: "#000",
+ muted: "rgba(0, 0, 0, 0.24)",
+ faint: "rgba(0, 0, 0, 0.12)",
+ },
+
+ shadows: {
+ float: [{ x: 0, y: 0, blur: 10, color: "rgba(0, 0, 0, 0.25)" }],
+ menu: [
+ {
+ x: 0,
+ y: 0,
+ blur: 6,
+ color: "rgba(0, 0, 0, 0.16)",
+ },
+ {
+ x: 0,
+ y: 3,
+ blur: 6,
+ color: "rgba(0, 0, 0, 0.12)",
+ },
+ ],
+ button: [
+ {
+ x: 0,
+ y: 4,
+ blur: 4,
+ color: "rgba(0, 0, 0, 0.25)",
+ },
+ ],
+ },
+};
+
+const darkThemeColors: Omit<ThemeColorsOptions, keyof FixedColors> = {
+ background: {
+ base: "#000000",
+ elevated: "#1b1b1b",
+ elevated2: "#252525",
+ },
+ backdrop: {
+ base: "rgba(0, 0, 0, 0.90)",
+ muted: "rgba(0, 0, 0, 0.65)",
+ faint: "rgba(0, 0, 0,0.20)",
+ },
+ text: {
+ base: "#fff",
+ muted: "rgba(255, 255, 255, 0.70)",
+ faint: "rgba(255, 255, 255, 0.50)",
+ },
+ fill: {
+ base: "#fff",
+ muted: "rgba(255, 255, 255, 0.16)",
+ faint: "rgba(255, 255, 255, 0.12)",
+ basePressed: "rgba(255, 255, 255, 0.90)",
+ faintPressed: "rgba(255, 255, 255, 0.06)",
+ },
+ stroke: {
+ base: "#ffffff",
+ muted: "rgba(255,255,255,0.24)",
+ faint: "rgba(255,255,255,0.16)",
+ },
+
+ shadows: {
+ float: [
+ {
+ x: 0,
+ y: 2,
+ blur: 12,
+ color: "rgba(0, 0, 0, 0.75)",
+ },
+ ],
+ menu: [
+ {
+ x: 0,
+ y: 0,
+ blur: 6,
+ color: "rgba(0, 0, 0, 0.50)",
+ },
+ {
+ x: 0,
+ y: 3,
+ blur: 6,
+ color: "rgba(0, 0, 0, 0.25)",
+ },
+ ],
+ button: [
+ {
+ x: 0,
+ y: 4,
+ blur: 4,
+ color: "rgba(0, 0, 0, 0.75)",
+ },
+ ],
+ },
+};
+
+const getPallette = (
+ themeColor: THEME_COLOR,
+ colors: ThemeColorsOptions,
+): PaletteOptions => {
+ const paletteOptions = getPalletteOptions(themeColor, colors);
+ switch (themeColor) {
+ case THEME_COLOR.LIGHT:
+ return { mode: "light", ...paletteOptions };
+ default:
+ return { mode: "dark", ...paletteOptions };
+ }
+};
+
+const getPalletteOptions = (
+ themeColor: THEME_COLOR,
+ colors: ThemeColorsOptions,
+): PaletteOptions => {
+ return {
+ primary: {
+ // See: [Note: strict mode migration]
+ //
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ main: colors.fill.base,
+ dark: colors.fill?.basePressed,
+ contrastText:
+ themeColor === "dark" ? colors.black?.base : colors.white?.base,
+ },
+ secondary: {
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ main: colors.fill.faint,
+ dark: colors.fill?.faintPressed,
+ contrastText: colors.text?.base,
+ },
+ accent: {
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ main: colors.accent.A500,
+ dark: colors.accent?.A700,
+ contrastText: colors.white?.base,
+ },
+ critical: {
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ main: colors.danger.A700,
+ dark: colors.danger?.A800,
+ contrastText: colors.white?.base,
+ },
+ background: {
+ default: colors.background?.base,
+ paper: colors.background?.elevated,
+ },
+ text: {
+ primary: colors.text?.base,
+ secondary: colors.text?.muted,
+ disabled: colors.text?.faint,
+ base: colors.text?.base,
+ muted: colors.text?.muted,
+ faint: colors.text?.faint,
+ },
+ divider: colors.stroke?.faint,
+ };
+};
+
+const getComponents = (
+ colors: ThemeColorsOptions,
+ typography: TypographyOptions,
+): Components => ({
+ MuiCssBaseline: {
+ styleOverrides: {
+ body: {
+ fontFamily: typography.fontFamily,
+ // MUI has different letter spacing for each variant, but those
+ // are values arrived at for the default Material font, and
+ // don't work for the font that we're using, so reset it to a
+ // reasonable value that works for our font.
+ letterSpacing: "-0.011em",
+ },
+ strong: { fontWeight: 700 },
+ },
+ },
+
+ MuiTypography: {
+ defaultProps: {
+ // MUI has body1 as the default variant for Typography, but our
+ // variant scheme is different, instead of body1/2, we have
+ // large/body/small etc. So reset the default to our equivalent of
+ // body1, which is "body".
+ variant: "body",
+ // Map all our custom variants to <p>.
+ variantMapping: {
+ large: "p",
+ body: "p",
+ small: "p",
+ mini: "p",
+ tiny: "p",
+ },
+ },
+ },
+
+ MuiDrawer: {
+ styleOverrides: {
+ root: {
+ ".MuiBackdrop-root": {
+ backgroundColor: colors.backdrop?.faint,
+ },
+ },
+ },
+ },
+ MuiDialog: {
+ defaultProps: {
+ // This is required to prevent console errors about aria-hiding a
+ // focused button when the dialog is closed.
+ //
+ // https://github.com/mui/material-ui/issues/43106#issuecomment-2314809028
+ closeAfterTransition: false,
+ },
+ styleOverrides: {
+ root: {
+ ".MuiBackdrop-root": {
+ backgroundColor: colors.backdrop?.faint,
+ },
+ "& .MuiDialog-paper": {
+ filter: getDropShadowStyle(colors.shadows?.float),
+ },
+ // Reset the MUI default paddings to 16px everywhere.
+ //
+ // This is not a great choice either, usually most dialogs, for
+ // one reason or the other, will need to customize this padding
+ // anyway. But not resetting it to 16px leaves it at the MUI
+ // defaults, which just doesn't work well with our designs.
+ "& .MuiDialogTitle-root": {
+ // MUI default is '16px 24px'.
+ padding: "16px",
+ },
+ "& .MuiDialogContent-root": {
+ // MUI default is '20px 24px'.
+ padding: "16px",
+ // If the contents of the dialog's contents exceed the
+ // available height, show a scrollbar just for the contents
+ // instead of the entire dialog.
+ overflowY: "auto",
+ },
+ "& .MuiDialogActions-root": {
+ // MUI default is way off for us since they cluster the
+ // buttons to the right, while our designs usually want the
+ // buttons to align with the heading / content.
+ padding: "16px",
+ },
+ ".MuiDialogTitle-root + .MuiDialogContent-root": {
+ // MUI resets this to 0 when the content doesn't use
+ // dividers (none of ours do). I feel that is a better
+ // default, since unlike margins, padding doesn't collapse,
+ // but changing this now would break existing layouts.
+ paddingTop: "16px",
+ },
+ },
+ },
+ },
+ MuiPaper: {
+ styleOverrides: { root: { backgroundImage: "none" } },
+ },
+ MuiLink: {
+ defaultProps: {
+ color: colors.accent?.A500,
+ underline: "none",
+ },
+ styleOverrides: {
+ root: {
+ "&:hover": {
+ underline: "always",
+ color: colors.accent?.A500,
+ },
+ },
+ },
+ },
+
+ MuiButton: {
+ defaultProps: {
+ // Change the default button variant from "text" to "contained".
+ variant: "contained",
+ },
+ styleOverrides: {
+ // We don't use the size prop for the MUI button, or rather it
+ // cannot be used, since we have fixed the paddings and font sizes
+ // unconditionally here (which are all that the size prop changes).
+ root: {
+ padding: "12px 16px",
+ borderRadius: "4px",
+ textTransform: "none",
+ fontWeight: "bold",
+ fontSize: typography.body?.fontSize,
+ lineHeight: typography.body?.lineHeight,
+ },
+ startIcon: {
+ marginRight: "12px",
+ "&& >svg": {
+ fontSize: "20px",
+ },
+ },
+ endIcon: {
+ marginLeft: "12px",
+ "&& >svg": {
+ fontSize: "20px",
+ },
+ },
+ },
+ },
+ MuiInputBase: {
+ styleOverrides: {
+ formControl: {
+ // Give a symmetric border to the input field, by default the
+ // border radius is only applied to the top for the "filled"
+ // variant of input used inside TextFields.
+ borderRadius: "8px",
+ // TODO: Should we also add overflow hidden so that there is no
+ // gap between the filled area and the (full width) border. Not
+ // sure how this might interact with selects.
+ // overflow: "hidden",
+
+ // Hide the bottom border that always appears for the "filled"
+ // variant of input used inside TextFields.
+ "::before": {
+ borderBottom: "none !important",
+ },
+ },
+ },
+ },
+ MuiFilledInput: {
+ styleOverrides: {
+ input: {
+ "&:autofill": {
+ boxShadow: "#c7fd4f",
+ },
+ },
+ },
+ },
+ MuiTextField: {
+ defaultProps: {
+ // The MUI default variant is "outlined", override it to use the
+ // "filled" one by default.
+ variant: "filled",
+ // Reduce the vertical margins that MUI adds to the TextField.
+ //
+ // Note that this causes things to be too tight when the helper text
+ // is shown, so this is not recommended for new code that we write.
+ margin: "dense",
+ },
+ styleOverrides: {
+ root: {
+ "& .MuiInputAdornment-root": {
+ marginRight: "8px",
+ },
+ },
+ },
+ },
+ MuiSvgIcon: {
+ styleOverrides: {
+ root: ({ ownerState }) => ({
+ ...getIconColor(ownerState, colors),
+ }),
+ },
+ },
+
+ MuiIconButton: {
+ styleOverrides: {
+ root: ({ ownerState }) => ({
+ ...getIconColor(ownerState, colors),
+ padding: "12px",
+ }),
+ },
+ },
+ MuiSnackbar: {
+ styleOverrides: {
+ root: {
+ // Set a default border radius for all snackbar's (e.g.
+ // notification popups).
+ borderRadius: "8px",
+ },
+ },
+ },
+ MuiModal: {
+ styleOverrides: {
+ root: {
+ '&:has(> div[style*="opacity: 0"])': {
+ pointerEvents: "none",
+ },
+ },
+ },
+ },
+ MuiMenuItem: {
+ styleOverrides: {
+ // don't reduce opacity of disabled items
+ root: {
+ "&.Mui-disabled": {
+ opacity: 1,
+ },
+ },
+ },
+ },
+});
+
+const getDropShadowStyle = (shadows: Shadow[] | undefined) => {
+ return (shadows ?? [])
+ .map(
+ (shadow) =>
+ `drop-shadow(${shadow.x}px ${shadow.y}px ${shadow.blur}px ${shadow.color})`,
+ )
+ .join(" ");
+};
+
+interface IconColorableOwnerState {
+ color?: string;
+ disabled?: boolean;
+}
+
+function getIconColor(
+ ownerState: IconColorableOwnerState,
+ colors: ThemeColorsOptions,
+) {
+ switch (ownerState.color) {
+ case "primary":
+ return {
+ color: colors.stroke?.base,
+ };
+ case "secondary":
+ return {
+ color: colors.stroke?.muted,
+ };
+ }
+ if (ownerState.disabled) {
+ return {
+ color: colors.stroke?.faint,
+ };
+ }
+ return {};
+}
diff --git a/web/packages/shared/themes/palette.tsx b/web/packages/shared/themes/palette.tsx
deleted file mode 100644
index f7c6a7d9bb..0000000000
--- a/web/packages/shared/themes/palette.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import type { PaletteOptions, ThemeColorsOptions } from "@mui/material";
-import { THEME_COLOR } from "./constants";
-
-export const getPallette = (
- themeColor: THEME_COLOR,
- colors: ThemeColorsOptions,
-): PaletteOptions => {
- const paletteOptions = getPalletteOptions(themeColor, colors);
- switch (themeColor) {
- case THEME_COLOR.LIGHT:
- return { mode: "light", ...paletteOptions };
- default:
- return { mode: "dark", ...paletteOptions };
- }
-};
-
-export const getPalletteOptions = (
- themeColor: THEME_COLOR,
- colors: ThemeColorsOptions,
-): PaletteOptions => {
- return {
- primary: {
- // See: [Note: strict mode migration]
- //
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- main: colors.fill.base,
- dark: colors.fill?.basePressed,
- contrastText:
- themeColor === "dark" ? colors.black?.base : colors.white?.base,
- },
- secondary: {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- main: colors.fill.faint,
- dark: colors.fill?.faintPressed,
- contrastText: colors.text?.base,
- },
- accent: {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- main: colors.accent.A500,
- dark: colors.accent?.A700,
- contrastText: colors.white?.base,
- },
- critical: {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- main: colors.danger.A700,
- dark: colors.danger?.A800,
- contrastText: colors.white?.base,
- },
- background: {
- default: colors.background?.base,
- paper: colors.background?.elevated,
- },
- text: {
- primary: colors.text?.base,
- secondary: colors.text?.muted,
- disabled: colors.text?.faint,
- base: colors.text?.base,
- muted: colors.text?.muted,
- faint: colors.text?.faint,
- },
- divider: colors.stroke?.faint,
- };
-};
diff --git a/web/packages/shared/themes/typography.ts b/web/packages/shared/themes/typography.ts
deleted file mode 100644
index ca5e4903ea..0000000000
--- a/web/packages/shared/themes/typography.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import type { TypographyOptions } from "@mui/material/styles/createTypography";
-
-export const typography: TypographyOptions = {
- h1: {
- fontSize: "48px",
- lineHeight: "58px",
- // [Note: Bold headings]
- //
- // Browser default is bold, but MUI resets it to 500 which is too light
- // for our chosen font.
- fontWeight: "bold",
- },
- h2: {
- fontSize: "32px",
- lineHeight: "39px",
- },
- h3: {
- fontSize: "24px",
- lineHeight: "29px",
- },
- h4: {
- fontSize: "22px",
- lineHeight: "27px",
- },
- h5: {
- fontSize: "20px",
- lineHeight: "25px",
- // See: [Note: Bold headings]
- fontWeight: "bold",
- },
- // h6 is the default variant used by MUI's DialogTitle.
- h6: {
- // The font size and line height below is the same as large.
- fontSize: "18px",
- lineHeight: "22px",
- // See: [Note: Bold headings]
- fontWeight: "bold",
- },
- large: {
- fontSize: "18px",
- lineHeight: "22px",
- },
- body: {
- fontSize: "16px",
- lineHeight: "20px",
- },
- small: {
- fontSize: "14px",
- lineHeight: "17px",
- },
- mini: {
- fontSize: "12px",
- lineHeight: "15px",
- },
- tiny: {
- fontSize: "10px",
- lineHeight: "12px",
- },
- fontFamily: ["Inter", "sans-serif"].join(","),
-};