2022-11-26 13:51:56 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-06-04 21:08:39 +02:00
|
|
|
import { createTheme as createMuiTheme, Palette as MuiPalette, Theme } from '@mui/material/styles';
|
|
|
|
|
|
|
|
|
|
declare module '@mui/material/styles/createPalette' {
|
|
|
|
|
interface Palette {
|
|
|
|
|
custom: Palette['primary'];
|
|
|
|
|
}
|
2022-11-26 13:51:56 +01:00
|
|
|
|
|
|
|
|
interface PaletteOptions {
|
2023-06-04 21:08:39 +02:00
|
|
|
custom: PaletteOptions['primary'];
|
2022-11-26 13:51:56 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 21:08:39 +02:00
|
|
|
type DefaultMuiPalette = Omit<MuiPalette, 'custom'>;
|
|
|
|
|
type DefaultMuiTheme = Omit<Theme, 'palette'> & { palette: DefaultMuiPalette };
|
|
|
|
|
|
2024-04-07 15:33:08 +02:00
|
|
|
let theme: Theme;
|
|
|
|
|
export const getCurrentTheme = () => theme;
|
2023-10-28 00:32:02 +02:00
|
|
|
export const createTheme = (dark?: boolean) => {
|
2023-06-04 21:08:39 +02:00
|
|
|
const baseTheme: DefaultMuiTheme = createMuiTheme({
|
2022-11-26 13:51:56 +01:00
|
|
|
palette: {
|
|
|
|
|
mode: dark ? 'dark' : 'light',
|
|
|
|
|
},
|
2023-06-04 21:08:39 +02:00
|
|
|
} as Theme);
|
2022-11-26 13:51:56 +01:00
|
|
|
|
2024-01-05 20:11:29 +01:00
|
|
|
const suwayomiTheme = createMuiTheme(
|
2023-02-06 10:06:33 +01:00
|
|
|
{
|
|
|
|
|
palette: {
|
|
|
|
|
custom: {
|
|
|
|
|
main: dark ? baseTheme.palette.common.black : baseTheme.palette.common.white,
|
|
|
|
|
light: dark ? baseTheme.palette.grey[900] : baseTheme.palette.grey[100],
|
|
|
|
|
},
|
2022-11-26 13:51:56 +01:00
|
|
|
},
|
2023-02-06 10:06:33 +01:00
|
|
|
components: {
|
2023-06-17 16:50:17 +02:00
|
|
|
MuiUseMediaQuery: {
|
|
|
|
|
defaultProps: {
|
|
|
|
|
noSsr: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-02-06 10:06:33 +01:00
|
|
|
MuiCssBaseline: {
|
|
|
|
|
styleOverrides: `
|
2022-11-26 13:51:56 +01:00
|
|
|
*::-webkit-scrollbar {
|
|
|
|
|
width: 10px;
|
|
|
|
|
background: ${dark ? '#222' : '#e1e1e1'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*::-webkit-scrollbar-thumb {
|
|
|
|
|
background: ${dark ? '#111' : '#aaa'};
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
}
|
|
|
|
|
`,
|
2023-02-06 10:06:33 +01:00
|
|
|
},
|
2022-11-26 13:51:56 +01:00
|
|
|
},
|
|
|
|
|
},
|
2023-02-06 10:06:33 +01:00
|
|
|
baseTheme,
|
|
|
|
|
);
|
2022-11-26 13:51:56 +01:00
|
|
|
|
2024-04-07 15:33:08 +02:00
|
|
|
theme = suwayomiTheme;
|
|
|
|
|
|
2024-01-05 20:11:29 +01:00
|
|
|
return suwayomiTheme;
|
2022-11-26 13:51:56 +01:00
|
|
|
};
|