Skip to content

Commit 7d671e3

Browse files
committed
Merge branch 'merge/update-from-main' of github.com:microsoftgraph/microsoft-graph-toolkit into merge/update-from-main
2 parents 78e04ca + f30c20c commit 7d671e3

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

packages/mgt-components/src/styles/theme-manager.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ type ColorScheme = {
5555
* @type {number}
5656
*/
5757
baseLayerLuminance: number;
58+
59+
designTokenOverrides?: Record<string, string>;
5860
};
5961

6062
/**
@@ -67,6 +69,14 @@ const applyColorScheme = (settings: ColorScheme, element: HTMLElement = document
6769
accentBaseColor.setValueFor(element, SwatchRGB.from(parseColorHexRGB(settings.accentBaseColor)));
6870
neutralBaseColor.setValueFor(element, SwatchRGB.from(parseColorHexRGB(settings.neutralBaseColor)));
6971
baseLayerLuminance.setValueFor(element, settings.baseLayerLuminance);
72+
// put this work on the macro queue so that it happens after promise based/reactive work of setting the base colors above
73+
if (settings.designTokenOverrides) {
74+
setTimeout(() => {
75+
Object.entries(settings.designTokenOverrides).forEach(([key, value]) => {
76+
element.style.setProperty(key, value);
77+
});
78+
});
79+
}
7080
};
7181

7282
/**
@@ -93,7 +103,30 @@ const getThemeSettings = (theme: Theme): ColorScheme => {
93103
return {
94104
accentBaseColor: '#479ef5',
95105
neutralBaseColor: '#adadad',
96-
baseLayerLuminance: StandardLuminance.DarkMode
106+
baseLayerLuminance: StandardLuminance.DarkMode,
107+
designTokenOverrides: {
108+
'--accent-fill-rest': '#115ea3',
109+
'--accent-fill-hover': '#0f6cbd',
110+
'--accent-fill-active': '#0c3b5e',
111+
'--accent-fill-focus': '#0f548c',
112+
'--accent-foreground-rest': '#479EF5',
113+
'--accent-foreground-hover': '#62abf5',
114+
'--accent-foreground-active': '#2886de',
115+
'--accent-foreground-focus': '#479ef5',
116+
'--accent-stroke-control-rest': '#115ea3',
117+
'--accent-stroke-control-hover': '#0f6cbd',
118+
'--accent-stroke-control-active': '#0c3b5e',
119+
'--accent-stroke-control-focus': '#0f548c',
120+
// foreground on accents
121+
'--foreground-on-accent-rest': '#ffffff',
122+
'--foreground-on-accent-active': '#ffffff',
123+
'--foreground-on-accent-rest-large': '#ffffff',
124+
'--foreground-on-accent-hover': '#ffffff',
125+
'--foreground-on-accent-hover-large': '#ffffff',
126+
'--foreground-on-accent-active-large': '#ffffff',
127+
'--foreground-on-accent-focus': '#ffffff',
128+
'--foreground-on-accent-focus-large': '#ffffff'
129+
}
97130
};
98131
case 'light':
99132
default:

0 commit comments

Comments
 (0)