@fluentui-react-native/apple-theme 0.29.6 → 0.29.11
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/.cache/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +68 -0
- package/lib/appleColors.ios.d.ts +2 -2
- package/lib/appleColors.ios.d.ts.map +1 -1
- package/lib/appleColors.ios.js +1 -8
- package/lib/appleColors.ios.js.map +1 -1
- package/lib/appleColors.macos.d.ts +1 -1
- package/lib/appleColors.macos.d.ts.map +1 -1
- package/lib/appleColors.macos.js +2 -3
- package/lib/appleColors.macos.js.map +1 -1
- package/lib/appleShadows.ios.d.ts +2 -2
- package/lib/appleShadows.ios.d.ts.map +1 -1
- package/lib/appleShadows.ios.js +1 -5
- package/lib/appleShadows.ios.js.map +1 -1
- package/lib/appleShadows.macos.d.ts +1 -1
- package/lib/appleShadows.macos.d.ts.map +1 -1
- package/lib/appleShadows.macos.js +2 -3
- package/lib/appleShadows.macos.js.map +1 -1
- package/lib/appleTheme.ios.d.ts.map +1 -1
- package/lib/appleTheme.ios.js +3 -2
- package/lib/appleTheme.ios.js.map +1 -1
- package/lib/appleTheme.macos.js +3 -3
- package/lib/appleTheme.macos.js.map +1 -1
- package/lib/createAppleTheme.ios.d.ts.map +1 -1
- package/lib/createAppleTheme.ios.js +29 -12
- package/lib/createAppleTheme.ios.js.map +1 -1
- package/lib/createAppleTheme.macos.d.ts.map +1 -1
- package/lib/createAppleTheme.macos.js +15 -23
- package/lib/createAppleTheme.macos.js.map +1 -1
- package/lib/createFontAliasTokens.ios.js +1 -1
- package/lib/createFontAliasTokens.ios.js.map +1 -1
- package/lib/createMacOSAliasTokens.js +1 -1
- package/lib/createMacOSAliasTokens.js.map +1 -1
- package/lib/createiOSAliasTokens.js +2 -2
- package/lib/createiOSAliasTokens.js.map +1 -1
- package/package.json +5 -7
- package/src/appleColors.ios.ts +2 -11
- package/src/appleColors.macos.ts +2 -3
- package/src/appleShadows.ios.ts +2 -7
- package/src/appleShadows.macos.ts +2 -3
- package/src/appleTheme.ios.ts +3 -2
- package/src/appleTheme.macos.ts +3 -3
- package/src/createAppleTheme.ios.ts +33 -16
- package/src/createAppleTheme.macos.ts +15 -26
- package/src/createFontAliasTokens.ios.ts +1 -1
- package/src/createMacOSAliasTokens.ts +1 -1
- package/src/createiOSAliasTokens.ts +2 -2
package/src/appleShadows.ios.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import type { ThemeShadowDefinition } from '@fluentui-react-native/design/theming';
|
|
4
|
-
import { getCurrentAppearance } from '@fluentui-react-native/design/theming';
|
|
1
|
+
import type { AppearanceOptions, ThemeShadowDefinition } from '@fluentui-react-native/design/theming';
|
|
5
2
|
|
|
6
3
|
import { createiOSShadowAliasTokens } from './createiOSAliasTokens';
|
|
7
4
|
|
|
8
|
-
export function iOSShadows(): ThemeShadowDefinition {
|
|
9
|
-
const appearance = Appearance.getColorScheme();
|
|
10
|
-
const mode = getCurrentAppearance(appearance, 'light');
|
|
5
|
+
export function iOSShadows(mode: AppearanceOptions): ThemeShadowDefinition {
|
|
11
6
|
return createiOSShadowAliasTokens(mode);
|
|
12
7
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ThemeShadowDefinition, AppearanceOptions } from '@fluentui-react-native/design/theming';
|
|
2
2
|
|
|
3
|
-
import { getIsHighContrast } from './appleHighContrast.macos';
|
|
4
3
|
import { createMacOSShadowAliasTokens } from './createMacOSAliasTokens';
|
|
5
4
|
|
|
6
|
-
export function fallbackAppleShadows(mode: AppearanceOptions): ThemeShadowDefinition {
|
|
7
|
-
return createMacOSShadowAliasTokens(mode,
|
|
5
|
+
export function fallbackAppleShadows(mode: AppearanceOptions, highContrast: boolean): ThemeShadowDefinition {
|
|
6
|
+
return createMacOSShadowAliasTokens(mode, highContrast);
|
|
8
7
|
}
|
package/src/appleTheme.ios.ts
CHANGED
|
@@ -130,10 +130,11 @@ const appleComponents = {
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
function getBaseAppleThemeIOSWorker(isLightMode: boolean, isElevated: boolean): Theme {
|
|
133
|
+
const mode = isLightMode ? 'light' : isElevated ? 'darkElevated' : 'dark';
|
|
133
134
|
return {
|
|
134
|
-
colors: paletteFromAppleColors(isLightMode,
|
|
135
|
+
colors: paletteFromAppleColors(isLightMode, mode),
|
|
135
136
|
typography: appleTypography(),
|
|
136
|
-
shadows: iOSShadows(),
|
|
137
|
+
shadows: iOSShadows(mode),
|
|
137
138
|
spacing: appleSpacing(),
|
|
138
139
|
components: appleComponents,
|
|
139
140
|
host: { appearance: isLightMode ? 'light' : 'dark' },
|
package/src/appleTheme.macos.ts
CHANGED
|
@@ -73,11 +73,11 @@ export const appleComponents = {
|
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
function getBaseAppleThemeMacOSWorker(mode: AppearanceOptions): Theme {
|
|
76
|
+
function getBaseAppleThemeMacOSWorker(mode: AppearanceOptions, highContrast: boolean): Theme {
|
|
77
77
|
return {
|
|
78
|
-
colors: fallbackApplePalette(mode),
|
|
78
|
+
colors: fallbackApplePalette(mode, highContrast),
|
|
79
79
|
typography: fallbackAppleTypography(),
|
|
80
|
-
shadows: fallbackAppleShadows(mode),
|
|
80
|
+
shadows: fallbackAppleShadows(mode, highContrast),
|
|
81
81
|
spacing: appleSpacing(),
|
|
82
82
|
components: appleComponents,
|
|
83
83
|
host: { appearance: 'dynamic' },
|
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
import { Appearance, NativeEventEmitter } from 'react-native';
|
|
2
2
|
|
|
3
3
|
import { NativeAppearanceAdditions } from '@fluentui-react-native/experimental-appearance-additions';
|
|
4
|
-
import { ThemeReference } from '@fluentui-react-native/design/theming';
|
|
4
|
+
import { createThemeAppearanceSource, ThemeReference } from '@fluentui-react-native/design/theming';
|
|
5
5
|
import type { Theme } from '@fluentui-react-native/design/theming';
|
|
6
6
|
|
|
7
7
|
import { getBaseAppleThemeIOS } from './appleTheme.ios';
|
|
8
8
|
|
|
9
9
|
export function createAppleTheme(): ThemeReference {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const appearanceSource = createThemeAppearanceSource(
|
|
11
|
+
() => ({
|
|
12
|
+
colorScheme: Appearance.getColorScheme(),
|
|
13
|
+
interfaceLevel: NativeAppearanceAdditions.userInterfaceLevel() === 'elevated' ? 'elevated' : 'base',
|
|
14
|
+
}),
|
|
15
|
+
(listener) => {
|
|
16
|
+
const appearanceSubscription = Appearance.addChangeListener(listener);
|
|
17
|
+
const eventEmitter = new NativeEventEmitter(NativeAppearanceAdditions);
|
|
18
|
+
const interfaceLevelSubscription = eventEmitter.addListener('appearanceChanged', listener);
|
|
19
|
+
return () => {
|
|
20
|
+
appearanceSubscription.remove();
|
|
21
|
+
interfaceLevelSubscription.remove();
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
return new ThemeReference({
|
|
26
|
+
base: {} as Theme,
|
|
27
|
+
appearance: {
|
|
28
|
+
colorScheme: 'system',
|
|
29
|
+
contrast: 'system',
|
|
30
|
+
interfaceLevel: 'system',
|
|
31
|
+
},
|
|
32
|
+
appearanceSource,
|
|
33
|
+
recipes: [
|
|
34
|
+
(_theme, appearance) => {
|
|
35
|
+
const isLightMode = appearance ? appearance.colorScheme === 'light' : Appearance.getColorScheme() === 'light';
|
|
36
|
+
const isElevated = appearance
|
|
37
|
+
? appearance.interfaceLevel === 'elevated'
|
|
38
|
+
: NativeAppearanceAdditions.userInterfaceLevel() === 'elevated';
|
|
39
|
+
return getBaseAppleThemeIOS(isLightMode, isElevated);
|
|
40
|
+
},
|
|
41
|
+
],
|
|
14
42
|
});
|
|
15
|
-
|
|
16
|
-
Appearance.addChangeListener(() => {
|
|
17
|
-
appleThemeReference.invalidate();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const eventEmitter = new NativeEventEmitter(NativeAppearanceAdditions);
|
|
21
|
-
eventEmitter.addListener('appearanceChanged', (_newTraits) => {
|
|
22
|
-
appleThemeReference.invalidate();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return appleThemeReference;
|
|
26
43
|
}
|
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
import { Appearance } from 'react-native';
|
|
2
2
|
|
|
3
|
-
import { getCurrentAppearance,
|
|
3
|
+
import { getCurrentAppearance, isHighContrast, ThemeReference } from '@fluentui-react-native/design/theming';
|
|
4
4
|
import type { Theme } from '@fluentui-react-native/design/theming';
|
|
5
|
-
import { AccessibilityInfo } from 'react-native-macos';
|
|
6
5
|
|
|
7
6
|
import { getBaseAppleThemeMacOS } from './appleTheme.macos';
|
|
8
7
|
|
|
9
|
-
let appleThemeReference: ThemeReference;
|
|
10
|
-
|
|
11
8
|
export function createAppleTheme(): ThemeReference {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
return appleThemeReference;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function highContrastHandler() {
|
|
31
|
-
AccessibilityInfo.isHighContrastEnabled().then((isEnabled) => {
|
|
32
|
-
setIsHighContrast(isEnabled);
|
|
33
|
-
appleThemeReference.invalidate();
|
|
9
|
+
return new ThemeReference({
|
|
10
|
+
base: {} as Theme,
|
|
11
|
+
appearance: {
|
|
12
|
+
colorScheme: 'system',
|
|
13
|
+
contrast: 'system',
|
|
14
|
+
interfaceLevel: 'base',
|
|
15
|
+
},
|
|
16
|
+
recipes: [
|
|
17
|
+
(_theme, appearance) => {
|
|
18
|
+
const mode = appearance?.colorScheme ?? getCurrentAppearance(Appearance.getColorScheme(), 'light');
|
|
19
|
+
const highContrast = appearance ? appearance.contrast === 'highContrast' : isHighContrast();
|
|
20
|
+
return getBaseAppleThemeMacOS(mode, highContrast);
|
|
21
|
+
},
|
|
22
|
+
],
|
|
34
23
|
});
|
|
35
24
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import aliasTokens from '@fluentui-react-native/design-tokens-ios/light/tokens-aliases.json'; // Font alias tokens should be the same for all color styles
|
|
2
2
|
import { memoize } from '@fluentui-react-native/framework-base';
|
|
3
3
|
import type { Variants } from '@fluentui-react-native/design/theming';
|
|
4
|
-
import { mapFontPipelineToTheme } from '@fluentui-react-native/theming
|
|
4
|
+
import { mapFontPipelineToTheme } from '@fluentui-react-native/design/theming';
|
|
5
5
|
|
|
6
6
|
function createFontAliasTokensWorker(): Partial<Variants> {
|
|
7
7
|
return mapFontPipelineToTheme(aliasTokens);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { memoize } from '@fluentui-react-native/framework-base';
|
|
2
2
|
import type { AliasColorTokens, AppearanceOptions } from '@fluentui-react-native/design/theming';
|
|
3
3
|
import type { ThemeShadowDefinition } from '@fluentui-react-native/design/theming';
|
|
4
|
-
import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/theming
|
|
4
|
+
import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/design/theming';
|
|
5
5
|
|
|
6
6
|
import { getMacOSAliasTokens, getMacOSShadowTokens } from './getMacOSTokens';
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { memoize } from '@fluentui-react-native/framework-base';
|
|
2
|
-
import { getAliasTokens, getShadowTokens } from '@fluentui-react-native/
|
|
2
|
+
import { getAliasTokens, getShadowTokens } from '@fluentui-react-native/design/tokens/legacy';
|
|
3
3
|
import type { AliasColorTokens, AppearanceOptions } from '@fluentui-react-native/design/theming';
|
|
4
4
|
import type { ThemeShadowDefinition } from '@fluentui-react-native/design/theming';
|
|
5
|
-
import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/theming
|
|
5
|
+
import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/design/theming';
|
|
6
6
|
|
|
7
7
|
function createiOSColorAliasTokensWorker(mode: AppearanceOptions): AliasColorTokens {
|
|
8
8
|
const aliasTokens = getAliasTokens(mode);
|