add theme provider

This commit is contained in:
2025-12-14 22:25:01 +05:00
parent d1e64382a4
commit 28fc3ab0fb
2 changed files with 183 additions and 1 deletions

View File

@ -1,9 +1,18 @@
import { createRoot } from 'react-dom/client';
import App from './App';
import { ThemeProvider, CssBaseline } from '@mui/material';
import { defaultTheme } from '../theme/themes'; // <-- поправь путь, если themes.ts лежит в другом месте
const container = document.getElementById('root') as HTMLElement;
const root = createRoot(container);
root.render(<App />);
root.render(
<ThemeProvider theme={defaultTheme}>
<CssBaseline />
<App />
</ThemeProvider>,
);
// calling IPC exposed from preload script
window.electron?.ipcRenderer.once('ipc-example', (arg) => {

173
src/theme/themes.ts Normal file
View File

@ -0,0 +1,173 @@
import { createTheme, SxProps, Theme } from '@mui/material/styles';
declare module '@mui/material/styles' {
interface Theme {
launcher: {
fonts: {
default: string;
};
topbar: {
firstBox: {
background: string;
backdropFilter: string;
boxShadow: string;
};
backButton: {
transition: string;
'&:hover': {
transform: string;
};
};
tabsBox: {
borderColor: string;
};
tabs: SxProps<Theme>;
tabBase: SxProps<Theme>;
tabActive: SxProps<Theme>;
menuPaper: SxProps<Theme>;
menuDivider: SxProps<Theme>;
menuItem: SxProps<Theme>;
menuUsername: SxProps<Theme>;
logoutButton: SxProps<Theme>;
windowControlIcon: {
color: string;
};
windowControlButton: SxProps<Theme>;
};
};
}
interface ThemeOptions {
launcher?: Theme['launcher'];
}
}
export const defaultTheme = createTheme({
palette: {
mode: 'dark',
primary: { main: '#F27121' },
secondary: { main: '#E940CD' },
text: {
primary: '#FFFFFF',
secondary: 'rgba(255,255,255,0.7)',
},
},
launcher: {
fonts: {
default: 'Benzin-Bold',
},
topbar: {
firstBox: {
background:
'linear-gradient(71deg, rgba(242,113,33,0.18) 0%, rgba(233,64,205,0.14) 70%, rgba(138,35,135,0.16) 100%)',
backdropFilter: 'blur(10px)',
boxShadow: '0 8px 30px rgba(0,0,0,0.35)',
},
backButton: {
transition: 'transform 0.3s ease',
'&:hover': {
transform: 'scale(1.2)',
},
},
tabsBox: {
borderColor: 'transparent',
},
tabs: {
// один градиент на весь Tabs
'--tabs-grad':
'linear-gradient(90deg, #F27121 0%, #E940CD 50%, #8A2387 100%)',
// активный текст показывает “срез” общего градиента
'& .MuiTab-root.Mui-selected': {
color: 'transparent',
backgroundImage: 'var(--tabs-grad)',
backgroundRepeat: 'no-repeat',
backgroundSize: 'var(--tabs-w) 100%',
backgroundPosition: 'calc(-1 * var(--active-x)) 0',
WebkitBackgroundClip: 'text',
backgroundClip: 'text',
},
// подчёркивание тоже из того же “единого” градиента
'& .MuiTabs-indicator': {
height: '2px',
backgroundImage: 'var(--tabs-grad)',
backgroundRepeat: 'no-repeat',
backgroundSize: 'var(--tabs-w) 100%',
backgroundPosition: 'calc(-1 * var(--active-x)) 0',
},
},
tabBase: (theme: Theme) => ({
color: 'white',
fontFamily: theme.launcher.fonts.default,
transition: 'all 0.3s ease',
'&:hover': {
color: 'rgb(170, 170, 170)',
},
}),
tabActive: {
color: 'transparent',
WebkitTextFillColor: 'transparent',
backgroundImage: 'var(--tabs-grad)',
backgroundRepeat: 'no-repeat',
backgroundSize: 'var(--tabs-w) 100%',
backgroundPosition: 'calc(-1 * var(--active-x)) 0',
WebkitBackgroundClip: 'text',
backgroundClip: 'text',
},
menuPaper: {
color: 'white',
bgcolor: 'rgba(0,0,0,0.82)',
backdropFilter: 'blur(10px)',
border: '1px solid rgba(233,64,205,0.25)',
boxShadow: '0 18px 40px rgba(0,0,0,0.55)',
},
menuDivider: {
borderColor: 'rgba(255,255,255,0.08)',
},
menuItem: (theme: Theme) => ({
fontFamily: theme.launcher.fonts.default,
'&:hover': {
bgcolor: 'rgba(255,77,77,0.15)',
},
}),
menuUsername: (theme: Theme) => ({
fontFamily: theme.launcher.fonts.default,
color: theme.palette.text.primary,
}),
logoutButton: (theme: Theme) => ({
fontFamily: theme.launcher.fonts.default,
background:
'linear-gradient(71deg, #F27121 0%, #E940CD 70%, #8A2387 100%)',
color: theme.palette.text.primary,
border: 'none',
transition: 'transform 0.3s ease',
'&:hover': {
background:
'linear-gradient(71deg, #F27121 0%, #E940CD 70%, #8A2387 100%)',
transform: 'scale(1.01)',
boxShadow: '0 4px 15px rgba(242, 113, 33, 0.4)',
},
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.3)',
}),
windowControlIcon: {
color: 'white',
},
windowControlButton: {
// тут только “визуал”, размеры оставим в TopBar
'&:hover': {
bgcolor: 'rgba(255,255,255,0.06)',
},
},
},
},
});