blob: cc890ece7fbecd705bf634434f6b30146e98b6c8 [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 },
165 },
idillon3470d072022-11-22 15:22:34 -0500166 InfoTooltip: {
167 backgroundColor: {
168 main: '#FFFFFF',
idillonef9ab812022-11-18 13:46:24 -0500169 },
idillon3470d072022-11-22 15:22:34 -0500170 color: {
171 main: '#292929',
idillon-sfl37c18df2022-08-26 18:44:27 -0400172 },
173 },
idillon-sfl837ea0b2022-08-25 11:35:29 -0400174 },
idillon3470d072022-11-22 15:22:34 -0500175 dark: {
176 palette: {
177 mode: 'dark' as PaletteMode,
178 primary: {
179 light: '#E5EEF5', // same as "#0056991A"
180 main: '#0071C9',
181 dark: '#005699',
182 },
183 error: {
184 main: '#CC0022',
185 dark: '#720013',
186 },
187 success: {
188 main: '#009980',
189 },
190 secondary: {
191 main: '#A3C2DA',
192 dark: '#06493F',
193 },
194 },
195 InfoTooltip: {
196 backgroundColor: {
197 main: '#FFFFFF',
198 },
199 color: {
200 main: '#292929',
201 },
202 },
203 },
204};
205
206export const buildDefaultTheme = (mode: PaletteMode) => {
207 // Attemps to set the fonts on the second "createTheme" has resulted with wrong font-families
208 const partialTheme = createTheme({ ...palettes[mode], ...fonts });
209 const palette = partialTheme.palette;
210
211 return createTheme(partialTheme, {
212 components: {
213 MuiButton: {
214 styleOverrides: {
215 root: {
216 height: '46px',
217 fontWeight: 700,
218 fontSize: '15px',
219 lineHeight: '17px',
220 textTransform: 'none',
221 borderRadius: '5px',
222 },
223 sizeSmall: {
224 height: '36px',
225 },
226 contained: {
227 background: palette.primary.dark,
228 '&:hover': {
229 background: palette.primary.main,
230 },
231 },
232 outlined: {
233 background: '#FFF',
234 borderColor: '#0056995C',
235 color: palette.primary.dark,
236 '&:hover': {
237 background: palette.primary.light,
238 borderColor: palette.primary.dark,
239 },
240 },
241 text: {
242 background: '#fff',
243 color: palette.primary.dark,
244 '&:hover': {
245 background: palette.primary.light,
246 },
247 },
248 },
249 },
250 MuiSwitch: {
251 defaultProps: {
252 disableRipple: true,
253 },
254 styleOverrides: {
255 root: {
256 width: '60px',
257 height: '30px',
258 padding: 0,
259 },
260 switchBase: {
261 padding: 0,
262 '&.Mui-checked': {
263 transform: `translateX(30px)`,
264 },
265 },
266 thumb: {
267 width: '28px',
268 height: '28px',
269 border: `1px solid ${palette.primary.dark}`,
270 '.Mui-checked.Mui-checked &': {
271 width: '30px',
272 height: '30px',
273 border: 'none',
274 },
275 },
276 track: {
277 backgroundColor: palette.primary.light,
278 borderRadius: '30px',
279 opacity: 1,
280 '.Mui-checked.Mui-checked + &': {
281 backgroundColor: palette.primary.light,
282 opacity: 1,
283 },
284 },
285 colorPrimary: {
286 color: '#fff',
287 '&.Mui-checked': {
288 color: palette.primary.dark,
289 },
290 },
291 },
292 },
293 MuiInput: {
294 styleOverrides: {
295 root: {
296 color: palette.primary.dark,
297 '&.Mui-error': {
298 color: palette.error.main,
299 },
300 },
301 underline: {
302 /*
303 Material UI uses "before" for the regular underline.
304 There is a second underline called "after" placed over "before"
305 */
306 '&:before': {
307 borderBottom: `2px solid ${palette.primary.dark}`,
308 },
309 '&:hover:not(.Mui-disabled, .Mui-error):before': {
310 borderBottom: '2px solid #03B9E9',
311 },
312 '&:after': {
313 borderBottom: '2px solid #03B9E9',
314 },
315 '&:hover:not(.Mui-error):after': {
316 borderBottom: '2px solid #03B9E9',
317 },
318 },
319 },
320 },
321 MuiFormControl: {
322 styleOverrides: {
323 root: {
324 height: '90px',
325 },
326 },
327 },
328 MuiFormHelperText: {
329 styleOverrides: {
330 root: {
331 position: 'absolute',
332 bottom: '0px',
333 fontSize: '15px',
334 },
335 },
336 },
337 MuiInputLabel: {
338 styleOverrides: {
339 root: {
340 color: 'black',
341 fontSize: '15px',
342 left: '50%',
343 transform: 'translate(-50%, 20px)',
344 transition: 'left .2s, transform .2s',
345 },
346 shrink: {
347 color: 'black',
348 left: 0,
349 transform: 'translate(0, 50px) scale(0.75)',
350 transition: 'left .2s, transform .2s',
351 '&.Mui-focused, &.Mui-error': {
352 color: 'black',
353 },
354 },
355 },
356 },
357 },
358 });
359};