simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 18 | import { createTheme, PaletteMode, SimplePaletteColorOptions } from '@mui/material'; |
Michelle Sepkap Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 19 | |
| 20 | declare 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-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 35 | |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 36 | const fonts = { |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 37 | typography: { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 38 | fontFamily: 'Ubuntu', |
idillon | 24fe8d8 | 2022-08-29 16:55:20 -0400 | [diff] [blame] | 39 | allVariants: { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 40 | color: 'black', |
idillon | 24fe8d8 | 2022-08-29 16:55:20 -0400 | [diff] [blame] | 41 | }, |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 42 | h1: { |
| 43 | fontWeight: 400, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 44 | fontSize: '26px', |
| 45 | lineHeight: '36px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 46 | }, |
| 47 | h2: { |
| 48 | fontWeight: 400, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 49 | fontSize: '22px', |
| 50 | lineHeight: '30px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 51 | }, |
| 52 | h3: { |
| 53 | fontWeight: 400, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 54 | fontSize: '18px', |
| 55 | lineHeight: '26px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 56 | }, |
| 57 | h4: { |
| 58 | fontWeight: 500, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 59 | fontSize: '15px', |
| 60 | lineHeight: '22px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 61 | }, |
| 62 | h5: { |
| 63 | fontWeight: 500, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 64 | fontSize: '13px', |
| 65 | lineHeight: '19px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 66 | }, |
| 67 | body1: { |
| 68 | fontWeight: 400, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 69 | fontSize: '15px', |
| 70 | lineHeight: '22px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 71 | }, |
| 72 | body2: { |
| 73 | fontWeight: 400, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 74 | fontSize: '13px', |
| 75 | lineHeight: '19px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 76 | }, |
| 77 | caption: { |
| 78 | fontWeight: 400, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 79 | fontSize: '12px', |
| 80 | lineHeight: '16px', |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 81 | }, |
| 82 | }, |
| 83 | components: { |
idillon | 760b7fb | 2022-08-29 14:32:38 -0400 | [diff] [blame] | 84 | 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 | }, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 142 | }, |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 143 | }; |
idillon | 760b7fb | 2022-08-29 14:32:38 -0400 | [diff] [blame] | 144 | |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 145 | const 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-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 164 | }, |
Charlie | 4b90415 | 2022-11-29 21:03:53 -0500 | [diff] [blame] | 165 | action: { |
| 166 | disabled: '#7F7F7F', |
| 167 | }, |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 168 | }, |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 169 | InfoTooltip: { |
| 170 | backgroundColor: { |
| 171 | main: '#FFFFFF', |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 172 | }, |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 173 | color: { |
| 174 | main: '#292929', |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 175 | }, |
| 176 | }, |
idillon-sfl | 837ea0b | 2022-08-25 11:35:29 -0400 | [diff] [blame] | 177 | }, |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 178 | 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 | }, |
Charlie | 4b90415 | 2022-11-29 21:03:53 -0500 | [diff] [blame] | 197 | action: { |
| 198 | disabled: '#7F7F7F', |
| 199 | }, |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 200 | }, |
| 201 | InfoTooltip: { |
| 202 | backgroundColor: { |
| 203 | main: '#FFFFFF', |
| 204 | }, |
| 205 | color: { |
| 206 | main: '#292929', |
| 207 | }, |
| 208 | }, |
| 209 | }, |
| 210 | }; |
| 211 | |
| 212 | export 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 | }, |
idillon | 22ed819 | 2022-11-29 12:17:04 -0500 | [diff] [blame] | 256 | 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 | }, |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 288 | 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: { |
idillon | 42cc62a | 2022-11-29 12:22:33 -0500 | [diff] [blame] | 305 | boxSizing: 'border-box', |
| 306 | width: '30px', |
| 307 | height: '30px', |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 308 | border: `1px solid ${palette.primary.dark}`, |
idillon | 42cc62a | 2022-11-29 12:22:33 -0500 | [diff] [blame] | 309 | boxShadow: 'none', |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 310 | '.Mui-checked.Mui-checked &': { |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 311 | 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 | }, |
idillon | a3c2fad | 2022-12-18 23:49:10 -0500 | [diff] [blame] | 395 | MuiLink: { |
| 396 | styleOverrides: { |
| 397 | root: { |
| 398 | color: '#005699', |
| 399 | }, |
| 400 | }, |
| 401 | }, |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 402 | MuiListItemButton: { |
| 403 | styleOverrides: { |
| 404 | root: { |
| 405 | '&.Mui-selected': { |
| 406 | backgroundColor: '#cccccc', |
| 407 | opacity: 1, |
| 408 | '&:hover': { |
| 409 | backgroundColor: '#cccccc', |
| 410 | opacity: 1, |
| 411 | }, |
| 412 | }, |
| 413 | '&:hover': { |
| 414 | backgroundColor: '#d5d5d5', |
| 415 | opacity: 1, |
| 416 | }, |
| 417 | }, |
| 418 | }, |
| 419 | }, |
idillon | 3470d07 | 2022-11-22 15:22:34 -0500 | [diff] [blame] | 420 | }, |
| 421 | }); |
| 422 | }; |