blob: 0245b673aa25677494300f391cc44efed7d29cb2 [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 },
256 MuiSwitch: {
257 defaultProps: {
258 disableRipple: true,
259 },
260 styleOverrides: {
261 root: {
262 width: '60px',
263 height: '30px',
264 padding: 0,
265 },
266 switchBase: {
267 padding: 0,
268 '&.Mui-checked': {
269 transform: `translateX(30px)`,
270 },
271 },
272 thumb: {
273 width: '28px',
274 height: '28px',
275 border: `1px solid ${palette.primary.dark}`,
276 '.Mui-checked.Mui-checked &': {
277 width: '30px',
278 height: '30px',
279 border: 'none',
280 },
281 },
282 track: {
283 backgroundColor: palette.primary.light,
284 borderRadius: '30px',
285 opacity: 1,
286 '.Mui-checked.Mui-checked + &': {
287 backgroundColor: palette.primary.light,
288 opacity: 1,
289 },
290 },
291 colorPrimary: {
292 color: '#fff',
293 '&.Mui-checked': {
294 color: palette.primary.dark,
295 },
296 },
297 },
298 },
299 MuiInput: {
300 styleOverrides: {
301 root: {
302 color: palette.primary.dark,
303 '&.Mui-error': {
304 color: palette.error.main,
305 },
306 },
307 underline: {
308 /*
309 Material UI uses "before" for the regular underline.
310 There is a second underline called "after" placed over "before"
311 */
312 '&:before': {
313 borderBottom: `2px solid ${palette.primary.dark}`,
314 },
315 '&:hover:not(.Mui-disabled, .Mui-error):before': {
316 borderBottom: '2px solid #03B9E9',
317 },
318 '&:after': {
319 borderBottom: '2px solid #03B9E9',
320 },
321 '&:hover:not(.Mui-error):after': {
322 borderBottom: '2px solid #03B9E9',
323 },
324 },
325 },
326 },
327 MuiFormControl: {
328 styleOverrides: {
329 root: {
330 height: '90px',
331 },
332 },
333 },
334 MuiFormHelperText: {
335 styleOverrides: {
336 root: {
337 position: 'absolute',
338 bottom: '0px',
339 fontSize: '15px',
340 },
341 },
342 },
343 MuiInputLabel: {
344 styleOverrides: {
345 root: {
346 color: 'black',
347 fontSize: '15px',
348 left: '50%',
349 transform: 'translate(-50%, 20px)',
350 transition: 'left .2s, transform .2s',
351 },
352 shrink: {
353 color: 'black',
354 left: 0,
355 transform: 'translate(0, 50px) scale(0.75)',
356 transition: 'left .2s, transform .2s',
357 '&.Mui-focused, &.Mui-error': {
358 color: 'black',
359 },
360 },
361 },
362 },
363 },
364 });
365};