@fluentui-react-native/apple-theme 0.8.0 → 0.9.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.
Files changed (35) hide show
  1. package/CHANGELOG.json +122 -1
  2. package/CHANGELOG.md +43 -2
  3. package/lib/appleColors.macos.d.ts +1 -1
  4. package/lib/appleColors.macos.d.ts.map +1 -1
  5. package/lib/appleColors.macos.js +60 -62
  6. package/lib/appleColors.macos.js.map +1 -1
  7. package/lib/appleColors.types.macos.d.ts +7 -1
  8. package/lib/appleColors.types.macos.d.ts.map +1 -1
  9. package/lib/createMacOSAliasTokens.d.ts +5 -0
  10. package/lib/createMacOSAliasTokens.d.ts.map +1 -0
  11. package/lib/createMacOSAliasTokens.js +9 -0
  12. package/lib/createMacOSAliasTokens.js.map +1 -0
  13. package/lib/index.d.ts +1 -0
  14. package/lib/index.d.ts.map +1 -1
  15. package/lib/index.js +1 -0
  16. package/lib/index.js.map +1 -1
  17. package/lib-commonjs/appleColors.macos.d.ts +1 -1
  18. package/lib-commonjs/appleColors.macos.d.ts.map +1 -1
  19. package/lib-commonjs/appleColors.macos.js +60 -62
  20. package/lib-commonjs/appleColors.macos.js.map +1 -1
  21. package/lib-commonjs/appleColors.types.macos.d.ts +7 -1
  22. package/lib-commonjs/appleColors.types.macos.d.ts.map +1 -1
  23. package/lib-commonjs/createMacOSAliasTokens.d.ts +5 -0
  24. package/lib-commonjs/createMacOSAliasTokens.d.ts.map +1 -0
  25. package/lib-commonjs/createMacOSAliasTokens.js +11 -0
  26. package/lib-commonjs/createMacOSAliasTokens.js.map +1 -0
  27. package/lib-commonjs/index.d.ts +1 -0
  28. package/lib-commonjs/index.d.ts.map +1 -1
  29. package/lib-commonjs/index.js +1 -0
  30. package/lib-commonjs/index.js.map +1 -1
  31. package/package.json +14 -12
  32. package/src/appleColors.macos.ts +62 -64
  33. package/src/appleColors.types.macos.ts +7 -1
  34. package/src/createMacOSAliasTokens.ts +11 -0
  35. package/src/index.ts +1 -0
@@ -3,6 +3,7 @@ import { getCurrentAppearance } from '@fluentui-react-native/theming-utils';
3
3
  import { AppleSemanticPalette, FluentUIApplePalette } from './appleColors.types.macos';
4
4
  import { PlatformColor, DynamicColorMacOS, ColorWithSystemEffectMacOS } from 'react-native-macos';
5
5
  import { Appearance } from 'react-native';
6
+ import { createMacOSAliasTokens } from './createMacOSAliasTokens';
6
7
 
7
8
  /** Creates a Palette of PlatformColors defined for macOS */
8
9
  export function getAppleSemanticPalette(): AppleSemanticPalette {
@@ -46,7 +47,7 @@ export function getAppleSemanticPalette(): AppleSemanticPalette {
46
47
 
47
48
  windowBackgroundColor: PlatformColor('windowBackgroundColor'),
48
49
  windowFrameTextColor: PlatformColor('windowFrameTextColor'),
49
- underPageBackgroundColor: PlatformColor(' underPageBackgroundColor'),
50
+ underPageBackgroundColor: PlatformColor('underPageBackgroundColor'),
50
51
 
51
52
  findHighlightColor: PlatformColor('findHighlightColor'),
52
53
  highlightColor: PlatformColor('highlightColor'),
@@ -55,6 +56,10 @@ export function getAppleSemanticPalette(): AppleSemanticPalette {
55
56
  }
56
57
 
57
58
  function getFluentUIApplePalette(): FluentUIApplePalette {
59
+ const appearance = Appearance.getColorScheme();
60
+ const mode = getCurrentAppearance(appearance, 'light');
61
+ const macOSAliasColorTokens = createMacOSAliasTokens(mode);
62
+
58
63
  return {
59
64
  blue10: '#4F6BED',
60
65
  blueMagenta20: '#8764B8',
@@ -259,35 +264,28 @@ function getFluentUIApplePalette(): FluentUIApplePalette {
259
264
  light: '#2525253F',
260
265
  dark: '#5656567F',
261
266
  }),
262
- neutralInverted: '#FFFFFF',
263
- neutralForeground2: '#000000D8',
264
- neutralBackground2: DynamicColorMacOS({
265
- light: '#FFFFFF',
266
- dark: '#555555',
267
- }),
268
- neutralStroke2: '#00000026',
269
- neutralForeground3: DynamicColorMacOS({
270
- light: '#272727',
271
- dark: '#FFFFFF',
272
- }),
273
- neutralBackground3: DynamicColorMacOS({
274
- light: '#0000000C',
275
- dark: '#555555',
276
- }),
267
+
268
+ brandedBackground: macOSAliasColorTokens.brandBackground,
269
+ brandBackgroundPressed: macOSAliasColorTokens.brandBackgroundPressed,
270
+ brandBackgroundHovered: macOSAliasColorTokens.brandBackgroundHover,
271
+ neutralBackgroundInverted: macOSAliasColorTokens.neutralBackgroundInverted,
272
+ neutralForegroundInverted: macOSAliasColorTokens.neutralForegroundInverted,
273
+ neutralForeground2: macOSAliasColorTokens.neutralForeground2,
274
+ neutralBackground2: macOSAliasColorTokens.neutralBackground2,
275
+ neutralStroke2: macOSAliasColorTokens.neutralStroke2,
276
+ neutralForeground3: macOSAliasColorTokens.neutralForeground3,
277
+ neutralBackground3: macOSAliasColorTokens.neutralBackground3,
278
+ neutralStrokeDisabled: macOSAliasColorTokens.neutralStrokeDisabled,
279
+ transparentBackground: macOSAliasColorTokens.transparentBackground,
277
280
  };
278
281
  }
279
282
 
280
283
  /** Creates a palette of colors for the apple theme, given the FluentUI Apple Palette and Apple Semantic Palette
281
- * The fallback palette is loaded while we wait for the native theming module to load, or if the module is not found
284
+ * The fallback palette is loaded while we wait for the native theming module to load, or if the module is not found
282
285
  */
283
286
  export function fallbackApplePalette(): ThemeColorDefinition {
284
287
  const fluentUIApple = getFluentUIApplePalette();
285
288
  const applePlatform = getAppleSemanticPalette();
286
-
287
- // GH:728 Until RN-SVG Supports PlatformColor, we need this workaround
288
- const appearance = Appearance.getColorScheme();
289
- const neutralForeground3 = getCurrentAppearance(appearance, 'light') === 'light' ? '#272727' : '#FFFFFF';
290
-
291
289
  return {
292
290
  /* PaletteBackgroundColors & PaletteTextColors */
293
291
 
@@ -338,7 +336,7 @@ export function fallbackApplePalette(): ThemeColorDefinition {
338
336
  buttonBackgroundCheckedHovered: fluentUIApple.neutralBackground3,
339
337
  buttonBackgroundPressed: ColorWithSystemEffectMacOS(fluentUIApple.neutralBackground3, 'pressed'),
340
338
  buttonBackgroundDisabled: ColorWithSystemEffectMacOS(fluentUIApple.neutralBackground3, 'disabled'),
341
- buttonBorder: 'transparent',
339
+ buttonBorder: fluentUIApple.transparentBackground,
342
340
  buttonText: fluentUIApple.neutralForeground3,
343
341
  buttonTextHovered: fluentUIApple.neutralForeground3,
344
342
  buttonTextChecked: fluentUIApple.neutralForeground3,
@@ -346,8 +344,8 @@ export function fallbackApplePalette(): ThemeColorDefinition {
346
344
  buttonTextPressed: ColorWithSystemEffectMacOS(fluentUIApple.neutralForeground3, 'pressed'),
347
345
  buttonTextDisabled: ColorWithSystemEffectMacOS(fluentUIApple.neutralForeground3, 'disabled'),
348
346
 
349
- buttonBorderDisabled: 'transparent',
350
- buttonBorderFocused: 'transparent',
347
+ buttonBorderDisabled: fluentUIApple.transparentBackground,
348
+ buttonBorderFocused: fluentUIApple.transparentBackground,
351
349
 
352
350
  primaryButtonBackground: fluentUIApple.communicationBlue,
353
351
  primaryButtonBackgroundHovered: fluentUIApple.communicationBlue,
@@ -355,22 +353,22 @@ export function fallbackApplePalette(): ThemeColorDefinition {
355
353
  primaryButtonBackgroundDisabled: fluentUIApple.brandBackgroundDisabled,
356
354
  primaryButtonBorder: 'transparent',
357
355
  primaryButtonBorderFocused: 'transparent',
358
- primaryButtonText: fluentUIApple.neutralInverted,
359
- primaryButtonTextHovered: fluentUIApple.neutralInverted,
360
- primaryButtonTextPressed: ColorWithSystemEffectMacOS(fluentUIApple.neutralInverted, 'pressed'),
356
+ primaryButtonText: fluentUIApple.neutralForegroundInverted,
357
+ primaryButtonTextHovered: fluentUIApple.neutralForegroundInverted,
358
+ primaryButtonTextPressed: ColorWithSystemEffectMacOS(fluentUIApple.neutralForegroundInverted, 'pressed'),
361
359
  primaryButtonTextDisabled: fluentUIApple.brandForegroundDisabled,
362
360
 
363
361
  accentButtonBackground: fluentUIApple.communicationBlue,
364
- accentButtonText: fluentUIApple.neutralInverted,
362
+ accentButtonText: fluentUIApple.neutralForegroundInverted,
365
363
 
366
364
  menuBackground: 'transparent',
367
365
  menuDivider: applePlatform.separatorColor,
368
- menuIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
366
+ menuIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
369
367
  menuHeader: applePlatform.headerTextColor,
370
- menuItemBackgroundHovered: 'transparent',
371
- menuItemBackgroundPressed: applePlatform.selectedContentBackgroundColor,
368
+ menuItemBackgroundHovered: applePlatform.controlAccentColor,
369
+ menuItemBackgroundPressed: ColorWithSystemEffectMacOS(applePlatform.controlAccentColor, 'pressed'),
372
370
  menuItemText: applePlatform.labelColor,
373
- menuItemTextHovered: applePlatform.labelColor,
371
+ menuItemTextHovered: 'white',
374
372
 
375
373
  listBackground: 'transparent',
376
374
  listText: applePlatform.labelColor,
@@ -393,27 +391,27 @@ export function fallbackApplePalette(): ThemeColorDefinition {
393
391
  defaultBackground: fluentUIApple.neutralBackground3,
394
392
  defaultBorder: 'transparent',
395
393
  defaultContent: fluentUIApple.neutralForeground3,
396
- defaultIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
394
+ defaultIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
397
395
 
398
396
  defaultHoveredBackground: fluentUIApple.neutralBackground3,
399
397
  defaultHoveredBorder: 'transparent',
400
398
  defaultHoveredContent: fluentUIApple.neutralForeground3,
401
- defaultHoveredIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
399
+ defaultHoveredIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
402
400
 
403
401
  defaultFocusedBackground: fluentUIApple.neutralBackground3,
404
402
  defaultFocusedBorder: 'transparent',
405
403
  defaultFocusedContent: fluentUIApple.neutralForeground3,
406
- defaultFocusedIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
404
+ defaultFocusedIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
407
405
 
408
406
  defaultPressedBackground: ColorWithSystemEffectMacOS(fluentUIApple.neutralBackground3, 'pressed'),
409
407
  defaultPressedBorder: 'transparent',
410
408
  defaultPressedContent: ColorWithSystemEffectMacOS(fluentUIApple.neutralForeground3, 'pressed'),
411
- defaultPressedIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
409
+ defaultPressedIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
412
410
 
413
- defaultDisabledBackground: ColorWithSystemEffectMacOS(fluentUIApple.neutralBackground3, 'disabled'),
411
+ defaultDisabledBackground: fluentUIApple.neutralStrokeDisabled,
414
412
  defaultDisabledBorder: 'transparent',
415
413
  defaultDisabledContent: ColorWithSystemEffectMacOS(fluentUIApple.neutralForeground3, 'pressed'),
416
- defaultDisabledIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
414
+ defaultDisabledIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
417
415
 
418
416
  ghostBackground: 'transparent',
419
417
  ghostBorder: 'transparent',
@@ -433,47 +431,47 @@ export function fallbackApplePalette(): ThemeColorDefinition {
433
431
  ghostPressedBackground: 'transparent',
434
432
  ghostPressedBorder: 'transparent',
435
433
  ghostPressedContent: ColorWithSystemEffectMacOS(fluentUIApple.communicationBlue, 'deepPressed'),
436
- ghostPressedIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
434
+ ghostPressedIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
437
435
 
438
436
  ghostDisabledBackground: 'transparent',
439
437
  ghostDisabledBorder: 'transparent',
440
438
  ghostDisabledContent: fluentUIApple.brandForegroundDisabled,
441
439
  ghostDisabledIcon: fluentUIApple.brandForegroundDisabled,
442
440
 
443
- brandedBackground: fluentUIApple.communicationBlue,
441
+ brandedBackground: fluentUIApple.brandedBackground,
444
442
  brandedBorder: 'transparent',
445
- brandedContent: fluentUIApple.neutralInverted,
446
- brandedIcon: fluentUIApple.neutralInverted,
443
+ brandedContent: fluentUIApple.neutralForegroundInverted,
444
+ brandedIcon: fluentUIApple.neutralForegroundInverted,
447
445
 
448
- brandedHoveredBackground: fluentUIApple.communicationBlue,
446
+ brandedHoveredBackground: fluentUIApple.brandBackgroundHovered,
449
447
  brandedHoveredBorder: 'transparent',
450
- brandedHoveredContent: fluentUIApple.neutralInverted,
451
- brandedHoveredIcon: fluentUIApple.neutralInverted,
448
+ brandedHoveredContent: fluentUIApple.neutralForegroundInverted,
449
+ brandedHoveredIcon: fluentUIApple.neutralForegroundInverted,
452
450
 
453
451
  brandedFocusedBackground: fluentUIApple.communicationBlue,
454
452
  brandedFocusedBorder: 'transparent',
455
- brandedFocusedContent: fluentUIApple.neutralInverted,
456
- brandedFocusedIcon: fluentUIApple.neutralInverted,
453
+ brandedFocusedContent: fluentUIApple.neutralForegroundInverted,
454
+ brandedFocusedIcon: fluentUIApple.neutralForegroundInverted,
457
455
 
458
- brandedPressedBackground: ColorWithSystemEffectMacOS(fluentUIApple.communicationBlue, 'pressed'),
456
+ brandedPressedBackground: fluentUIApple.brandBackgroundPressed, //ColorWithSystemEffectMacOS(fluentUIApple.communicationBlue, 'pressed'),
459
457
  brandedPressedBorder: 'transparent',
460
- brandedPressedContent: fluentUIApple.neutralInverted,
461
- brandedPressedIcon: fluentUIApple.neutralInverted,
458
+ brandedPressedContent: fluentUIApple.neutralForegroundInverted,
459
+ brandedPressedIcon: fluentUIApple.neutralForegroundInverted,
462
460
 
463
461
  brandedDisabledBackground: fluentUIApple.brandBackgroundDisabled,
464
462
  brandedDisabledBorder: 'transparent',
465
463
  brandedDisabledContent: fluentUIApple.brandForegroundDisabled,
466
- brandedDisabledIcon: neutralForeground3, //GH:728 Icon doesn't support PlatformColor
464
+ brandedDisabledIcon: fluentUIApple.neutralForeground3, //GH:728 Icon doesn't support PlatformColor
467
465
 
468
466
  defaultCheckedBackground: fluentUIApple.communicationBlue,
469
- defaultCheckedContent: fluentUIApple.neutralInverted,
467
+ defaultCheckedContent: fluentUIApple.neutralForegroundInverted,
470
468
  defaultCheckedHoveredBackground: fluentUIApple.communicationBlue,
471
- defaultCheckedHoveredContent: fluentUIApple.neutralInverted,
469
+ defaultCheckedHoveredContent: fluentUIApple.neutralForegroundInverted,
472
470
 
473
471
  brandedCheckedBackground: fluentUIApple.communicationBlue,
474
- brandedCheckedContent: fluentUIApple.neutralInverted,
472
+ brandedCheckedContent: fluentUIApple.neutralForegroundInverted,
475
473
  brandedCheckedHoveredBackground: fluentUIApple.communicationBlue,
476
- brandedCheckedHoveredContent: fluentUIApple.neutralInverted,
474
+ brandedCheckedHoveredContent: fluentUIApple.neutralForegroundInverted,
477
475
 
478
476
  ghostCheckedBackground: 'transparent',
479
477
  ghostCheckedContent: fluentUIApple.communicationBlue,
@@ -486,21 +484,21 @@ export function fallbackApplePalette(): ThemeColorDefinition {
486
484
  ghostHoveredSecondaryContent: fluentUIApple.communicationBlue,
487
485
  ghostPressedSecondaryContent: ColorWithSystemEffectMacOS(fluentUIApple.communicationBlue, 'deepPressed'),
488
486
 
489
- brandedSecondaryContent: fluentUIApple.neutralInverted,
490
- brandedFocusedSecondaryContent: fluentUIApple.neutralInverted,
491
- brandedHoveredSecondaryContent: fluentUIApple.neutralInverted,
492
- brandedPressedSecondaryContent: ColorWithSystemEffectMacOS(fluentUIApple.neutralInverted, 'pressed'),
487
+ brandedSecondaryContent: fluentUIApple.neutralForegroundInverted,
488
+ brandedFocusedSecondaryContent: fluentUIApple.neutralForegroundInverted,
489
+ brandedHoveredSecondaryContent: fluentUIApple.neutralForegroundInverted,
490
+ brandedPressedSecondaryContent: ColorWithSystemEffectMacOS(fluentUIApple.neutralForegroundInverted, 'pressed'),
493
491
 
494
492
  defaultDisabledSecondaryContent: fluentUIApple.brandForegroundDisabled,
495
- defaultHoveredSecondaryContent: fluentUIApple.neutralInverted,
496
- defaultPressedSecondaryContent: fluentUIApple.neutralInverted,
493
+ defaultHoveredSecondaryContent: fluentUIApple.neutralForegroundInverted,
494
+ defaultPressedSecondaryContent: fluentUIApple.neutralForegroundInverted,
497
495
 
498
496
  checkboxBackground: fluentUIApple.communicationBlue,
499
497
  checkboxBackgroundDisabled: fluentUIApple.brandBackgroundDisabled,
500
498
  checkboxBorderColor: fluentUIApple.gray600,
501
- checkmarkColor: fluentUIApple.neutralInverted,
499
+ checkmarkColor: fluentUIApple.neutralForegroundInverted,
502
500
 
503
- personaActivityRing: fluentUIApple.neutralInverted,
501
+ personaActivityRing: fluentUIApple.neutralForegroundInverted,
504
502
  personaActivityGlow: fluentUIApple.red10,
505
503
  };
506
504
  }
@@ -206,14 +206,20 @@ interface FluentUIAppleBasePalette {
206
206
 
207
207
  /** A set of control tokens used on the FluentUI Apple macOS button */
208
208
  interface FluentAppleButtonTokens {
209
+ brandedBackground: ColorValue;
210
+ brandBackgroundHovered: ColorValue;
211
+ brandBackgroundPressed: ColorValue;
209
212
  brandForegroundDisabled: ColorValue;
210
213
  brandBackgroundDisabled: ColorValue;
211
- neutralInverted: ColorValue;
214
+ neutralStrokeDisabled: ColorValue;
215
+ neutralBackgroundInverted: ColorValue;
216
+ neutralForegroundInverted: ColorValue;
212
217
  neutralForeground2: ColorValue;
213
218
  neutralBackground2: ColorValue;
214
219
  neutralStroke2: ColorValue;
215
220
  neutralForeground3: ColorValue;
216
221
  neutralBackground3: ColorValue;
222
+ transparentBackground: ColorValue;
217
223
  }
218
224
 
219
225
  export type FluentUIApplePalette = FluentUIAppleBasePalette & FluentAppleButtonTokens;
@@ -0,0 +1,11 @@
1
+ import { getAliasTokens } from '@fluentui-react-native/theme-tokens';
2
+ import { AliasColorTokens, AppearanceOptions } from '@fluentui-react-native/theme-types';
3
+ import { memoize } from '@fluentui-react-native/memo-cache';
4
+ import { mapPipelineToTheme } from '@fluentui-react-native/theming-utils';
5
+
6
+ function createMacOSAliasTokensWorker(mode: AppearanceOptions): AliasColorTokens {
7
+ const aliasTokens = getAliasTokens(mode);
8
+ return mapPipelineToTheme(aliasTokens);
9
+ }
10
+
11
+ export const createMacOSAliasTokens = memoize(createMacOSAliasTokensWorker);
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './createAppleTheme';
2
+ export * from './createMacOSAliasTokens';