Skip to content

Commit 72e12d7

Browse files
committed
add brandable theme
Signed-off-by: aabidsofi19 <mailtoaabid01@gmail.com>
1 parent cdb1f4e commit 72e12d7

2 files changed

Lines changed: 471 additions & 33 deletions

File tree

src/theme/palette.ts

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ declare module '@mui/material/styles' {
4747
error?: Interactiveness;
4848
code?: string;
4949
surfaces?: string;
50+
51+
appNavigationBar?: string;
52+
secondaryAppNavigationBar?: string;
5053
}
5154

5255
// Defines the extended text color options used in the palette.
@@ -141,6 +144,9 @@ declare module '@mui/material/styles' {
141144
To define any additional custom color options, you can extend the interface here.
142145
*/
143146
interface Palette {
147+
surface: SurfaceTokens;
148+
interactive: InteractiveTokens;
149+
navigation: NavigationTokens;
144150
border: {
145151
default: string;
146152
strong: string;
@@ -164,9 +170,74 @@ declare module '@mui/material/styles' {
164170
};
165171
};
166172
}
173+
174+
// surface tokens need to have enough contrast
175+
// with text and interactive elements
176+
type SurfaceTokens = {
177+
178+
/** main page background, content containers (pure bg color) */
179+
primary: string;
180+
181+
/** secondary surfaces (slightly darker bg) */
182+
secondary: string;
183+
184+
/** tertiary surfaces (even darker bg) */
185+
tertiary: string;
186+
187+
/** floating elements with depth (bg + shadow) */
188+
elevated: string;
189+
190+
/** modal backdrops (semi-transparent bg) */
191+
overlay: string;
192+
193+
/** highlight surfaces (eg. modal headers , tabs, ) */
194+
tint: string;
195+
196+
/** high contrast alternative (fg as bg) */
197+
inverse: string;
198+
}
199+
200+
type InteractiveTokens = {
201+
/** default interactive elements (primary color) */
202+
primary: string;
203+
204+
/** hover state for interactive elements (primary hover tint) */
205+
hover: string;
206+
207+
/** disabled state for interactive elements (primary disabled tint) */
208+
disabled?: string;
209+
210+
/** pressed state for interactive elements (primary pressed tint) */
211+
pressed: string;
212+
213+
/** secondary interactive elements (secondary color) */
214+
secondary: string;
215+
216+
/** tertiary interactive elements (tertiary color) */
217+
tertiary: string;
218+
};
219+
220+
type NavigationTokens = {
221+
/** main navigation bar background */
222+
primary: string;
223+
224+
/** secondary navigation bar background */
225+
secondary: string;
226+
227+
/** active navigation item background */
228+
active: string;
229+
230+
/** hover state for navigation items */
231+
hover: string;
232+
};
167233

168234
// Defines the options available for the palette.
169235
interface PaletteOptions {
236+
237+
surface: SurfaceTokens;
238+
interactive: InteractiveTokens;
239+
navigation: NavigationTokens;
240+
170241
border: {
171242
default: string;
172243
strong: string;
@@ -177,8 +248,11 @@ declare module '@mui/material/styles' {
177248
alt: string;
178249
};
179250
};
251+
180252
icon: {
181253
default: string;
254+
dualTone?: string; // For icons with two colors
255+
dualToneInverse?: string; // For icons with two colors in inverse mode (eg on primary colored bg)
182256
secondary: string;
183257
brand: string;
184258
inverse: string;
@@ -192,7 +266,38 @@ declare module '@mui/material/styles' {
192266
}
193267
}
194268

269+
export type ThemePalette = PaletteOptions
270+
271+
272+
195273
export const lightModePalette: PaletteOptions = {
274+
275+
surface: {
276+
primary: Colors.charcoal[100],
277+
secondary: Colors.charcoal[90],
278+
tertiary: Colors.charcoal[80],
279+
tint: Colors.charcoal[70],
280+
elevated: Colors.WHITE,
281+
overlay: alpha(Colors.charcoal[90], 0.8),
282+
inverse: Colors.charcoal[10]
283+
},
284+
285+
interactive: {
286+
primary: Colors.KEPPEL,
287+
hover: Colors.keppel[50],
288+
disabled: Colors.charcoal[90],
289+
pressed: Colors.keppel[60],
290+
secondary: Colors.keppel[40],
291+
tertiary: Colors.keppel[70]
292+
},
293+
294+
navigation: {
295+
primary: Colors.charcoal[100],
296+
secondary: Colors.charcoal[90],
297+
active: Colors.KEPPEL,
298+
hover: Colors.keppel[50]
299+
},
300+
196301
primary: {
197302
main: Colors.KEPPEL
198303
},
@@ -305,6 +410,8 @@ export const lightModePalette: PaletteOptions = {
305410
},
306411
icon: {
307412
default: Colors.accentGrey[10],
413+
dualTone: Colors.KEPPEL,
414+
dualToneInverse: Colors.charcoal[10],
308415
secondary: Colors.charcoal[40],
309416
brand: Colors.keppel[40],
310417
inverse: Colors.charcoal[100],
@@ -318,6 +425,32 @@ export const lightModePalette: PaletteOptions = {
318425
};
319426

320427
export const darkModePalette: PaletteOptions = {
428+
429+
surface: {
430+
primary: Colors.charcoal[10],
431+
secondary: Colors.charcoal[20],
432+
tertiary: Colors.charcoal[30],
433+
elevated: Colors.charcoal[40],
434+
overlay: alpha(Colors.charcoal[20], 0.8),
435+
tint: Colors.charcoal[50],
436+
inverse: Colors.WHITE
437+
},
438+
interactive: {
439+
primary: Colors.KEPPEL,
440+
hover: Colors.keppel[50],
441+
disabled: Colors.charcoal[30],
442+
pressed: Colors.keppel[60],
443+
secondary: Colors.keppel[20],
444+
tertiary: Colors.keppel[10]
445+
},
446+
447+
navigation: {
448+
primary: Colors.charcoal[10],
449+
secondary: Colors.charcoal[20],
450+
active: Colors.KEPPEL,
451+
hover: Colors.keppel[50]
452+
},
453+
321454
primary: {
322455
main: Colors.KEPPEL
323456
},
@@ -430,6 +563,8 @@ export const darkModePalette: PaletteOptions = {
430563
icon: {
431564
default: Colors.charcoal[80],
432565
secondary: Colors.charcoal[70],
566+
dualTone: Colors.KEPPEL,
567+
dualToneInverse: Colors.charcoal[100],
433568
brand: Colors.keppel[40],
434569
inverse: Colors.charcoal[10],
435570
weather: Colors.saffron[40],

0 commit comments

Comments
 (0)