@fluentui-react-native/win32-theme 0.39.0 → 0.39.1
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.md +15 -0
- package/lib/NativeModule/_mocks_/getThemingModule.native.d.ts +1 -1
- package/lib/NativeModule/_mocks_/getThemingModule.native.js +2 -2
- package/lib/NativeModule/fallbackOfficeModule.d.ts +1 -1
- package/lib/NativeModule/fallbackOfficeModule.js +163 -163
- package/lib/NativeModule/getThemingModule.d.ts +1 -1
- package/lib/NativeModule/getThemingModule.js +2 -2
- package/lib/NativeModule/getThemingModule.native.d.ts +1 -1
- package/lib/NativeModule/getThemingModule.native.js +30 -28
- package/lib/NativeModule/hostThemeSetting.d.ts +1 -1
- package/lib/NativeModule/hostThemeSetting.js +3 -3
- package/lib/NativeModule/index.d.ts +2 -10
- package/lib/NativeModule/index.js +1 -1
- package/lib/NativeModule/officeThemingModule.d.ts +21 -21
- package/lib/NativeModule/officeThemingModule.js +1 -1
- package/lib/__tests__/win32-theme.test.d.ts +1 -1
- package/lib/__tests__/win32-theme.test.js +47 -47
- package/lib/createAliasesFromPalette.d.ts +1 -1
- package/lib/createAliasesFromPalette.js +56 -56
- package/lib/createBrandedThemeWithAlias.d.ts +1 -1
- package/lib/createBrandedThemeWithAlias.js +61 -56
- package/lib/createFontAliasTokens.d.ts +1 -1
- package/lib/createFontAliasTokens.js +3 -3
- package/lib/createOfficeAliasTokens.d.ts +1 -1
- package/lib/createOfficeAliasTokens.js +5 -5
- package/lib/createOfficeTheme.d.ts +1 -1
- package/lib/createOfficeTheme.js +46 -53
- package/lib/createPartialOfficeTheme.d.ts +1 -1
- package/lib/createPartialOfficeTheme.js +19 -22
- package/lib/getOfficeTokens.d.ts +227 -229
- package/lib/getOfficeTokens.js +26 -20
- package/lib/getThemeTypography.d.ts +1 -1
- package/lib/getThemeTypography.js +32 -32
- package/lib/highContrast/tokens-alias.d.ts +1 -1
- package/lib/highContrast/tokens-alias.js +11 -11
- package/lib/index.d.ts +2 -10
- package/lib/index.js +1 -1
- package/lib/paletteFromOfficeColors.d.ts +1 -1
- package/lib/paletteFromOfficeColors.js +114 -114
- package/lib-commonjs/NativeModule/_mocks_/getThemingModule.native.d.ts +1 -1
- package/lib-commonjs/NativeModule/_mocks_/getThemingModule.native.js +5 -5
- package/lib-commonjs/NativeModule/fallbackOfficeModule.d.ts +1 -1
- package/lib-commonjs/NativeModule/fallbackOfficeModule.js +165 -165
- package/lib-commonjs/NativeModule/getThemingModule.d.ts +1 -1
- package/lib-commonjs/NativeModule/getThemingModule.js +5 -5
- package/lib-commonjs/NativeModule/getThemingModule.native.d.ts +1 -1
- package/lib-commonjs/NativeModule/getThemingModule.native.js +35 -33
- package/lib-commonjs/NativeModule/hostThemeSetting.d.ts +1 -1
- package/lib-commonjs/NativeModule/hostThemeSetting.js +5 -5
- package/lib-commonjs/NativeModule/index.d.ts +2 -10
- package/lib-commonjs/NativeModule/index.js +8 -23
- package/lib-commonjs/NativeModule/officeThemingModule.d.ts +21 -21
- package/lib-commonjs/NativeModule/officeThemingModule.js +3 -3
- package/lib-commonjs/__tests__/win32-theme.test.d.ts +1 -1
- package/lib-commonjs/__tests__/win32-theme.test.js +57 -57
- package/lib-commonjs/createAliasesFromPalette.d.ts +1 -1
- package/lib-commonjs/createAliasesFromPalette.js +58 -58
- package/lib-commonjs/createBrandedThemeWithAlias.d.ts +1 -1
- package/lib-commonjs/createBrandedThemeWithAlias.js +64 -59
- package/lib-commonjs/createFontAliasTokens.d.ts +1 -1
- package/lib-commonjs/createFontAliasTokens.js +8 -8
- package/lib-commonjs/createOfficeAliasTokens.d.ts +1 -1
- package/lib-commonjs/createOfficeAliasTokens.js +10 -10
- package/lib-commonjs/createOfficeTheme.d.ts +1 -1
- package/lib-commonjs/createOfficeTheme.js +57 -66
- package/lib-commonjs/createPartialOfficeTheme.d.ts +1 -1
- package/lib-commonjs/createPartialOfficeTheme.js +22 -25
- package/lib-commonjs/getOfficeTokens.d.ts +227 -229
- package/lib-commonjs/getOfficeTokens.js +39 -35
- package/lib-commonjs/getThemeTypography.d.ts +1 -1
- package/lib-commonjs/getThemeTypography.js +36 -36
- package/lib-commonjs/highContrast/tokens-alias.d.ts +1 -1
- package/lib-commonjs/highContrast/tokens-alias.js +18 -20
- package/lib-commonjs/index.d.ts +2 -10
- package/lib-commonjs/index.js +23 -89
- package/lib-commonjs/paletteFromOfficeColors.d.ts +1 -1
- package/lib-commonjs/paletteFromOfficeColors.js +116 -116
- package/package.json +19 -18
|
@@ -9,71 +9,71 @@ import { fallbackGetPalette, fallbackOfficeModule, getThemingModule } from '../N
|
|
|
9
9
|
const officeThemes = ['White', 'Colorful', 'DarkGray', 'Black', 'HighContrast'];
|
|
10
10
|
const appPrimaries = ['#185abd', '#107c41', '#d83b01', '#80397b', '#0078d4', '#c43e1c'];
|
|
11
11
|
it('win32Typography test', () => {
|
|
12
|
-
|
|
12
|
+
expect(win32Typography).toMatchSnapshot();
|
|
13
13
|
});
|
|
14
14
|
it('fallbackOfficeModule test', () => {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
expect(fallbackOfficeModule).toMatchSnapshot();
|
|
16
|
+
expect(fallbackOfficeModule.getConstants()).toMatchSnapshot();
|
|
17
17
|
});
|
|
18
18
|
it('getThemingModule test', () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const themingModule = getThemingModule();
|
|
20
|
+
expect(themingModule).toMatchSnapshot();
|
|
21
|
+
expect(themingModule[0].getConstants()).toMatchSnapshot();
|
|
22
22
|
});
|
|
23
23
|
it('createPartialOfficeTheme test', () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const themingModule = getThemingModule();
|
|
25
|
+
const partialOfficeTheme = createPartialOfficeTheme(themingModule[0]);
|
|
26
|
+
expect(partialOfficeTheme).toMatchSnapshot;
|
|
27
27
|
});
|
|
28
28
|
it('createFontAliasTokens test', () => {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const fontAliasToken = createFontAliasTokens();
|
|
30
|
+
expect(fontAliasToken).toMatchSnapshot();
|
|
31
31
|
});
|
|
32
32
|
it('createOfficeTheme test', () => {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const officeTheme = createOfficeTheme({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
34
|
+
expect(officeTheme).toMatchSnapshot();
|
|
35
35
|
});
|
|
36
36
|
it.concurrent.each(officeThemes)('createBrandedThemeWithAlias test themeName: %s', async (themeName) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
setCurrentHostThemeSetting('Colorful');
|
|
38
|
+
const officeTheme = createOfficeTheme({ paletteName: 'TaskPane', appearance: 'light' }).theme;
|
|
39
|
+
const brandedTheme = createBrandedThemeWithAlias(themeName, officeTheme);
|
|
40
|
+
expect(brandedTheme).toMatchSnapshot();
|
|
41
41
|
});
|
|
42
42
|
it.concurrent.each(officeThemes)('createOfficeColorAliasTokens test officeTheme: %s', async (themeName) => {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const colorAliasToken = createOfficeColorAliasTokens(themeName);
|
|
44
|
+
expect(colorAliasToken).toMatchSnapshot();
|
|
45
45
|
});
|
|
46
46
|
it.concurrent.each(officeThemes)('createOfficeShadowAliasTokens test officeTheme: %s', async (themeName) => {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const shadowAliasToken = createOfficeShadowAliasTokens(themeName);
|
|
48
|
+
expect(shadowAliasToken).toMatchSnapshot();
|
|
49
49
|
});
|
|
50
50
|
describe('fallbackGetPalette test', () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
it('TaskPane palette', () => {
|
|
52
|
+
const fallbackPalette = fallbackGetPalette('TaskPane');
|
|
53
|
+
expect(fallbackPalette).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
it('Random palette', () => {
|
|
56
|
+
/**
|
|
57
|
+
* RedColors is just a random pallette, we're just testing to see what happens
|
|
58
|
+
* if we use anything other than the TaskPane palette.
|
|
59
|
+
* */
|
|
60
|
+
const fallbackPalette = fallbackGetPalette('RedColors');
|
|
61
|
+
expect(fallbackPalette).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
63
|
});
|
|
64
64
|
describe('getCurrentBrandAliasTokens test', () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
it.concurrent.each(appPrimaries)('themeName: White, appPrimary: %s', async (appPrimary) => {
|
|
66
|
+
const brandAliasTokens = getCurrentBrandAliasTokens('White', appPrimary);
|
|
67
|
+
expect(brandAliasTokens).toMatchSnapshot();
|
|
68
|
+
});
|
|
69
|
+
it.concurrent.each(appPrimaries)('themeName: Colorful, appPrimary: %s', async (appPrimary) => {
|
|
70
|
+
const brandAliasTokens = getCurrentBrandAliasTokens('Colorful', appPrimary);
|
|
71
|
+
expect(brandAliasTokens).toMatchSnapshot();
|
|
72
|
+
});
|
|
73
|
+
// Tests the variation of the alias tokens for when isWhiteOrColorfulTheme is not true
|
|
74
|
+
it.concurrent.each(appPrimaries)('themeName: null, appPrimary: %s', async (appPrimary) => {
|
|
75
|
+
const brandAliasTokens = getCurrentBrandAliasTokens(null, appPrimary);
|
|
76
|
+
expect(brandAliasTokens).toMatchSnapshot();
|
|
77
|
+
});
|
|
78
78
|
});
|
|
79
|
-
//# sourceMappingURL=win32-theme.test.js.map
|
|
79
|
+
//# sourceMappingURL=win32-theme.test.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AliasColorTokens, OfficePalette } from '@fluentui-react-native/theme-types';
|
|
2
2
|
export declare function createAliasesFromPalette(palette: OfficePalette, isHighContrast: boolean): Partial<AliasColorTokens>;
|
|
3
|
-
//# sourceMappingURL=createAliasesFromPalette.d.ts.map
|
|
3
|
+
//# sourceMappingURL=createAliasesFromPalette.d.ts.map
|
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
export function createAliasesFromPalette(palette, isHighContrast) {
|
|
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
|
-
|
|
2
|
+
// Workaround for getting checkmark to have correct color in HC
|
|
3
|
+
// while native code doesn't support PlatformColor
|
|
4
|
+
if (isHighContrast) {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
neutralForeground1: palette.Text,
|
|
9
|
+
neutralForeground1Hover: palette.TextHover,
|
|
10
|
+
neutralForeground1Pressed: palette.TextPressed,
|
|
11
|
+
neutralForeground1Selected: palette.TextSelected,
|
|
12
|
+
neutralForeground2: palette.TextSecondary,
|
|
13
|
+
neutralForeground2Hover: palette.TextSecondaryHover,
|
|
14
|
+
neutralForeground2Pressed: palette.TextSecondaryPressed,
|
|
15
|
+
neutralForeground2Selected: palette.TextSecondarySelected,
|
|
16
|
+
neutralForeground4: palette.TextTextBoxPlaceholder,
|
|
17
|
+
neutralForegroundDisabled: palette.TextDisabled,
|
|
18
|
+
compoundBrandForeground1: palette.TextEmphasis,
|
|
19
|
+
compoundBrandForeground1Hover: palette.TextEmphasisHover,
|
|
20
|
+
compoundBrandForeground1Pressed: palette.TextEmphasisPressed,
|
|
21
|
+
neutralForegroundOnBrand: palette.TextCtlEmphasis,
|
|
22
|
+
neutralForegroundOnBrandHover: palette.TextCtlEmphasisHover,
|
|
23
|
+
neutralForegroundOnBrandPressed: palette.TextCtlEmphasisPressed,
|
|
24
|
+
neutralForegroundInvertedLink: palette.BkgToggleSwitchOff,
|
|
25
|
+
neutralForegroundInvertedLinkHover: palette.BkgToggleSwitchOffHover,
|
|
26
|
+
neutralForegroundInvertedLinkPressed: palette.BkgToggleSwitchOffPressed,
|
|
27
|
+
neutralBackground1: palette.Bkg,
|
|
28
|
+
neutralBackground1Hover: palette.BkgHover,
|
|
29
|
+
neutralBackground1Pressed: palette.BkgPressed,
|
|
30
|
+
neutralBackground1Selected: palette.BkgSelected,
|
|
31
|
+
neutralBackground2: palette.BkgHeader,
|
|
32
|
+
neutralBackground2Hover: palette.BkgSubtle,
|
|
33
|
+
neutralBackground3: palette.BkgSubtle,
|
|
34
|
+
neutralBackgroundInverted: palette.BkgSelectionHighlight,
|
|
35
|
+
neutralBackgroundDisabled: palette.BkgCtlDisabled,
|
|
36
|
+
neutralStencil1: palette.SliderBuffer,
|
|
37
|
+
brandBackground: palette.BkgCtlEmphasis,
|
|
38
|
+
brandBackgroundHover: palette.BkgCtlEmphasisHover,
|
|
39
|
+
brandBackgroundPressed: palette.BkgCtlEmphasisPressed,
|
|
40
|
+
compoundBrandBackground1: palette.BkgToggleSwitchOn,
|
|
41
|
+
compoundBrandBackground1Hover: palette.BkgToggleSwitchOnHover,
|
|
42
|
+
compoundBrandBackground1Pressed: palette.BkgToggleSwitchOnPressed,
|
|
43
|
+
neutralStrokeAccessible: palette.StrokeOnlySelected,
|
|
44
|
+
neutralStrokeAccessibleHover: palette.StrokeOnlyHover,
|
|
45
|
+
neutralStrokeAccessiblePressed: palette.StrokeOnlyPressed,
|
|
46
|
+
neutralStroke1: palette.StrokeCtl,
|
|
47
|
+
neutralStroke1Hover: palette.StrokeSelectedHover,
|
|
48
|
+
neutralStroke1Pressed: palette.StrokeOverPressed,
|
|
49
|
+
neutralStroke2: palette.SliderBuffer,
|
|
50
|
+
brandStroke1: palette.AccentEmphasis,
|
|
51
|
+
compoundBrandStroke1: palette.StrokeToggleSwitchOn,
|
|
52
|
+
compoundBrandStroke1Hover: palette.StrokeToggleSwitchOnHover,
|
|
53
|
+
compoundBrandStroke1Pressed: palette.StrokeToggleSwitchOnPressed,
|
|
54
|
+
neutralStrokeDisabled: palette.StrokeCtlDisabled,
|
|
55
|
+
strokeFocus2: palette.StrokeKeyboard,
|
|
56
|
+
};
|
|
57
57
|
}
|
|
58
|
-
//# sourceMappingURL=createAliasesFromPalette.js.map
|
|
58
|
+
//# sourceMappingURL=createAliasesFromPalette.js.map
|
|
@@ -2,4 +2,4 @@ import type { ColorValue } from 'react-native';
|
|
|
2
2
|
import type { Theme, PartialTheme, AliasColorTokens } from '@fluentui-react-native/theme-types';
|
|
3
3
|
export declare function createBrandedThemeWithAlias(themeName: string, theme: Theme): PartialTheme;
|
|
4
4
|
export declare function getCurrentBrandAliasTokens(themeName: string, appPrimary: ColorValue): Partial<AliasColorTokens>;
|
|
5
|
-
//# sourceMappingURL=createBrandedThemeWithAlias.d.ts.map
|
|
5
|
+
//# sourceMappingURL=createBrandedThemeWithAlias.d.ts.map
|
|
@@ -1,64 +1,69 @@
|
|
|
1
1
|
import { globalTokens } from '@fluentui-react-native/theme-tokens';
|
|
2
2
|
export function createBrandedThemeWithAlias(themeName, theme) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
if (themeName === 'HighContrast' || !theme.host.colors) {
|
|
4
|
+
return {};
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
colors: getCurrentBrandAliasTokens(themeName, theme.host.colors.AppPrimary),
|
|
8
|
+
};
|
|
9
9
|
}
|
|
10
10
|
export function getCurrentBrandAliasTokens(themeName, appPrimary) {
|
|
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
|
-
|
|
11
|
+
const appColors = getAppColors(appPrimary);
|
|
12
|
+
const isWhiteOrColorfulTheme = themeName === 'White' || themeName === 'Colorful';
|
|
13
|
+
return {
|
|
14
|
+
neutralForeground2BrandHover: isWhiteOrColorfulTheme ? appColors.shade10 : appColors.tint40,
|
|
15
|
+
neutralForeground2BrandPressed: isWhiteOrColorfulTheme ? appColors.shade30 : appColors.tint10,
|
|
16
|
+
neutralForeground2BrandSelected: isWhiteOrColorfulTheme ? appColors.shade20 : appColors.tint40,
|
|
17
|
+
neutralForeground3BrandHover: isWhiteOrColorfulTheme ? appColors.shade10 : appColors.tint40,
|
|
18
|
+
neutralForeground3BrandPressed: isWhiteOrColorfulTheme ? appColors.shade30 : appColors.tint10,
|
|
19
|
+
neutralForeground3BrandSelected: isWhiteOrColorfulTheme ? appColors.shade20 : appColors.tint40,
|
|
20
|
+
brandForegroundLink: isWhiteOrColorfulTheme ? appColors.primary : appColors.tint30,
|
|
21
|
+
brandForegroundLinkHover: isWhiteOrColorfulTheme ? appColors.shade10 : appColors.tint40,
|
|
22
|
+
brandForegroundLinkPressed: isWhiteOrColorfulTheme ? appColors.shade30 : appColors.tint10,
|
|
23
|
+
brandForegroundLinkSelected: isWhiteOrColorfulTheme ? appColors.shade20 : appColors.tint40,
|
|
24
|
+
compoundBrandForeground1: isWhiteOrColorfulTheme ? appColors.primary : appColors.tint30,
|
|
25
|
+
compoundBrandForeground1Hover: isWhiteOrColorfulTheme ? appColors.shade10 : appColors.tint40,
|
|
26
|
+
compoundBrandForeground1Pressed: isWhiteOrColorfulTheme ? appColors.shade30 : appColors.tint10,
|
|
27
|
+
brandForeground1: isWhiteOrColorfulTheme ? appColors.primary : appColors.tint30,
|
|
28
|
+
brandForeground2: isWhiteOrColorfulTheme ? appColors.shade10 : appColors.tint40,
|
|
29
|
+
brandBackground: appColors.primary,
|
|
30
|
+
brandBackgroundHover: appColors.shade10,
|
|
31
|
+
brandBackgroundPressed: appColors.shade30,
|
|
32
|
+
brandBackgroundSelected: appColors.shade20,
|
|
33
|
+
compoundBrandBackground1: appColors.primary,
|
|
34
|
+
compoundBrandBackground1Hover: appColors.shade10,
|
|
35
|
+
compoundBrandBackground1Pressed: appColors.shade20,
|
|
36
|
+
brandBackgroundStatic: appColors.primary,
|
|
37
|
+
brandBackground2: appColors.tint40,
|
|
38
|
+
neutralStrokeAccessibleSelected: appColors.primary,
|
|
39
|
+
brandStroke1: appColors.primary,
|
|
40
|
+
brandStroke2: appColors.tint40,
|
|
41
|
+
compoundBrandStroke1: appColors.primary,
|
|
42
|
+
compoundBrandStroke1Hover: appColors.shade10,
|
|
43
|
+
compoundBrandStroke1Pressed: appColors.shade20,
|
|
44
|
+
};
|
|
45
45
|
}
|
|
46
46
|
function getAppColors(primaryColor) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
if (typeof primaryColor === 'string') {
|
|
48
|
+
if (primaryColor.toLowerCase() === '#185abd') {
|
|
49
|
+
return globalTokens.color.word;
|
|
50
|
+
}
|
|
51
|
+
else if (primaryColor.toLowerCase() === '#107c41') {
|
|
52
|
+
return globalTokens.color.excel;
|
|
53
|
+
}
|
|
54
|
+
else if (primaryColor.toLowerCase() === '#d83b01') {
|
|
55
|
+
return globalTokens.color.office;
|
|
56
|
+
}
|
|
57
|
+
else if (primaryColor.toLowerCase() === '#80397b' || primaryColor.toLowerCase() === '#7719aa') {
|
|
58
|
+
return globalTokens.color.oneNote;
|
|
59
|
+
}
|
|
60
|
+
else if (primaryColor.toLowerCase() === '#0078d4') {
|
|
61
|
+
return globalTokens.color.outlook;
|
|
62
|
+
}
|
|
63
|
+
else if (primaryColor.toLowerCase() === '#c43e1c') {
|
|
64
|
+
return globalTokens.color.powerPoint;
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
return globalTokens.color.brand;
|
|
67
|
+
return globalTokens.color.brand;
|
|
63
68
|
}
|
|
64
|
-
//# sourceMappingURL=createBrandedThemeWithAlias.js.map
|
|
69
|
+
//# sourceMappingURL=createBrandedThemeWithAlias.js.map
|
|
@@ -2,4 +2,4 @@ import type { Variants } from '@fluentui-react-native/theme-types';
|
|
|
2
2
|
declare function createFontAliasTokensWorker(): Partial<Variants>;
|
|
3
3
|
export declare const createFontAliasTokens: typeof createFontAliasTokensWorker;
|
|
4
4
|
export {};
|
|
5
|
-
//# sourceMappingURL=createFontAliasTokens.d.ts.map
|
|
5
|
+
//# sourceMappingURL=createFontAliasTokens.d.ts.map
|
|
@@ -2,8 +2,8 @@ import { memoize } from '@fluentui-react-native/framework-base';
|
|
|
2
2
|
import { mapFontPipelineToTheme } from '@fluentui-react-native/theming-utils';
|
|
3
3
|
import { getOfficeAliasTokens } from './getOfficeTokens';
|
|
4
4
|
function createFontAliasTokensWorker() {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const aliasTokens = getOfficeAliasTokens('Colorful');
|
|
6
|
+
return mapFontPipelineToTheme(aliasTokens);
|
|
7
7
|
}
|
|
8
8
|
export const createFontAliasTokens = memoize(createFontAliasTokensWorker);
|
|
9
|
-
//# sourceMappingURL=createFontAliasTokens.js.map
|
|
9
|
+
//# sourceMappingURL=createFontAliasTokens.js.map
|
|
@@ -4,4 +4,4 @@ export declare const createOfficeColorAliasTokens: typeof createOfficeColorAlias
|
|
|
4
4
|
declare function createOfficeShadowAliasTokensWorker(officeTheme: string): ThemeShadowDefinition;
|
|
5
5
|
export declare const createOfficeShadowAliasTokens: typeof createOfficeShadowAliasTokensWorker;
|
|
6
6
|
export {};
|
|
7
|
-
//# sourceMappingURL=createOfficeAliasTokens.d.ts.map
|
|
7
|
+
//# sourceMappingURL=createOfficeAliasTokens.d.ts.map
|
|
@@ -2,13 +2,13 @@ import { memoize } from '@fluentui-react-native/framework-base';
|
|
|
2
2
|
import { mapPipelineToShadow, mapPipelineToTheme } from '@fluentui-react-native/theming-utils';
|
|
3
3
|
import { getOfficeAliasTokens, getOfficeShadowTokens } from './getOfficeTokens';
|
|
4
4
|
function createOfficeColorAliasTokensWorker(officeTheme) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const aliasTokens = getOfficeAliasTokens(officeTheme);
|
|
6
|
+
return mapPipelineToTheme(aliasTokens);
|
|
7
7
|
}
|
|
8
8
|
export const createOfficeColorAliasTokens = memoize(createOfficeColorAliasTokensWorker);
|
|
9
9
|
function createOfficeShadowAliasTokensWorker(officeTheme) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const aliasTokens = getOfficeShadowTokens(officeTheme);
|
|
11
|
+
return mapPipelineToShadow(aliasTokens);
|
|
12
12
|
}
|
|
13
13
|
export const createOfficeShadowAliasTokens = memoize(createOfficeShadowAliasTokensWorker);
|
|
14
|
-
//# sourceMappingURL=createOfficeAliasTokens.js.map
|
|
14
|
+
//# sourceMappingURL=createOfficeAliasTokens.js.map
|
|
@@ -10,4 +10,4 @@ import type { ThemeOptions } from '@fluentui-react-native/theme-types';
|
|
|
10
10
|
* @param paletteName - optional specifier for the currently active office palette
|
|
11
11
|
*/
|
|
12
12
|
export declare function createOfficeTheme(options?: ThemeOptions): ThemeReference;
|
|
13
|
-
//# sourceMappingURL=createOfficeTheme.d.ts.map
|
|
13
|
+
//# sourceMappingURL=createOfficeTheme.d.ts.map
|
package/lib/createOfficeTheme.js
CHANGED
|
@@ -8,8 +8,8 @@ import { win32Typography } from './getThemeTypography';
|
|
|
8
8
|
import { getThemingModule } from './NativeModule/getThemingModule';
|
|
9
9
|
import { getCurrentHostThemeSetting, setCurrentHostThemeSetting } from './NativeModule/hostThemeSetting';
|
|
10
10
|
function handlePaletteCall(palette) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const exception = palette;
|
|
12
|
+
return exception && exception.message !== undefined ? undefined : palette;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* create a theme reference for an Office win32 theme. This will be based upon the standard
|
|
@@ -21,55 +21,48 @@ function handlePaletteCall(palette) {
|
|
|
21
21
|
* @param paletteName - optional specifier for the currently active office palette
|
|
22
22
|
*/
|
|
23
23
|
export function createOfficeTheme(options = {}) {
|
|
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
|
-
ref.themeName = (args && args.hostThemeSetting) || ref.themeName;
|
|
68
|
-
setCurrentHostThemeSetting(ref.themeName);
|
|
69
|
-
themeRef.invalidate();
|
|
70
|
-
};
|
|
71
|
-
emitter && emitter.addListener('onPlatformDefaultsChanged', onPlatformDefaultsChanged);
|
|
72
|
-
// now return the theme reference
|
|
73
|
-
return themeRef;
|
|
24
|
+
const [module, emitter] = getThemingModule();
|
|
25
|
+
const ref = { module, emitter, themeName: getCurrentHostThemeSetting() || '' };
|
|
26
|
+
const { paletteName } = options;
|
|
27
|
+
const themeRef = new ThemeReference(createDefaultTheme(options), () => {
|
|
28
|
+
const name = paletteName || 'WhiteColors';
|
|
29
|
+
const palette = handlePaletteCall(ref.module.getPalette(name));
|
|
30
|
+
return createPartialOfficeTheme(module, ref.themeName, palette);
|
|
31
|
+
}, () => {
|
|
32
|
+
if (!ref.themeName || ref.themeName === '') {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
shadows: { ...createOfficeShadowAliasTokens(ref.themeName) },
|
|
37
|
+
typography: win32Typography(),
|
|
38
|
+
};
|
|
39
|
+
}, () => {
|
|
40
|
+
if (!ref.themeName || ref.themeName === '') {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
colors: { ...createOfficeColorAliasTokens(ref.themeName) },
|
|
45
|
+
typography: win32Typography(),
|
|
46
|
+
};
|
|
47
|
+
}, (theme) => {
|
|
48
|
+
return createBrandedThemeWithAlias(ref.themeName, theme);
|
|
49
|
+
}, (theme) => {
|
|
50
|
+
if (!theme.host.palette) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...(paletteName !== undefined && { colors: createAliasesFromPalette(theme.host.palette, ref.themeName === 'HighContrast') }),
|
|
55
|
+
typography: win32Typography(),
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
// set up the callback for theme changes on the native side
|
|
59
|
+
const onPlatformDefaultsChanged = (args) => {
|
|
60
|
+
ref.themeName = (args && args.hostThemeSetting) || ref.themeName;
|
|
61
|
+
setCurrentHostThemeSetting(ref.themeName);
|
|
62
|
+
themeRef.invalidate();
|
|
63
|
+
};
|
|
64
|
+
emitter && emitter.addListener('onPlatformDefaultsChanged', onPlatformDefaultsChanged);
|
|
65
|
+
// now return the theme reference
|
|
66
|
+
return themeRef;
|
|
74
67
|
}
|
|
75
|
-
//# sourceMappingURL=createOfficeTheme.js.map
|
|
68
|
+
//# sourceMappingURL=createOfficeTheme.js.map
|
|
@@ -7,4 +7,4 @@ import type { OfficeThemingModule } from './NativeModule/officeThemingModule';
|
|
|
7
7
|
* @param palette - Office palette colors, if they have been successfully retrieved
|
|
8
8
|
*/
|
|
9
9
|
export declare function createPartialOfficeTheme(module: OfficeThemingModule, themeName?: string, palette?: OfficePalette): PartialTheme;
|
|
10
|
-
//# sourceMappingURL=createPartialOfficeTheme.d.ts.map
|
|
10
|
+
//# sourceMappingURL=createPartialOfficeTheme.d.ts.map
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { paletteFromOfficeColors } from './paletteFromOfficeColors';
|
|
2
2
|
const getRamps = (module) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}),
|
|
9
|
-
);
|
|
10
|
-
}, {});
|
|
3
|
+
return Object.keys(module.getConstants().ramps).reduce((total, colorRamp) => {
|
|
4
|
+
return Object.assign(total, ...module.getConstants().rampNames[colorRamp].map((rampValueName, index) => {
|
|
5
|
+
return { [rampValueName]: module.getConstants().ramps[colorRamp][index] };
|
|
6
|
+
}));
|
|
7
|
+
}, {});
|
|
11
8
|
};
|
|
12
9
|
/**
|
|
13
10
|
* create a partial theme with overrides from the office native module
|
|
@@ -16,18 +13,18 @@ const getRamps = (module) => {
|
|
|
16
13
|
* @param palette - Office palette colors, if they have been successfully retrieved
|
|
17
14
|
*/
|
|
18
15
|
export function createPartialOfficeTheme(module, themeName, palette) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
return {
|
|
17
|
+
colors: {
|
|
18
|
+
...(palette && paletteFromOfficeColors(palette)),
|
|
19
|
+
},
|
|
20
|
+
typography: module.getConstants().fluentTypography,
|
|
21
|
+
host: {
|
|
22
|
+
// Office Semantic Colors
|
|
23
|
+
palette: palette || {},
|
|
24
|
+
// Office Branding Colors
|
|
25
|
+
colors: getRamps(module),
|
|
26
|
+
},
|
|
27
|
+
...(themeName ? { name: themeName } : undefined),
|
|
28
|
+
};
|
|
32
29
|
}
|
|
33
|
-
//# sourceMappingURL=createPartialOfficeTheme.js.map
|
|
30
|
+
//# sourceMappingURL=createPartialOfficeTheme.js.map
|