95 lines
2.2 KiB
TypeScript
Raw Normal View History

import darkScrollbar from '@mui/material/darkScrollbar';
import { createTheme } from '@mui/material/styles';
import { useMemo } from 'react';
2022-10-30 10:38:28 -04:00
import type { Components, PaletteMode, PaletteOptions, Theme } from '@mui/material';
const useCreateTheme = (mode: PaletteMode) => {
2022-10-30 10:38:28 -04:00
const theme = useMemo(() => createTheme(), []);
const palette: PaletteOptions = useMemo(
() =>
mode === 'light'
2022-10-30 10:38:28 -04:00
? {
mode,
primary: {
main: '#1b72de',
},
2022-10-30 10:38:28 -04:00
secondary: {
main: '#1b72de',
},
2022-10-30 10:38:28 -04:00
background: {
default: '#f9f9f9',
paper: '#f9f9f9',
},
2022-10-30 10:38:28 -04:00
}
: {
mode,
primary: {
2022-11-07 15:21:37 -05:00
main: '#5ecffb',
2022-10-30 10:38:28 -04:00
},
secondary: {
main: '#5ecffb',
},
background: {
default: '#2e3034',
paper: '#2e3034',
},
2022-10-30 10:38:28 -04:00
},
[mode],
);
const components: Components<Omit<Theme, 'components'>> | undefined = useMemo(
() =>
mode === 'light'
? {}
: {
MuiCssBaseline: {
styleOverrides: {
body: darkScrollbar(),
},
},
2022-10-30 10:38:28 -04:00
},
[mode],
);
2022-10-30 10:38:28 -04:00
return useMemo(
() =>
createTheme({
palette,
typography: {
fontFamily: "'Roboto', -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif",
h1: {
fontSize: '42px',
fontWeight: 'bold',
lineHeight: 1.3,
marginBottom: '16px',
[theme.breakpoints.down('md')]: {
fontSize: '30px',
},
},
h2: {
fontSize: '24px',
lineHeight: 1.3,
position: 'relative',
[theme.breakpoints.down('md')]: {
fontSize: '20px',
},
},
h3: {
fontSize: '20px',
lineHeight: 1.3,
position: 'relative',
[theme.breakpoints.down('md')]: {
fontSize: '18px',
},
},
},
components,
}),
[components, palette, theme.breakpoints],
);
};
export default useCreateTheme;