@fluentui-react-native/win32-theme 0.25.6 → 0.25.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +16 -1
- package/CHANGELOG.md +10 -2
- package/lib/NativeModule/getThemingModule.native.d.ts.map +1 -1
- package/lib/NativeModule/getThemingModule.native.js +8 -0
- package/lib/NativeModule/getThemingModule.native.js.map +1 -1
- package/lib/NativeModule/hostThemeSetting.d.ts +3 -0
- package/lib/NativeModule/hostThemeSetting.d.ts.map +1 -0
- package/lib/NativeModule/hostThemeSetting.js +20 -0
- package/lib/NativeModule/hostThemeSetting.js.map +1 -0
- package/lib/__tests__/win32-theme.test.js +3 -0
- package/lib/__tests__/win32-theme.test.js.map +1 -1
- package/lib/createOfficeTheme.d.ts.map +1 -1
- package/lib/createOfficeTheme.js +3 -1
- package/lib/createOfficeTheme.js.map +1 -1
- package/lib-commonjs/NativeModule/getThemingModule.native.d.ts.map +1 -1
- package/lib-commonjs/NativeModule/getThemingModule.native.js +8 -0
- package/lib-commonjs/NativeModule/getThemingModule.native.js.map +1 -1
- package/lib-commonjs/NativeModule/hostThemeSetting.d.ts +3 -0
- package/lib-commonjs/NativeModule/hostThemeSetting.d.ts.map +1 -0
- package/lib-commonjs/NativeModule/hostThemeSetting.js +25 -0
- package/lib-commonjs/NativeModule/hostThemeSetting.js.map +1 -0
- package/lib-commonjs/__tests__/win32-theme.test.js +3 -0
- package/lib-commonjs/__tests__/win32-theme.test.js.map +1 -1
- package/lib-commonjs/createOfficeTheme.d.ts.map +1 -1
- package/lib-commonjs/createOfficeTheme.js +3 -1
- package/lib-commonjs/createOfficeTheme.js.map +1 -1
- package/package.json +1 -1
- package/src/NativeModule/getThemingModule.native.ts +9 -0
- package/src/NativeModule/hostThemeSetting.ts +22 -0
- package/src/__tests__/__snapshots__/win32-theme.test.ts.snap +13 -12
- package/src/__tests__/win32-theme.test.ts +3 -0
- package/src/createOfficeTheme.ts +3 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/win32-theme",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 16 Mar 2023 21:46:27 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/win32-theme_v0.25.7",
|
|
7
|
+
"version": "0.25.7",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "ruaraki@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/win32-theme",
|
|
13
|
+
"commit": "124fa9e36989035c4ebb848de1c727b0893eaceb",
|
|
14
|
+
"comment": "Have a way to query theme state over multiple instances of the win32 theme"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Tue, 14 Mar 2023 20:50:45 GMT",
|
|
6
21
|
"tag": "@fluentui-react-native/win32-theme_v0.25.6",
|
|
7
22
|
"version": "0.25.6",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/win32-theme
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 16 Mar 2023 21:46:27 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.25.7
|
|
8
|
+
|
|
9
|
+
Thu, 16 Mar 2023 21:46:27 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Have a way to query theme state over multiple instances of the win32 theme (ruaraki@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.25.6
|
|
8
16
|
|
|
9
|
-
Tue, 14 Mar 2023 20:
|
|
17
|
+
Tue, 14 Mar 2023 20:50:45 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getThemingModule.native.d.ts","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"getThemingModule.native.d.ts","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,cAAc,CAAC;AAIvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAejE,wBAAgB,gBAAgB,IAAI,CAAC,mBAAmB,EAAE,kBAAkB,GAAG,SAAS,CAAC,CAgBxF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { NativeEventEmitter, TurboModuleRegistry } from 'react-native';
|
|
3
3
|
import { fallbackGetPalette, fallbackOfficeModule } from './fallbackOfficeModule';
|
|
4
|
+
import { setCurrentHostThemeSetting } from './hostThemeSetting';
|
|
4
5
|
function disableGetPalette() {
|
|
5
6
|
var disabled = __DEV__ && navigator && navigator.userAgent !== undefined;
|
|
6
7
|
disabled && console.warn(console.warn('Web Debugging forces Theming Native Module to fallback to fake color values.'));
|
|
@@ -10,10 +11,17 @@ export function getThemingModule() {
|
|
|
10
11
|
var module = TurboModuleRegistry.get('Theming');
|
|
11
12
|
// if the native module exists return the module + an emitter for it
|
|
12
13
|
if (module) {
|
|
14
|
+
if (!isInstantiated) {
|
|
15
|
+
// We need to store the host theme so that when themes are created
|
|
16
|
+
// they can use this information.
|
|
17
|
+
setCurrentHostThemeSetting(module.initialHostThemeSetting);
|
|
18
|
+
isInstantiated = true;
|
|
19
|
+
}
|
|
13
20
|
// mock getPalette if it should be disabled, otherwise return the module directly
|
|
14
21
|
return [disableGetPalette() ? __assign(__assign({}, module), { getPalette: fallbackGetPalette }) : module, new NativeEventEmitter(module)];
|
|
15
22
|
}
|
|
16
23
|
// otherwise use the fallback module
|
|
17
24
|
return [fallbackOfficeModule, undefined];
|
|
18
25
|
}
|
|
26
|
+
var isInstantiated = false;
|
|
19
27
|
//# sourceMappingURL=getThemingModule.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getThemingModule.native.js","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"getThemingModule.native.js","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAUhE,SAAS,iBAAiB;IACxB,IAAM,QAAQ,GAAG,OAAO,IAAI,SAAS,IAAI,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC;IAC3E,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC,CAAC;IACvH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAuB,SAAS,CAAC,CAAC;IACxE,oEAAoE;IACpE,IAAI,MAAM,EAAE;QACV,IAAI,CAAC,cAAc,EAAE;YACnB,kEAAkE;YAClE,iCAAiC;YACjC,0BAA0B,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;YAC3D,cAAc,GAAG,IAAI,CAAC;SACvB;QACD,iFAAiF;QACjF,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,uBAAM,MAAM,KAAE,UAAU,EAAE,kBAAkB,IAAG,CAAC,CAAC,MAAM,EAAE,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;KACvH;IAED,oCAAoC;IACpC,OAAO,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED,IAAI,cAAc,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostThemeSetting.d.ts","sourceRoot":"","sources":["../../src/NativeModule/hostThemeSetting.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,0BAA0B,cAMtC,CAAC;AAEF,eAAO,MAAM,0BAA0B,wBAAyB,MAAM,SAErE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The ThemingModule currently only stores its initial host theme state
|
|
2
|
+
// This state is never updated (it's a constant on the native module)
|
|
3
|
+
// This can cause issues if the host theme has changed and you want to
|
|
4
|
+
// query for the current state of the host theme. (i.e. you're spinning up
|
|
5
|
+
// a new instance of a theme and don't have something already keeping track
|
|
6
|
+
// of changes to the theme).
|
|
7
|
+
// Unfortunately, native changes take a long time to roundtrip,
|
|
8
|
+
// so as a workaround we store a copy of that information instead to last the
|
|
9
|
+
// entire lifetime of the instance.
|
|
10
|
+
var currentHostThemeSetting = '';
|
|
11
|
+
export var getCurrentHostThemeSetting = function () {
|
|
12
|
+
if (currentHostThemeSetting.length === 0) {
|
|
13
|
+
throw new Error('Host theme was never set');
|
|
14
|
+
}
|
|
15
|
+
return currentHostThemeSetting;
|
|
16
|
+
};
|
|
17
|
+
export var setCurrentHostThemeSetting = function (newHostThemeSetting) {
|
|
18
|
+
currentHostThemeSetting = newHostThemeSetting;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=hostThemeSetting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostThemeSetting.js","sourceRoot":"","sources":["../../src/NativeModule/hostThemeSetting.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,qEAAqE;AACrE,sEAAsE;AACtE,0EAA0E;AAC1E,2EAA2E;AAC3E,4BAA4B;AAC5B,+DAA+D;AAC/D,6EAA6E;AAC7E,mCAAmC;AACnC,IAAI,uBAAuB,GAAW,EAAE,CAAC;AAEzC,MAAM,CAAC,IAAM,0BAA0B,GAAG;IACxC,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAC,mBAA2B;IACpE,uBAAuB,GAAG,mBAAmB,CAAC;AAChD,CAAC,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { createOfficeColorAliasTokens, createOfficeShadowAliasTokens } from '../
|
|
|
5
5
|
import { createOfficeTheme } from '../createOfficeTheme';
|
|
6
6
|
import { createPartialOfficeTheme } from '../createPartialOfficeTheme';
|
|
7
7
|
import { win32Typography } from '../getThemeTypography';
|
|
8
|
+
import { setCurrentHostThemeSetting } from '../NativeModule/hostThemeSetting';
|
|
8
9
|
import { fallbackGetPalette, fallbackOfficeModule, getThemingModule } from '../NativeModule/index';
|
|
9
10
|
var officeThemes = ['White', 'Colorful', 'DarkGray', 'Black', 'HighContrast'];
|
|
10
11
|
var appPrimaries = ['#185abd', '#107c41', '#d83b01', '#80397b', '#0078d4', '#c43e1c'];
|
|
@@ -28,12 +29,14 @@ it('createFontAliasTokens test', function () {
|
|
|
28
29
|
expect(fontAliasToken).toMatchSnapshot();
|
|
29
30
|
});
|
|
30
31
|
it('createOfficeTheme test', function () {
|
|
32
|
+
setCurrentHostThemeSetting('White');
|
|
31
33
|
var officeTheme = createOfficeTheme({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
32
34
|
expect(officeTheme).toMatchSnapshot();
|
|
33
35
|
});
|
|
34
36
|
it.concurrent.each(officeThemes)('createBrandedThemeWithAlias test themeName: %s', function (themeName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
35
37
|
var officeTheme, brandedTheme;
|
|
36
38
|
return __generator(this, function (_a) {
|
|
39
|
+
setCurrentHostThemeSetting('Colorful');
|
|
37
40
|
officeTheme = createOfficeTheme({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
38
41
|
brandedTheme = createBrandedThemeWithAlias(themeName, officeTheme);
|
|
39
42
|
expect(brandedTheme).toMatchSnapshot();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"win32-theme.test.js","sourceRoot":"","sources":["../../src/__tests__/win32-theme.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEnG,IAAM,YAAY,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;AAChF,IAAM,YAAY,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAExF,EAAE,CAAC,sBAAsB,EAAE;IACzB,MAAM,CAAC,eAAe,CAAC,CAAC,eAAe,EAAE,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,EAAE,C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8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"createOfficeTheme.d.ts","sourceRoot":"","sources":["../src/createOfficeTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAgB7F;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,YAAiB,GAAG,cAAc,CAyD5E"}
|
package/lib/createOfficeTheme.js
CHANGED
|
@@ -7,6 +7,7 @@ import { createOfficeColorAliasTokens, createOfficeShadowAliasTokens } from './c
|
|
|
7
7
|
import { createPartialOfficeTheme } from './createPartialOfficeTheme';
|
|
8
8
|
import { win32Typography } from './getThemeTypography';
|
|
9
9
|
import { getThemingModule } from './NativeModule/getThemingModule';
|
|
10
|
+
import { getCurrentHostThemeSetting, setCurrentHostThemeSetting } from './NativeModule/hostThemeSetting';
|
|
10
11
|
function handlePaletteCall(palette) {
|
|
11
12
|
var exception = palette;
|
|
12
13
|
return exception && exception.message !== undefined ? undefined : palette;
|
|
@@ -23,7 +24,7 @@ function handlePaletteCall(palette) {
|
|
|
23
24
|
export function createOfficeTheme(options) {
|
|
24
25
|
if (options === void 0) { options = {}; }
|
|
25
26
|
var _a = getThemingModule(), module = _a[0], emitter = _a[1];
|
|
26
|
-
var ref = { module: module, emitter: emitter, themeName:
|
|
27
|
+
var ref = { module: module, emitter: emitter, themeName: getCurrentHostThemeSetting() || '' };
|
|
27
28
|
var paletteName = options.paletteName;
|
|
28
29
|
var themeRef = new ThemeReference(createDefaultTheme(options), function () {
|
|
29
30
|
var name = paletteName || 'WhiteColors';
|
|
@@ -59,6 +60,7 @@ export function createOfficeTheme(options) {
|
|
|
59
60
|
// set up the callback for theme changes on the native side
|
|
60
61
|
var onPlatformDefaultsChanged = function (args) {
|
|
61
62
|
ref.themeName = (args && args.hostThemeSetting) || ref.themeName;
|
|
63
|
+
setCurrentHostThemeSetting(ref.themeName);
|
|
62
64
|
themeRef.invalidate();
|
|
63
65
|
};
|
|
64
66
|
emitter && emitter.addListener('onPlatformDefaultsChanged', onPlatformDefaultsChanged);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOfficeTheme.js","sourceRoot":"","sources":["../src/createOfficeTheme.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"createOfficeTheme.js","sourceRoot":"","sources":["../src/createOfficeTheme.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAA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,EAAE;YAC1C,OAAO,EAAE,CAAC;SACX;QAED,OAAO;YACL,MAAM,eAAO,4BAA4B,CAAC,GAAG,CAAC,SAAS,CAAC,CAAE;YAC1D,UAAU,EAAE,eAAe,EAAE;SAC9B,CAAC;IACJ,CAAC,EACD,UAAC,KAAY;QACX,OAAO,2BAA2B,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC,EACD,UAAC,KAAY;QACX,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE;YACvB,OAAO,EAAE,CAAC;SACX;QAED,OAAO;YACL,MAAM,EAAE,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,KAAK,cAAc,CAAC;YACtF,UAAU,EAAE,eAAe,EAAE;SAC9B,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,2DAA2D;IAC3D,IAAM,yBAAyB,GAAG,UAAC,IAAiC;QAClE,GAAG,CAAC,SAAS,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC;QACjE,0BAA0B,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC1C,QAAQ,CAAC,UAAU,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,2BAA2B,EAAE,yBAAyB,CAAC,CAAC;IAEvF,iCAAiC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getThemingModule.native.d.ts","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"getThemingModule.native.d.ts","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,cAAc,CAAC;AAIvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAejE,wBAAgB,gBAAgB,IAAI,CAAC,mBAAmB,EAAE,kBAAkB,GAAG,SAAS,CAAC,CAgBxF"}
|
|
@@ -4,6 +4,7 @@ exports.getThemingModule = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_native_1 = require("react-native");
|
|
6
6
|
var fallbackOfficeModule_1 = require("./fallbackOfficeModule");
|
|
7
|
+
var hostThemeSetting_1 = require("./hostThemeSetting");
|
|
7
8
|
function disableGetPalette() {
|
|
8
9
|
var disabled = __DEV__ && navigator && navigator.userAgent !== undefined;
|
|
9
10
|
disabled && console.warn(console.warn('Web Debugging forces Theming Native Module to fallback to fake color values.'));
|
|
@@ -13,6 +14,12 @@ function getThemingModule() {
|
|
|
13
14
|
var module = react_native_1.TurboModuleRegistry.get('Theming');
|
|
14
15
|
// if the native module exists return the module + an emitter for it
|
|
15
16
|
if (module) {
|
|
17
|
+
if (!isInstantiated) {
|
|
18
|
+
// We need to store the host theme so that when themes are created
|
|
19
|
+
// they can use this information.
|
|
20
|
+
(0, hostThemeSetting_1.setCurrentHostThemeSetting)(module.initialHostThemeSetting);
|
|
21
|
+
isInstantiated = true;
|
|
22
|
+
}
|
|
16
23
|
// mock getPalette if it should be disabled, otherwise return the module directly
|
|
17
24
|
return [disableGetPalette() ? tslib_1.__assign(tslib_1.__assign({}, module), { getPalette: fallbackOfficeModule_1.fallbackGetPalette }) : module, new react_native_1.NativeEventEmitter(module)];
|
|
18
25
|
}
|
|
@@ -20,4 +27,5 @@ function getThemingModule() {
|
|
|
20
27
|
return [fallbackOfficeModule_1.fallbackOfficeModule, undefined];
|
|
21
28
|
}
|
|
22
29
|
exports.getThemingModule = getThemingModule;
|
|
30
|
+
var isInstantiated = false;
|
|
23
31
|
//# sourceMappingURL=getThemingModule.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getThemingModule.native.js","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":";;;;AACA,6CAAuE;AAEvE,+DAAkF;
|
|
1
|
+
{"version":3,"file":"getThemingModule.native.js","sourceRoot":"","sources":["../../src/NativeModule/getThemingModule.native.ts"],"names":[],"mappings":";;;;AACA,6CAAuE;AAEvE,+DAAkF;AAClF,uDAAgE;AAUhE,SAAS,iBAAiB;IACxB,IAAM,QAAQ,GAAG,OAAO,IAAI,SAAS,IAAI,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC;IAC3E,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC,CAAC;IACvH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,gBAAgB;IAC9B,IAAM,MAAM,GAAG,kCAAmB,CAAC,GAAG,CAAuB,SAAS,CAAC,CAAC;IACxE,oEAAoE;IACpE,IAAI,MAAM,EAAE;QACV,IAAI,CAAC,cAAc,EAAE;YACnB,kEAAkE;YAClE,iCAAiC;YACjC,IAAA,6CAA0B,EAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;YAC3D,cAAc,GAAG,IAAI,CAAC;SACvB;QACD,iFAAiF;QACjF,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,uCAAM,MAAM,KAAE,UAAU,EAAE,yCAAkB,IAAG,CAAC,CAAC,MAAM,EAAE,IAAI,iCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;KACvH;IAED,oCAAoC;IACpC,OAAO,CAAC,2CAAoB,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC;AAhBD,4CAgBC;AAED,IAAI,cAAc,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostThemeSetting.d.ts","sourceRoot":"","sources":["../../src/NativeModule/hostThemeSetting.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,0BAA0B,cAMtC,CAAC;AAEF,eAAO,MAAM,0BAA0B,wBAAyB,MAAM,SAErE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setCurrentHostThemeSetting = exports.getCurrentHostThemeSetting = void 0;
|
|
4
|
+
// The ThemingModule currently only stores its initial host theme state
|
|
5
|
+
// This state is never updated (it's a constant on the native module)
|
|
6
|
+
// This can cause issues if the host theme has changed and you want to
|
|
7
|
+
// query for the current state of the host theme. (i.e. you're spinning up
|
|
8
|
+
// a new instance of a theme and don't have something already keeping track
|
|
9
|
+
// of changes to the theme).
|
|
10
|
+
// Unfortunately, native changes take a long time to roundtrip,
|
|
11
|
+
// so as a workaround we store a copy of that information instead to last the
|
|
12
|
+
// entire lifetime of the instance.
|
|
13
|
+
var currentHostThemeSetting = '';
|
|
14
|
+
var getCurrentHostThemeSetting = function () {
|
|
15
|
+
if (currentHostThemeSetting.length === 0) {
|
|
16
|
+
throw new Error('Host theme was never set');
|
|
17
|
+
}
|
|
18
|
+
return currentHostThemeSetting;
|
|
19
|
+
};
|
|
20
|
+
exports.getCurrentHostThemeSetting = getCurrentHostThemeSetting;
|
|
21
|
+
var setCurrentHostThemeSetting = function (newHostThemeSetting) {
|
|
22
|
+
currentHostThemeSetting = newHostThemeSetting;
|
|
23
|
+
};
|
|
24
|
+
exports.setCurrentHostThemeSetting = setCurrentHostThemeSetting;
|
|
25
|
+
//# sourceMappingURL=hostThemeSetting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostThemeSetting.js","sourceRoot":"","sources":["../../src/NativeModule/hostThemeSetting.ts"],"names":[],"mappings":";;;AAAA,uEAAuE;AACvE,qEAAqE;AACrE,sEAAsE;AACtE,0EAA0E;AAC1E,2EAA2E;AAC3E,4BAA4B;AAC5B,+DAA+D;AAC/D,6EAA6E;AAC7E,mCAAmC;AACnC,IAAI,uBAAuB,GAAW,EAAE,CAAC;AAElC,IAAM,0BAA0B,GAAG;IACxC,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC,CAAC;AANW,QAAA,0BAA0B,8BAMrC;AAEK,IAAM,0BAA0B,GAAG,UAAC,mBAA2B;IACpE,uBAAuB,GAAG,mBAAmB,CAAC;AAChD,CAAC,CAAC;AAFW,QAAA,0BAA0B,8BAErC"}
|
|
@@ -7,6 +7,7 @@ var createOfficeAliasTokens_1 = require("../createOfficeAliasTokens");
|
|
|
7
7
|
var createOfficeTheme_1 = require("../createOfficeTheme");
|
|
8
8
|
var createPartialOfficeTheme_1 = require("../createPartialOfficeTheme");
|
|
9
9
|
var getThemeTypography_1 = require("../getThemeTypography");
|
|
10
|
+
var hostThemeSetting_1 = require("../NativeModule/hostThemeSetting");
|
|
10
11
|
var index_1 = require("../NativeModule/index");
|
|
11
12
|
var officeThemes = ['White', 'Colorful', 'DarkGray', 'Black', 'HighContrast'];
|
|
12
13
|
var appPrimaries = ['#185abd', '#107c41', '#d83b01', '#80397b', '#0078d4', '#c43e1c'];
|
|
@@ -30,12 +31,14 @@ it('createFontAliasTokens test', function () {
|
|
|
30
31
|
expect(fontAliasToken).toMatchSnapshot();
|
|
31
32
|
});
|
|
32
33
|
it('createOfficeTheme test', function () {
|
|
34
|
+
(0, hostThemeSetting_1.setCurrentHostThemeSetting)('White');
|
|
33
35
|
var officeTheme = (0, createOfficeTheme_1.createOfficeTheme)({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
34
36
|
expect(officeTheme).toMatchSnapshot();
|
|
35
37
|
});
|
|
36
38
|
it.concurrent.each(officeThemes)('createBrandedThemeWithAlias test themeName: %s', function (themeName) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
37
39
|
var officeTheme, brandedTheme;
|
|
38
40
|
return tslib_1.__generator(this, function (_a) {
|
|
41
|
+
(0, hostThemeSetting_1.setCurrentHostThemeSetting)('Colorful');
|
|
39
42
|
officeTheme = (0, createOfficeTheme_1.createOfficeTheme)({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
40
43
|
brandedTheme = (0, createBrandedThemeWithAlias_1.createBrandedThemeWithAlias)(themeName, officeTheme);
|
|
41
44
|
expect(brandedTheme).toMatchSnapshot();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"win32-theme.test.js","sourceRoot":"","sources":["../../src/__tests__/win32-theme.test.ts"],"names":[],"mappings":";;;AAAA,8EAAyG;AACzG,kEAAiE;AACjE,sEAAyG;AACzG,0DAAyD;AACzD,wEAAuE;AACvE,4DAAwD;AACxD,+CAAmG;AAEnG,IAAM,YAAY,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;AAChF,IAAM,YAAY,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAExF,EAAE,CAAC,sBAAsB,EAAE;IACzB,MAAM,CAAC,oCAAe,CAAC,CAAC,eAAe,EAAE,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,2BAA2B,EAAE;IAC9B,MAAM,CAAC,4BAAoB,CAAC,CAAC,eAAe,EAAE,CAAC;AACjD,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,uBAAuB,EAAE;IAC1B,IAAM,aAAa,GAAG,IAAA,wBAAgB,GAAE,CAAC;IACzC,MAAM,CAAC,aAAa,CAAC,CAAC,eAAe,EAAE,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,+BAA+B,EAAE;IAClC,IAAM,aAAa,GAAG,IAAA,wBAAgB,GAAE,CAAC;IACzC,IAAM,kBAAkB,GAAG,IAAA,mDAAwB,EAAC,aAAa,CAAC,C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UAAO,UAAkB;;;YACzF,gBAAgB,GAAG,IAAA,wDAA0B,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAC5E,MAAM,CAAC,gBAAgB,CAAC,CAAC,eAAe,EAAE,CAAC;;;SAC5C,CAAC,CAAC;IAEH,sFAAsF;IACtF,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,iCAAiC,EAAE,UAAO,UAAkB;;;YACrF,gBAAgB,GAAG,IAAA,wDAA0B,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YACtE,MAAM,CAAC,gBAAgB,CAAC,CAAC,eAAe,EAAE,CAAC;;;SAC5C,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOfficeTheme.d.ts","sourceRoot":"","sources":["../src/createOfficeTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"createOfficeTheme.d.ts","sourceRoot":"","sources":["../src/createOfficeTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAgB7F;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,YAAiB,GAAG,cAAc,CAyD5E"}
|
|
@@ -10,6 +10,7 @@ var createOfficeAliasTokens_1 = require("./createOfficeAliasTokens");
|
|
|
10
10
|
var createPartialOfficeTheme_1 = require("./createPartialOfficeTheme");
|
|
11
11
|
var getThemeTypography_1 = require("./getThemeTypography");
|
|
12
12
|
var getThemingModule_1 = require("./NativeModule/getThemingModule");
|
|
13
|
+
var hostThemeSetting_1 = require("./NativeModule/hostThemeSetting");
|
|
13
14
|
function handlePaletteCall(palette) {
|
|
14
15
|
var exception = palette;
|
|
15
16
|
return exception && exception.message !== undefined ? undefined : palette;
|
|
@@ -26,7 +27,7 @@ function handlePaletteCall(palette) {
|
|
|
26
27
|
function createOfficeTheme(options) {
|
|
27
28
|
if (options === void 0) { options = {}; }
|
|
28
29
|
var _a = (0, getThemingModule_1.getThemingModule)(), module = _a[0], emitter = _a[1];
|
|
29
|
-
var ref = { module: module, emitter: emitter, themeName:
|
|
30
|
+
var ref = { module: module, emitter: emitter, themeName: (0, hostThemeSetting_1.getCurrentHostThemeSetting)() || '' };
|
|
30
31
|
var paletteName = options.paletteName;
|
|
31
32
|
var themeRef = new theme_1.ThemeReference((0, default_theme_1.createDefaultTheme)(options), function () {
|
|
32
33
|
var name = paletteName || 'WhiteColors';
|
|
@@ -62,6 +63,7 @@ function createOfficeTheme(options) {
|
|
|
62
63
|
// set up the callback for theme changes on the native side
|
|
63
64
|
var onPlatformDefaultsChanged = function (args) {
|
|
64
65
|
ref.themeName = (args && args.hostThemeSetting) || ref.themeName;
|
|
66
|
+
(0, hostThemeSetting_1.setCurrentHostThemeSetting)(ref.themeName);
|
|
65
67
|
themeRef.invalidate();
|
|
66
68
|
};
|
|
67
69
|
emitter && emitter.addListener('onPlatformDefaultsChanged', onPlatformDefaultsChanged);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOfficeTheme.js","sourceRoot":"","sources":["../src/createOfficeTheme.ts"],"names":[],"mappings":";;;;AAAA,sEAA0E;AAC1E,sDAA8D;AAG9D,uEAAsE;AACtE,6EAA4E;AAC5E,qEAAwG;AACxG,uEAAsE;AACtE,2DAAuD;AACvD,oEAAmE;
|
|
1
|
+
{"version":3,"file":"createOfficeTheme.js","sourceRoot":"","sources":["../src/createOfficeTheme.ts"],"names":[],"mappings":";;;;AAAA,sEAA0E;AAC1E,sDAA8D;AAG9D,uEAAsE;AACtE,6EAA4E;AAC5E,qEAAwG;AACxG,uEAAsE;AACtE,2DAAuD;AACvD,oEAA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E,CAAC;SACX;QAED,OAAO;YACL,MAAM,uBAAO,IAAA,sDAA4B,EAAC,GAAG,CAAC,SAAS,CAAC,CAAE;YAC1D,UAAU,EAAE,IAAA,oCAAe,GAAE;SAC9B,CAAC;IACJ,CAAC,EACD,UAAC,KAAY;QACX,OAAO,IAAA,yDAA2B,EAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC,EACD,UAAC,KAAY;QACX,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE;YACvB,OAAO,EAAE,CAAC;SACX;QAED,OAAO;YACL,MAAM,EAAE,IAAA,mDAAwB,EAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,KAAK,cAAc,CAAC;YACtF,UAAU,EAAE,IAAA,oCAAe,GAAE;SAC9B,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,2DAA2D;IAC3D,IAAM,yBAAyB,GAAG,UAAC,IAAiC;QAClE,GAAG,CAAC,SAAS,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC;QACjE,IAAA,6CAA0B,EAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC1C,QAAQ,CAAC,UAAU,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,2BAA2B,EAAE,yBAAyB,CAAC,CAAC;IAEvF,iCAAiC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAzDD,8CAyDC"}
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import type { EventSubscriptionVendor, TurboModule } from 'react-native';
|
|
|
2
2
|
import { NativeEventEmitter, TurboModuleRegistry } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { fallbackGetPalette, fallbackOfficeModule } from './fallbackOfficeModule';
|
|
5
|
+
import { setCurrentHostThemeSetting } from './hostThemeSetting';
|
|
5
6
|
import type { OfficeThemingModule } from './officeThemingModule';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -21,6 +22,12 @@ export function getThemingModule(): [OfficeThemingModule, NativeEventEmitter | u
|
|
|
21
22
|
const module = TurboModuleRegistry.get<ITurboModuleRegistry>('Theming');
|
|
22
23
|
// if the native module exists return the module + an emitter for it
|
|
23
24
|
if (module) {
|
|
25
|
+
if (!isInstantiated) {
|
|
26
|
+
// We need to store the host theme so that when themes are created
|
|
27
|
+
// they can use this information.
|
|
28
|
+
setCurrentHostThemeSetting(module.initialHostThemeSetting);
|
|
29
|
+
isInstantiated = true;
|
|
30
|
+
}
|
|
24
31
|
// mock getPalette if it should be disabled, otherwise return the module directly
|
|
25
32
|
return [disableGetPalette() ? { ...module, getPalette: fallbackGetPalette } : module, new NativeEventEmitter(module)];
|
|
26
33
|
}
|
|
@@ -28,3 +35,5 @@ export function getThemingModule(): [OfficeThemingModule, NativeEventEmitter | u
|
|
|
28
35
|
// otherwise use the fallback module
|
|
29
36
|
return [fallbackOfficeModule, undefined];
|
|
30
37
|
}
|
|
38
|
+
|
|
39
|
+
let isInstantiated = false;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The ThemingModule currently only stores its initial host theme state
|
|
2
|
+
// This state is never updated (it's a constant on the native module)
|
|
3
|
+
// This can cause issues if the host theme has changed and you want to
|
|
4
|
+
// query for the current state of the host theme. (i.e. you're spinning up
|
|
5
|
+
// a new instance of a theme and don't have something already keeping track
|
|
6
|
+
// of changes to the theme).
|
|
7
|
+
// Unfortunately, native changes take a long time to roundtrip,
|
|
8
|
+
// so as a workaround we store a copy of that information instead to last the
|
|
9
|
+
// entire lifetime of the instance.
|
|
10
|
+
let currentHostThemeSetting: string = '';
|
|
11
|
+
|
|
12
|
+
export const getCurrentHostThemeSetting = () => {
|
|
13
|
+
if (currentHostThemeSetting.length === 0) {
|
|
14
|
+
throw new Error('Host theme was never set');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return currentHostThemeSetting;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const setCurrentHostThemeSetting = (newHostThemeSetting: string) => {
|
|
21
|
+
currentHostThemeSetting = newHostThemeSetting;
|
|
22
|
+
};
|
|
@@ -2108,12 +2108,12 @@ Object {
|
|
|
2108
2108
|
"brandBackgroundPressed": "#A22C01",
|
|
2109
2109
|
"brandBackgroundSelected": "#13458f",
|
|
2110
2110
|
"brandBackgroundStatic": "#185abd",
|
|
2111
|
-
"brandForeground1": "#
|
|
2112
|
-
"brandForeground2": "#
|
|
2113
|
-
"brandForegroundLink": "#
|
|
2114
|
-
"brandForegroundLinkHover": "#
|
|
2115
|
-
"brandForegroundLinkPressed": "#
|
|
2116
|
-
"brandForegroundLinkSelected": "#
|
|
2111
|
+
"brandForeground1": "#185abd",
|
|
2112
|
+
"brandForeground2": "#1651aa",
|
|
2113
|
+
"brandForegroundLink": "#185abd",
|
|
2114
|
+
"brandForegroundLinkHover": "#1651aa",
|
|
2115
|
+
"brandForegroundLinkPressed": "#0e336a",
|
|
2116
|
+
"brandForegroundLinkSelected": "#13458f",
|
|
2117
2117
|
"brandStroke1": "#D83B01",
|
|
2118
2118
|
"brandStroke2": "#d2e0f4",
|
|
2119
2119
|
"brandedBackground": "#D83B01",
|
|
@@ -2293,16 +2293,16 @@ Object {
|
|
|
2293
2293
|
"neutralForeground1Pressed": "#262626",
|
|
2294
2294
|
"neutralForeground1Selected": "#262626",
|
|
2295
2295
|
"neutralForeground2": "#666666",
|
|
2296
|
-
"neutralForeground2BrandHover": "#
|
|
2297
|
-
"neutralForeground2BrandPressed": "#
|
|
2298
|
-
"neutralForeground2BrandSelected": "#
|
|
2296
|
+
"neutralForeground2BrandHover": "#1651aa",
|
|
2297
|
+
"neutralForeground2BrandPressed": "#0e336a",
|
|
2298
|
+
"neutralForeground2BrandSelected": "#13458f",
|
|
2299
2299
|
"neutralForeground2Hover": "#505050",
|
|
2300
2300
|
"neutralForeground2Pressed": "#666666",
|
|
2301
2301
|
"neutralForeground2Selected": "#666666",
|
|
2302
2302
|
"neutralForeground3": "#616161",
|
|
2303
|
-
"neutralForeground3BrandHover": "#
|
|
2304
|
-
"neutralForeground3BrandPressed": "#
|
|
2305
|
-
"neutralForeground3BrandSelected": "#
|
|
2303
|
+
"neutralForeground3BrandHover": "#1651aa",
|
|
2304
|
+
"neutralForeground3BrandPressed": "#0e336a",
|
|
2305
|
+
"neutralForeground3BrandSelected": "#13458f",
|
|
2306
2306
|
"neutralForeground3Hover": "#424242",
|
|
2307
2307
|
"neutralForeground3Pressed": "#424242",
|
|
2308
2308
|
"neutralForeground3Selected": "#424242",
|
|
@@ -2532,6 +2532,7 @@ Object {
|
|
|
2532
2532
|
"ThumbToggleSwitchOnPressed": "#FFFFFF",
|
|
2533
2533
|
},
|
|
2534
2534
|
},
|
|
2535
|
+
"name": "White",
|
|
2535
2536
|
"shadows": Object {
|
|
2536
2537
|
"shadow16": Object {
|
|
2537
2538
|
"ambient": Object {
|
|
@@ -4,6 +4,7 @@ import { createOfficeColorAliasTokens, createOfficeShadowAliasTokens } from '../
|
|
|
4
4
|
import { createOfficeTheme } from '../createOfficeTheme';
|
|
5
5
|
import { createPartialOfficeTheme } from '../createPartialOfficeTheme';
|
|
6
6
|
import { win32Typography } from '../getThemeTypography';
|
|
7
|
+
import { setCurrentHostThemeSetting } from '../NativeModule/hostThemeSetting';
|
|
7
8
|
import { fallbackGetPalette, fallbackOfficeModule, getThemingModule } from '../NativeModule/index';
|
|
8
9
|
|
|
9
10
|
const officeThemes = ['White', 'Colorful', 'DarkGray', 'Black', 'HighContrast'];
|
|
@@ -34,11 +35,13 @@ it('createFontAliasTokens test', () => {
|
|
|
34
35
|
});
|
|
35
36
|
|
|
36
37
|
it('createOfficeTheme test', () => {
|
|
38
|
+
setCurrentHostThemeSetting('White');
|
|
37
39
|
const officeTheme = createOfficeTheme({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
38
40
|
expect(officeTheme).toMatchSnapshot();
|
|
39
41
|
});
|
|
40
42
|
|
|
41
43
|
it.concurrent.each(officeThemes)('createBrandedThemeWithAlias test themeName: %s', async (themeName: string) => {
|
|
44
|
+
setCurrentHostThemeSetting('Colorful');
|
|
42
45
|
const officeTheme = createOfficeTheme({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
43
46
|
const brandedTheme = createBrandedThemeWithAlias(themeName, officeTheme);
|
|
44
47
|
expect(brandedTheme).toMatchSnapshot();
|
package/src/createOfficeTheme.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { createOfficeColorAliasTokens, createOfficeShadowAliasTokens } from './c
|
|
|
8
8
|
import { createPartialOfficeTheme } from './createPartialOfficeTheme';
|
|
9
9
|
import { win32Typography } from './getThemeTypography';
|
|
10
10
|
import { getThemingModule } from './NativeModule/getThemingModule';
|
|
11
|
+
import { getCurrentHostThemeSetting, setCurrentHostThemeSetting } from './NativeModule/hostThemeSetting';
|
|
11
12
|
import type { CxxException, PlatformDefaultsChangedArgs } from './NativeModule/officeThemingModule';
|
|
12
13
|
|
|
13
14
|
function handlePaletteCall(palette: OfficePalette | CxxException): OfficePalette | undefined {
|
|
@@ -26,7 +27,7 @@ function handlePaletteCall(palette: OfficePalette | CxxException): OfficePalette
|
|
|
26
27
|
*/
|
|
27
28
|
export function createOfficeTheme(options: ThemeOptions = {}): ThemeReference {
|
|
28
29
|
const [module, emitter] = getThemingModule();
|
|
29
|
-
const ref = { module, emitter, themeName:
|
|
30
|
+
const ref = { module, emitter, themeName: getCurrentHostThemeSetting() || '' };
|
|
30
31
|
const { paletteName } = options;
|
|
31
32
|
|
|
32
33
|
const themeRef = new ThemeReference(
|
|
@@ -74,6 +75,7 @@ export function createOfficeTheme(options: ThemeOptions = {}): ThemeReference {
|
|
|
74
75
|
// set up the callback for theme changes on the native side
|
|
75
76
|
const onPlatformDefaultsChanged = (args: PlatformDefaultsChangedArgs) => {
|
|
76
77
|
ref.themeName = (args && args.hostThemeSetting) || ref.themeName;
|
|
78
|
+
setCurrentHostThemeSetting(ref.themeName);
|
|
77
79
|
themeRef.invalidate();
|
|
78
80
|
};
|
|
79
81
|
emitter && emitter.addListener('onPlatformDefaultsChanged', onPlatformDefaultsChanged);
|