1- import { type PaletteColor , createTheme } from '@mui/material/styles' ;
1+ import {
2+ type PaletteColor ,
3+ type Theme ,
4+ createTheme ,
5+ } from '@mui/material/styles' ;
26import { type Property } from 'csstype' ;
37
48declare module '@mui/material/Typography' {
@@ -16,6 +20,11 @@ declare module '@mui/material/styles/createMixins' {
1620 }
1721}
1822
23+ export enum ThemeModeEnum {
24+ light = 'light' ,
25+ dark = 'dark' ,
26+ }
27+
1928export const fontFamily = {
2029 primary : '"Mulish"' ,
2130 secondary : '"IBM Plex Mono"' ,
@@ -43,87 +52,153 @@ const palette = {
4352 secondary : 'rgba(71, 71, 71, 0.8)' ,
4453 disabled : 'rgba(0,0,0,0.3)' ,
4554 } ,
55+ divider : 'rgba(0, 0, 0, 0.23)' ,
4656} ;
4757
48- export const theme = createTheme ( {
49- palette,
50- mixins : {
51- code : {
52- contrastText : '#f1fa8c' ,
53- command : {
54- fontWeight : 'bold' ,
55- color : '#ff79c6' ,
56- } ,
57- } ,
58+ const darkPalette = {
59+ primary : {
60+ main : '#96a1ff' ,
61+ dark : '#4a5dff' ,
62+ light : '#e7e8ff' ,
63+ contrastText : '#E3E3E3' ,
5864 } ,
59- typography : {
60- fontFamily : fontFamily . primary ,
65+ secondary : {
66+ main : '#3959fa' ,
67+ dark : '#002eea' ,
68+ light : '#989ffc' ,
69+ contrastText : '#ffffff' ,
70+ } ,
71+ background : {
72+ default : '#121212' ,
73+ paper : '#1E1E1E' ,
74+ } ,
75+ text : {
76+ primary : '#E3E3E3' ,
77+ secondary : 'rgba(255, 255, 255, 0.7)' ,
78+ disabled : 'rgba(255, 255, 255, 0.3)' ,
6179 } ,
62- components : {
63- MuiFormLabel : {
64- styleOverrides : {
65- root : {
66- color : '#474747' ,
80+ divider : 'rgba(255, 255, 255, 0.23)' ,
81+ } ;
82+
83+ export const getTheme = ( mode : ThemeModeEnum ) : Theme => {
84+ const isLightMode = mode === ThemeModeEnum . light ;
85+ const chosenPalette = ! isLightMode ? darkPalette : palette ;
86+ return createTheme ( {
87+ palette : { ...chosenPalette , mode } ,
88+ mixins : {
89+ code : {
90+ contrastText : '#f1fa8c' ,
91+ command : {
6792 fontWeight : 'bold' ,
93+ color : '#ff79c6' ,
6894 } ,
6995 } ,
7096 } ,
71- MuiTextField : {
72- styleOverrides : {
73- root : {
74- '&.md-small-input' : {
75- input : { paddingTop : '7px' , paddingBottom : '7px' } ,
97+ typography : {
98+ fontFamily : fontFamily . primary ,
99+ } ,
100+ components : {
101+ MuiInputAdornment : {
102+ styleOverrides : {
103+ root : {
104+ color : 'inherit' ,
76105 } ,
77106 } ,
78107 } ,
79- } ,
80- MuiSelect : {
81- styleOverrides : {
82- root : {
83- '.MuiSelect-select' : { paddingTop : '7px' , paddingBottom : '7px' } ,
108+ MuiFormLabel : {
109+ styleOverrides : {
110+ root : {
111+ color : chosenPalette . text . primary ,
112+ fontWeight : 'bold' ,
113+ } ,
84114 } ,
85115 } ,
86- } ,
87- MuiButton : {
88- styleOverrides : {
89- root : {
90- textTransform : 'none' ,
91- boxShadow : 'none' ,
92- fontFamily : fontFamily . secondary ,
93- boxSizing : 'border-box' ,
94- '&.MuiButton-contained' : {
95- border : '2px solid transparent' ,
116+ MuiTextField : {
117+ styleOverrides : {
118+ root : {
119+ '&.md-small-input' : {
120+ input : { paddingTop : '7px' , paddingBottom : '7px' } ,
121+ } ,
122+ '.MuiOutlinedInput-root fieldset' : {
123+ borderColor : chosenPalette . divider ,
124+ } ,
96125 } ,
97- '&.MuiButton-containedPrimary:hover' : {
98- boxShadow : 'none' ,
99- backgroundColor : 'transparent' ,
100- border : `2px solid ${ palette . primary . main } ` ,
101- color : palette . primary . main ,
102- } ,
103- '&.MuiButton-outlinedPrimary' : {
104- border : `2px solid ${ palette . primary . main } ` ,
105- padding : '6px 16px' ,
106- } ,
107- '&.MuiButton-outlinedPrimary:hover' : {
108- backgroundColor : palette . primary . main ,
109- color : palette . primary . contrastText ,
126+ } ,
127+ } ,
128+ MuiSelect : {
129+ styleOverrides : {
130+ root : {
131+ '.MuiSelect-select' : { paddingTop : '7px' , paddingBottom : '7px' } ,
132+ '.MuiSvgIcon-root' : { color : chosenPalette . text . primary } ,
133+ '&.MuiInputBase-root fieldset' : {
134+ borderColor : chosenPalette . divider ,
135+ } ,
110136 } ,
111137 } ,
112138 } ,
113- } ,
114- MuiTypography : {
115- variants : [
116- {
117- props : { variant : 'sectionTitle' } ,
118- style : {
119- color : palette . primary ?. main ,
120- fontWeight : 'bold' ,
121- fontSize : '1.5rem' ,
122- marginBottom : '0.5rem' ,
123- marginTop : '1rem' ,
139+ MuiButton : {
140+ styleOverrides : {
141+ root : {
142+ textTransform : 'none' ,
143+ boxShadow : 'none' ,
144+ fontFamily : fontFamily . secondary ,
145+ boxSizing : 'border-box' ,
146+ '&.MuiButton-contained' : {
147+ border : '2px solid transparent' ,
148+ color : chosenPalette . background . default ,
149+ '&.Mui-disabled' : {
150+ backgroundColor : chosenPalette . text . disabled ,
151+ } ,
152+ } ,
153+ '&.MuiButton-containedPrimary:hover' : {
154+ boxShadow : 'none' ,
155+ backgroundColor : 'transparent' ,
156+ border : `2px solid ${ chosenPalette . primary . main } ` ,
157+ color : chosenPalette . primary . main ,
158+ } ,
159+ '&.MuiButton-outlinedPrimary' : {
160+ border : `2px solid ${ chosenPalette . primary . main } ` ,
161+ padding : '6px 16px' ,
162+ } ,
163+ '&.MuiButton-outlinedPrimary:hover' : {
164+ backgroundColor : chosenPalette . primary . main ,
165+ color : isLightMode
166+ ? chosenPalette . primary . contrastText
167+ : chosenPalette . background . default ,
168+ } ,
169+ '&.MuiButton-text.inline' : {
170+ fontFamily : fontFamily . primary ,
171+ fontSize : 'inherit' ,
172+ padding : `0 8px` ,
173+ lineHeight : 'normal' ,
174+ verticalAlign : 'baseline' ,
175+ '&.line-start' : {
176+ paddingLeft : 0 ,
177+ } ,
178+ '.MuiButton-endIcon' : {
179+ marginRight : 0 ,
180+ svg : {
181+ color : 'inherit' ,
182+ } ,
183+ } ,
184+ } ,
124185 } ,
125186 } ,
126- ] ,
187+ } ,
188+ MuiTypography : {
189+ variants : [
190+ {
191+ props : { variant : 'sectionTitle' } ,
192+ style : {
193+ color : chosenPalette . primary ?. main ,
194+ fontWeight : 'bold' ,
195+ fontSize : '1.5rem' ,
196+ marginBottom : '0.5rem' ,
197+ marginTop : '1rem' ,
198+ } ,
199+ } ,
200+ ] ,
201+ } ,
127202 } ,
128- } ,
129- } ) ;
203+ } ) ;
204+ } ;
0 commit comments