@fluentui-react-native/apple-theme 0.9.6 → 0.9.10

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.
Files changed (51) hide show
  1. package/CHANGELOG.json +174 -1
  2. package/CHANGELOG.md +44 -2
  3. package/babel.config.js +1 -1
  4. package/just.config.js +1 -1
  5. package/lib/appleColors.macos.d.ts.map +1 -1
  6. package/lib/appleColors.macos.js +29 -29
  7. package/lib/appleColors.macos.js.map +1 -1
  8. package/lib/appleColors.types.macos.d.ts +6 -1
  9. package/lib/appleColors.types.macos.d.ts.map +1 -1
  10. package/lib/appleHighContrast.macos.d.ts +3 -0
  11. package/lib/appleHighContrast.macos.d.ts.map +1 -0
  12. package/lib/appleHighContrast.macos.js +8 -0
  13. package/lib/appleHighContrast.macos.js.map +1 -0
  14. package/lib/createAppleTheme.macos.d.ts.map +1 -1
  15. package/lib/createAppleTheme.macos.js +16 -1
  16. package/lib/createAppleTheme.macos.js.map +1 -1
  17. package/lib/createMacOSAliasTokens.d.ts +1 -1
  18. package/lib/createMacOSAliasTokens.d.ts.map +1 -1
  19. package/lib/createMacOSAliasTokens.js +4 -4
  20. package/lib/createMacOSAliasTokens.js.map +1 -1
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +1 -0
  24. package/lib/index.js.map +1 -1
  25. package/lib-commonjs/appleColors.macos.d.ts.map +1 -1
  26. package/lib-commonjs/appleColors.macos.js +29 -29
  27. package/lib-commonjs/appleColors.macos.js.map +1 -1
  28. package/lib-commonjs/appleColors.types.macos.d.ts +6 -1
  29. package/lib-commonjs/appleColors.types.macos.d.ts.map +1 -1
  30. package/lib-commonjs/appleHighContrast.macos.d.ts +3 -0
  31. package/lib-commonjs/appleHighContrast.macos.d.ts.map +1 -0
  32. package/lib-commonjs/appleHighContrast.macos.js +13 -0
  33. package/lib-commonjs/appleHighContrast.macos.js.map +1 -0
  34. package/lib-commonjs/createAppleTheme.macos.d.ts.map +1 -1
  35. package/lib-commonjs/createAppleTheme.macos.js +16 -1
  36. package/lib-commonjs/createAppleTheme.macos.js.map +1 -1
  37. package/lib-commonjs/createMacOSAliasTokens.d.ts +1 -1
  38. package/lib-commonjs/createMacOSAliasTokens.d.ts.map +1 -1
  39. package/lib-commonjs/createMacOSAliasTokens.js +3 -3
  40. package/lib-commonjs/createMacOSAliasTokens.js.map +1 -1
  41. package/lib-commonjs/index.d.ts +1 -0
  42. package/lib-commonjs/index.d.ts.map +1 -1
  43. package/lib-commonjs/index.js +1 -0
  44. package/lib-commonjs/index.js.map +1 -1
  45. package/package.json +7 -9
  46. package/src/appleColors.macos.ts +29 -32
  47. package/src/appleColors.types.macos.ts +6 -1
  48. package/src/appleHighContrast.macos.ts +9 -0
  49. package/src/createAppleTheme.macos.ts +18 -2
  50. package/src/createMacOSAliasTokens.ts +4 -4
  51. package/src/index.ts +1 -0
@@ -210,17 +210,22 @@ interface FluentAppleButtonTokens {
210
210
  brandBackgroundHovered: ColorValue;
211
211
  brandBackgroundPressed: ColorValue;
212
212
  brandForegroundDisabled: ColorValue;
213
- brandBackgroundDisabled: ColorValue;
213
+ brandForegroundPressed: ColorValue;
214
214
  neutralStrokeDisabled: ColorValue;
215
215
  neutralBackgroundInverted: ColorValue;
216
216
  neutralForegroundInverted: ColorValue;
217
217
  neutralForeground2: ColorValue;
218
218
  neutralBackground1: ColorValue;
219
219
  neutralBackground2: ColorValue;
220
+ neutralBackgroundDisabled: ColorValue;
221
+ neutralBackground2Pressed: ColorValue;
220
222
  neutralStroke2: ColorValue;
221
223
  neutralForeground3: ColorValue;
224
+ neutralForegroundDisabled: ColorValue;
225
+ neutralForeground2Pressed: ColorValue;
222
226
  neutralBackground3: ColorValue;
223
227
  transparentBackground: ColorValue;
228
+ transparentStroke: ColorValue;
224
229
  }
225
230
 
226
231
  export type FluentUIApplePalette = FluentUIAppleBasePalette & FluentAppleButtonTokens;
@@ -0,0 +1,9 @@
1
+ let isHighContrastEnabled = false;
2
+
3
+ export function setIsHighContrast(isHighContrast: boolean) {
4
+ isHighContrastEnabled = isHighContrast;
5
+ }
6
+
7
+ export function getIsHighContrast() {
8
+ return isHighContrastEnabled;
9
+ }
@@ -2,15 +2,31 @@ import { ThemeReference } from '@fluentui-react-native/theme';
2
2
  import { Theme } from '@fluentui-react-native/theme-types';
3
3
  import { Appearance } from 'react-native';
4
4
  import { getBaseAppleThemeMacOS } from './appleTheme.macos';
5
+ import { AccessibilityInfo } from 'react-native-macos';
6
+ import { setIsHighContrast } from './appleHighContrast.macos';
7
+
8
+ let appleThemeReference: ThemeReference;
5
9
 
6
10
  export function createAppleTheme(): ThemeReference {
7
- const appleThemeReference = new ThemeReference({} as Theme, () => {
11
+ appleThemeReference = new ThemeReference({} as Theme, () => {
8
12
  return getBaseAppleThemeMacOS();
9
13
  });
14
+ // Fetch initial system settings for high contrast mode
15
+ highContrastHandler();
16
+ // Invalidate theme and set prop when high contrast setting changes
17
+ AccessibilityInfo.addEventListener('highContrastChanged', () => {
18
+ highContrastHandler();
19
+ });
10
20
 
11
21
  Appearance.addChangeListener(() => {
12
22
  appleThemeReference.invalidate();
13
23
  });
14
-
15
24
  return appleThemeReference;
16
25
  }
26
+
27
+ function highContrastHandler() {
28
+ AccessibilityInfo.isHighContrastEnabled().then((isEnabled) => {
29
+ setIsHighContrast(isEnabled);
30
+ appleThemeReference.invalidate();
31
+ });
32
+ }
@@ -1,10 +1,10 @@
1
- import { getAliasTokens } from '@fluentui-react-native/theme-tokens';
1
+ import { getMacOSAliasTokens } from '@fluentui-react-native/theme-tokens';
2
2
  import { AliasColorTokens, AppearanceOptions } from '@fluentui-react-native/theme-types';
3
- import { memoize } from '@fluentui-react-native/memo-cache';
4
3
  import { mapPipelineToTheme } from '@fluentui-react-native/theming-utils';
4
+ import { memoize } from '@fluentui-react-native/memo-cache';
5
5
 
6
- function createMacOSAliasTokensWorker(mode: AppearanceOptions): AliasColorTokens {
7
- const aliasTokens = getAliasTokens(mode);
6
+ function createMacOSAliasTokensWorker(mode: AppearanceOptions, isHighContrast: boolean): AliasColorTokens {
7
+ const aliasTokens = getMacOSAliasTokens(mode, isHighContrast);
8
8
  return mapPipelineToTheme(aliasTokens);
9
9
  }
10
10
 
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './createAppleTheme';
2
2
  export * from './createMacOSAliasTokens';
3
+ export * from './appleHighContrast.macos';