-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
theme.ts
161 lines (142 loc) Β· 3.41 KB
/
theme.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { createTheme } from '@mui/material/styles';
import { PRIMARY_COLOR } from './colors';
const colors = {
black: '#000',
white: '#fff',
red: '#d32f2f',
orange: '#CD4000',
greySuperLight: '#f5f5f5',
greyLight: '#d3d3d3',
greyLight2: '#908ba1',
greyLight3: '#f3f4f240',
greyDark: '#a9a9a9',
greyDark2: '#586069',
greyChateau: '#95989a',
greyGainsboro: '#e3e3e3',
greyAthens: '#d3dddd',
eclipse: '#3c3c3c',
paleNavy: '#e4e8f1',
saltpan: '#f7f8f6',
snow: '#f9f9f9',
love: '#e25555',
nobel01: '#999999',
nobel02: '#9f9f9f',
primary: PRIMARY_COLOR,
secondary: '#20232a',
background: '#fff',
dodgerBlue: '#1ba1f2',
cyanBlue: '#253341',
};
const themeModes = {
light: {
...colors,
},
dark: {
...colors,
primary: '#24394e',
secondary: '#424242',
background: '#1A202C',
},
};
function applyPrimaryColor(mode: ThemeMode, primaryColor: string): any {
if (mode === 'light') {
themeModes['light'].primary = primaryColor;
}
return themeModes[mode];
}
export type ThemeMode = keyof typeof themeModes;
const fontSize = {
xxl: 26,
xl: 24,
lg: 21,
md: 18,
default: 16,
sm: 14,
ssm: 12,
};
export type FontSize = keyof typeof fontSize;
const fontWeight = {
light: 300,
regular: 400,
semiBold: 500,
bold: 700,
};
export type FontWeight = keyof typeof fontWeight;
export const breakPoints = {
xsmall: 400,
small: 576,
medium: 768,
large: 1024,
container: 1240,
xlarge: 1275,
};
export type BreakPoints = typeof breakPoints;
const customizedTheme = {
fontSize,
fontWeight,
breakPoints,
};
type CustomizedTheme = typeof customizedTheme;
export const getTheme = (themeMode: ThemeMode, primaryColor: string) => {
const palette = applyPrimaryColor(themeMode, primaryColor);
return createTheme({
typography: {
fontFamily: [
'-apple-system',
'BlinkMacSystemFont',
'"Helvetica Neue"',
'Arial',
'sans-serif',
].join(','),
},
palette: {
mode: themeMode,
...palette,
primary: { main: palette.primary },
secondary: { main: palette.secondary },
error: { main: palette.red },
background: {
default: palette.background,
},
},
...customizedTheme,
});
};
export type Theme = ReturnType<typeof getTheme>;
declare module '@mui/material/styles/createTheme' {
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
interface Theme extends CustomizedTheme {}
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
interface DeprecatedThemeOptions extends CustomizedTheme {}
}
declare module '@mui/material/styles/createPalette' {
interface CustomPalette {
black: string;
white: string;
red: string;
orange: string;
greySuperLight: string;
greyLight: string;
greyLight2: string;
greyLight3: string;
greyDark: string;
greyDark2: string;
greyChateau: string;
greyGainsboro: string;
greyAthens: string;
eclipse: string;
paleNavy: string;
saltpan: string;
snow: string;
love: string;
nobel01: string;
nobel02: string;
background: string;
dodgerBlue: string;
cyanBlue: string;
}
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
interface Palette extends CustomPalette {}
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
interface PaletteOptions extends Partial<CustomPalette> {}
}