blob: a29c68d0dc6a2437e41b5b9f5c51d7ea224ca9f9 [file] [log] [blame]
simon26e79f72022-10-05 22:16:08 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
idillon3470d072022-11-22 15:22:34 -050018import { createTheme, PaletteMode, SimplePaletteColorOptions } from '@mui/material';
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040019
20declare module '@mui/material/styles' {
21 interface Theme {
22 InfoTooltip: {
23 backgroundColor: SimplePaletteColorOptions;
24 color: SimplePaletteColorOptions;
25 };
26 }
27
28 interface ThemeOptions {
29 InfoTooltip: {
30 backgroundColor: SimplePaletteColorOptions;
31 color: SimplePaletteColorOptions;
32 };
33 }
34}
idillon-sfl837ea0b2022-08-25 11:35:29 -040035
idillon3470d072022-11-22 15:22:34 -050036const fonts = {
idillon-sfl837ea0b2022-08-25 11:35:29 -040037 typography: {
simond47ef9e2022-09-28 22:24:28 -040038 fontFamily: 'Ubuntu',
idillon24fe8d82022-08-29 16:55:20 -040039 allVariants: {
simond47ef9e2022-09-28 22:24:28 -040040 color: 'black',
idillon24fe8d82022-08-29 16:55:20 -040041 },
idillon-sfl837ea0b2022-08-25 11:35:29 -040042 h1: {
43 fontWeight: 400,
simond47ef9e2022-09-28 22:24:28 -040044 fontSize: '26px',
45 lineHeight: '36px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040046 },
47 h2: {
48 fontWeight: 400,
simond47ef9e2022-09-28 22:24:28 -040049 fontSize: '22px',
50 lineHeight: '30px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040051 },
52 h3: {
53 fontWeight: 400,
simond47ef9e2022-09-28 22:24:28 -040054 fontSize: '18px',
55 lineHeight: '26px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040056 },
57 h4: {
58 fontWeight: 500,
simond47ef9e2022-09-28 22:24:28 -040059 fontSize: '15px',
60 lineHeight: '22px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040061 },
62 h5: {
63 fontWeight: 500,
simond47ef9e2022-09-28 22:24:28 -040064 fontSize: '13px',
65 lineHeight: '19px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040066 },
67 body1: {
68 fontWeight: 400,
simond47ef9e2022-09-28 22:24:28 -040069 fontSize: '15px',
70 lineHeight: '22px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040071 },
72 body2: {
73 fontWeight: 400,
simond47ef9e2022-09-28 22:24:28 -040074 fontSize: '13px',
75 lineHeight: '19px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040076 },
77 caption: {
78 fontWeight: 400,
simond47ef9e2022-09-28 22:24:28 -040079 fontSize: '12px',
80 lineHeight: '16px',
idillon-sfl837ea0b2022-08-25 11:35:29 -040081 },
82 },
83 components: {
idillon760b7fb2022-08-29 14:32:38 -040084 MuiCssBaseline: {
85 styleOverrides: `
86 @font-face {
87 font-family: "Ubuntu";
88 src: url("./fonts/Ubuntu-Th.ttf");
89 font-weight: 100;
90 font-style: normal;
91 }
92 @font-face {
93 font-family: "Ubuntu";
94 src: url("./fonts/Ubuntu-L.ttf");
95 font-weight: 300;
96 font-style: normal;
97 }
98 @font-face {
99 font-family: "Ubuntu";
100 src: url("./fonts/Ubuntu-LI.ttf");
101 font-weight: 300;
102 font-style: italic;
103 }
104 @font-face {
105 font-family: "Ubuntu";
106 src: url("./fonts/Ubuntu-R.ttf");
107 font-weight: 400;
108 font-style: normal;
109 }
110 @font-face {
111 font-family: "Ubuntu";
112 src: url("./fonts/Ubuntu-RI.ttf");
113 font-weight: 400;
114 font-style: italic;
115 }
116 @font-face {
117 font-family: "Ubuntu";
118 src: url("./fonts/Ubuntu-M.ttf");
119 font-weight: 500;
120 font-style: normal;
121 }
122 @font-face {
123 font-family: "Ubuntu";
124 src: url("./fonts/Ubuntu-MI.ttf");
125 font-weight: 500;
126 font-style: italic;
127 }
128 @font-face {
129 font-family: "Ubuntu";
130 src: url("./fonts/Ubuntu-B.ttf");
131 font-weight: 700;
132 font-style: normal;
133 }
134 @font-face {
135 font-family: "Ubuntu";
136 src: url("./fonts/Ubuntu-BI.ttf");
137 font-weight: 700;
138 font-style: italic;
139 }
140 `,
141 },
simond47ef9e2022-09-28 22:24:28 -0400142 },
idillon3470d072022-11-22 15:22:34 -0500143};
idillon760b7fb2022-08-29 14:32:38 -0400144
idillon3470d072022-11-22 15:22:34 -0500145const palettes = {
146 light: {
147 palette: {
148 mode: 'light' as PaletteMode,
149 primary: {
150 light: '#E5EEF5', // same as "#0056991A"
151 main: '#0071C9',
152 dark: '#005699',
153 },
154 error: {
155 main: '#CC0022',
156 dark: '#720013',
157 },
158 success: {
159 main: '#009980',
160 },
161 secondary: {
162 main: '#A3C2DA',
163 dark: '#06493F',
idillon-sfl837ea0b2022-08-25 11:35:29 -0400164 },
Charlie4b904152022-11-29 21:03:53 -0500165 action: {
166 disabled: '#7F7F7F',
167 },
idillon-sfl837ea0b2022-08-25 11:35:29 -0400168 },
idillon3470d072022-11-22 15:22:34 -0500169 InfoTooltip: {
170 backgroundColor: {
171 main: '#FFFFFF',
idillonef9ab812022-11-18 13:46:24 -0500172 },
idillon3470d072022-11-22 15:22:34 -0500173 color: {
174 main: '#292929',
idillon-sfl37c18df2022-08-26 18:44:27 -0400175 },
176 },
idillon-sfl837ea0b2022-08-25 11:35:29 -0400177 },
idillon3470d072022-11-22 15:22:34 -0500178 dark: {
179 palette: {
180 mode: 'dark' as PaletteMode,
181 primary: {
182 light: '#E5EEF5', // same as "#0056991A"
183 main: '#0071C9',
184 dark: '#005699',
185 },
186 error: {
187 main: '#CC0022',
188 dark: '#720013',
189 },
190 success: {
191 main: '#009980',
192 },
193 secondary: {
194 main: '#A3C2DA',
195 dark: '#06493F',
196 },
Charlie4b904152022-11-29 21:03:53 -0500197 action: {
198 disabled: '#7F7F7F',
199 },
idillon3470d072022-11-22 15:22:34 -0500200 },
201 InfoTooltip: {
202 backgroundColor: {
203 main: '#FFFFFF',
204 },
205 color: {
206 main: '#292929',
207 },
208 },
209 },
210};
211
212export const buildDefaultTheme = (mode: PaletteMode) => {
213 // Attemps to set the fonts on the second "createTheme" has resulted with wrong font-families
214 const partialTheme = createTheme({ ...palettes[mode], ...fonts });
215 const palette = partialTheme.palette;
216
217 return createTheme(partialTheme, {
218 components: {
219 MuiButton: {
220 styleOverrides: {
221 root: {
222 height: '46px',
223 fontWeight: 700,
224 fontSize: '15px',
225 lineHeight: '17px',
226 textTransform: 'none',
227 borderRadius: '5px',
228 },
229 sizeSmall: {
230 height: '36px',
231 },
232 contained: {
233 background: palette.primary.dark,
234 '&:hover': {
235 background: palette.primary.main,
236 },
237 },
238 outlined: {
239 background: '#FFF',
240 borderColor: '#0056995C',
241 color: palette.primary.dark,
242 '&:hover': {
243 background: palette.primary.light,
244 borderColor: palette.primary.dark,
245 },
246 },
247 text: {
248 background: '#fff',
249 color: palette.primary.dark,
250 '&:hover': {
251 background: palette.primary.light,
252 },
253 },
254 },
255 },
idillon22ed8192022-11-29 12:17:04 -0500256 MuiDialog: {
257 styleOverrides: {
258 paper: {
259 padding: '16px',
260 boxShadow: '3px 3px 7px #00000029',
261 borderRadius: '20px',
262 },
263 },
264 },
265 MuiDialogActions: {
266 styleOverrides: {
267 root: {
268 padding: '0px',
269 },
270 },
271 },
272 MuiDialogContent: {
273 styleOverrides: {
274 root: {
275 padding: '0px',
276 margin: '16px 0px',
277 minWidth: '500px',
278 },
279 },
280 },
281 MuiDialogTitle: {
282 styleOverrides: {
283 root: {
284 padding: '0px',
285 },
286 },
287 },
idillon3470d072022-11-22 15:22:34 -0500288 MuiSwitch: {
289 defaultProps: {
290 disableRipple: true,
291 },
292 styleOverrides: {
293 root: {
294 width: '60px',
295 height: '30px',
296 padding: 0,
297 },
298 switchBase: {
299 padding: 0,
300 '&.Mui-checked': {
301 transform: `translateX(30px)`,
302 },
303 },
304 thumb: {
idillon42cc62a2022-11-29 12:22:33 -0500305 boxSizing: 'border-box',
306 width: '30px',
307 height: '30px',
idillon3470d072022-11-22 15:22:34 -0500308 border: `1px solid ${palette.primary.dark}`,
idillon42cc62a2022-11-29 12:22:33 -0500309 boxShadow: 'none',
idillon3470d072022-11-22 15:22:34 -0500310 '.Mui-checked.Mui-checked &': {
idillon3470d072022-11-22 15:22:34 -0500311 border: 'none',
312 },
313 },
314 track: {
315 backgroundColor: palette.primary.light,
316 borderRadius: '30px',
317 opacity: 1,
318 '.Mui-checked.Mui-checked + &': {
319 backgroundColor: palette.primary.light,
320 opacity: 1,
321 },
322 },
323 colorPrimary: {
324 color: '#fff',
325 '&.Mui-checked': {
326 color: palette.primary.dark,
327 },
328 },
329 },
330 },
331 MuiInput: {
332 styleOverrides: {
333 root: {
334 color: palette.primary.dark,
335 '&.Mui-error': {
336 color: palette.error.main,
337 },
338 },
339 underline: {
340 /*
341 Material UI uses "before" for the regular underline.
342 There is a second underline called "after" placed over "before"
343 */
344 '&:before': {
345 borderBottom: `2px solid ${palette.primary.dark}`,
346 },
347 '&:hover:not(.Mui-disabled, .Mui-error):before': {
348 borderBottom: '2px solid #03B9E9',
349 },
350 '&:after': {
351 borderBottom: '2px solid #03B9E9',
352 },
353 '&:hover:not(.Mui-error):after': {
354 borderBottom: '2px solid #03B9E9',
355 },
356 },
357 },
358 },
359 MuiFormControl: {
360 styleOverrides: {
361 root: {
362 height: '90px',
363 },
364 },
365 },
366 MuiFormHelperText: {
367 styleOverrides: {
368 root: {
369 position: 'absolute',
370 bottom: '0px',
371 fontSize: '15px',
372 },
373 },
374 },
375 MuiInputLabel: {
376 styleOverrides: {
377 root: {
378 color: 'black',
379 fontSize: '15px',
380 left: '50%',
381 transform: 'translate(-50%, 20px)',
382 transition: 'left .2s, transform .2s',
383 },
384 shrink: {
385 color: 'black',
386 left: 0,
387 transform: 'translate(0, 50px) scale(0.75)',
388 transition: 'left .2s, transform .2s',
389 '&.Mui-focused, &.Mui-error': {
390 color: 'black',
391 },
392 },
393 },
394 },
idillon9e542ca2022-12-15 17:54:07 -0500395 MuiListItemButton: {
396 styleOverrides: {
397 root: {
398 '&.Mui-selected': {
399 backgroundColor: '#cccccc',
400 opacity: 1,
401 '&:hover': {
402 backgroundColor: '#cccccc',
403 opacity: 1,
404 },
405 },
406 '&:hover': {
407 backgroundColor: '#d5d5d5',
408 opacity: 1,
409 },
410 },
411 },
412 },
idillon3470d072022-11-22 15:22:34 -0500413 },
414 });
415};