@fluentui-react-native/apple-theme 0.17.8 → 0.18.0
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 +61 -1
- package/CHANGELOG.md +23 -2
- package/lib/__tests__/apple-theme.test.js +8 -4
- package/lib/__tests__/apple-theme.test.js.map +1 -1
- package/lib/appleColors.ios.d.ts.map +1 -1
- package/lib/appleColors.ios.js +21 -174
- package/lib/appleColors.ios.js.map +1 -1
- package/lib/createiOSAliasTokens.d.ts +3 -1
- package/lib/createiOSAliasTokens.d.ts.map +1 -1
- package/lib/createiOSAliasTokens.js +8 -3
- package/lib/createiOSAliasTokens.js.map +1 -1
- package/lib-commonjs/__tests__/apple-theme.test.js +8 -4
- package/lib-commonjs/__tests__/apple-theme.test.js.map +1 -1
- package/lib-commonjs/appleColors.ios.d.ts.map +1 -1
- package/lib-commonjs/appleColors.ios.js +21 -174
- package/lib-commonjs/appleColors.ios.js.map +1 -1
- package/lib-commonjs/createiOSAliasTokens.d.ts +3 -1
- package/lib-commonjs/createiOSAliasTokens.d.ts.map +1 -1
- package/lib-commonjs/createiOSAliasTokens.js +8 -3
- package/lib-commonjs/createiOSAliasTokens.js.map +1 -1
- package/package.json +7 -6
- package/src/__tests__/__snapshots__/apple-theme.test.ts.snap +730 -307
- package/src/__tests__/apple-theme.test.ts +9 -4
- package/src/appleColors.ios.ts +10 -0
- package/src/createiOSAliasTokens.ts +11 -4
- package/lib/getiOSTokens.d.ts +0 -76
- package/lib/getiOSTokens.d.ts.map +0 -1
- package/lib/getiOSTokens.js +0 -18
- package/lib/getiOSTokens.js.map +0 -1
- package/lib-commonjs/getiOSTokens.d.ts +0 -76
- package/lib-commonjs/getiOSTokens.d.ts.map +0 -1
- package/lib-commonjs/getiOSTokens.js +0 -25
- package/lib-commonjs/getiOSTokens.js.map +0 -1
- package/src/getiOSTokens.ts +0 -16
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { createAppleTheme } from '../createAppleTheme';
|
|
2
1
|
import { createMacOSColorAliasTokens, createMacOSShadowAliasTokens } from '../createMacOSAliasTokens';
|
|
3
2
|
import { getIsHighContrast, setIsHighContrast } from '../appleHighContrast.macos';
|
|
4
3
|
import { AppearanceOptions } from '@fluentui-react-native/theme-types';
|
|
4
|
+
import { createAppleTheme } from '../createAppleTheme';
|
|
5
|
+
|
|
6
|
+
// For some reason the automatically mocked AccessibilityInfo object is the react-native version, not the
|
|
7
|
+
// react-native-macos version, which doesn't contain the isHighContrastEnabled function that is accessed in
|
|
8
|
+
// createAppleTheme. Use the actual module instead
|
|
9
|
+
jest.dontMock('react-native-macos/Libraries/Components/AccessibilityInfo/AccessibilityInfo');
|
|
5
10
|
|
|
6
|
-
const
|
|
11
|
+
const macOSAliasTokensTable: [AppearanceOptions, boolean][] = [
|
|
7
12
|
['light', true],
|
|
8
13
|
['light', false],
|
|
9
14
|
['dark', true],
|
|
@@ -23,7 +28,7 @@ it('IsHighContrast test', () => {
|
|
|
23
28
|
expect(getIsHighContrast()).toBe(true);
|
|
24
29
|
});
|
|
25
30
|
|
|
26
|
-
it.concurrent.each(
|
|
31
|
+
it.concurrent.each(macOSAliasTokensTable)(
|
|
27
32
|
'createMacOSColorAliasTokens test mode: %s, isHighContrast: %p',
|
|
28
33
|
async (mode: AppearanceOptions, isHighContrast: boolean) => {
|
|
29
34
|
if (mode === 'highContrast') {
|
|
@@ -34,7 +39,7 @@ it.concurrent.each(macOsAliasTokensTable)(
|
|
|
34
39
|
},
|
|
35
40
|
);
|
|
36
41
|
|
|
37
|
-
it.concurrent.each(
|
|
42
|
+
it.concurrent.each(macOSAliasTokensTable)(
|
|
38
43
|
'createMacOSShadowAliasTokens test mode: %s, isHighContrast: %p',
|
|
39
44
|
async (mode: AppearanceOptions, isHighContrast: boolean) => {
|
|
40
45
|
if (mode === 'highContrast') {
|
package/src/appleColors.ios.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ThemeColorDefinition } from '@fluentui-react-native/theme-types';
|
|
2
|
+
import { getCurrentAppearance } from '@fluentui-react-native/theming-utils';
|
|
3
|
+
import { Appearance } from 'react-native';
|
|
2
4
|
import { ApplePalette } from './appleColors.types.ios';
|
|
5
|
+
import { createiOSColorAliasTokens } from './createiOSAliasTokens';
|
|
3
6
|
|
|
4
7
|
function getFluentUIAppleLightPalette(): ApplePalette {
|
|
5
8
|
return {
|
|
@@ -215,7 +218,14 @@ function getFluentUIAppleDarkPalette(): ApplePalette {
|
|
|
215
218
|
export function paletteFromAppleColors(isLightMode: boolean): ThemeColorDefinition {
|
|
216
219
|
const fluentApple = isLightMode ? getFluentUIAppleLightPalette() : getFluentUIAppleDarkPalette();
|
|
217
220
|
|
|
221
|
+
const appearance = Appearance.getColorScheme();
|
|
222
|
+
const mode = getCurrentAppearance(appearance, 'light');
|
|
223
|
+
|
|
218
224
|
return {
|
|
225
|
+
/* Color Alias Tokens */
|
|
226
|
+
|
|
227
|
+
...createiOSColorAliasTokens(mode),
|
|
228
|
+
|
|
219
229
|
/* PaletteBackgroundColors & PaletteTextColors */
|
|
220
230
|
|
|
221
231
|
background: fluentApple.surfacePrimary,
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AppearanceOptions } from '@fluentui-react-native/theme-types';
|
|
3
|
-
import { mapPipelineToShadow } from '@fluentui-react-native/theming-utils';
|
|
1
|
+
import { getAliasTokens, getShadowTokens } from '@fluentui-react-native/theme-tokens';
|
|
2
|
+
import { AliasColorTokens, AppearanceOptions } from '@fluentui-react-native/theme-types';
|
|
3
|
+
import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/theming-utils';
|
|
4
4
|
import { memoize } from '@fluentui-react-native/memo-cache';
|
|
5
5
|
import { ThemeShadowDefinition } from '@fluentui-react-native/theme-types/lib/Shadow.types';
|
|
6
6
|
|
|
7
|
+
function createiOSColorAliasTokensWorker(mode: AppearanceOptions): AliasColorTokens {
|
|
8
|
+
const aliasTokens = getAliasTokens(mode);
|
|
9
|
+
return mapPipelineToTheme(aliasTokens);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const createiOSColorAliasTokens = memoize(createiOSColorAliasTokensWorker);
|
|
13
|
+
|
|
7
14
|
function createiOSShadowAliasTokensWorker(mode: AppearanceOptions): ThemeShadowDefinition {
|
|
8
|
-
const aliasTokens =
|
|
15
|
+
const aliasTokens = getShadowTokens(mode);
|
|
9
16
|
return mapPipelineToShadow(aliasTokens);
|
|
10
17
|
}
|
|
11
18
|
|
package/lib/getiOSTokens.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AppearanceOptions } from '@fluentui-react-native/theme-types';
|
|
2
|
-
export declare function getiOSShadowTokens(mode: AppearanceOptions): {
|
|
3
|
-
shadow16: {
|
|
4
|
-
x: number;
|
|
5
|
-
y: number;
|
|
6
|
-
blur: number;
|
|
7
|
-
color: string;
|
|
8
|
-
}[];
|
|
9
|
-
shadow2: {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
blur: number;
|
|
13
|
-
color: string;
|
|
14
|
-
}[];
|
|
15
|
-
shadow28: {
|
|
16
|
-
x: number;
|
|
17
|
-
y: number;
|
|
18
|
-
blur: number;
|
|
19
|
-
color: string;
|
|
20
|
-
}[];
|
|
21
|
-
shadow4: {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
blur: number;
|
|
25
|
-
color: string;
|
|
26
|
-
}[];
|
|
27
|
-
shadow64: {
|
|
28
|
-
x: number;
|
|
29
|
-
y: number;
|
|
30
|
-
blur: number;
|
|
31
|
-
color: string;
|
|
32
|
-
}[];
|
|
33
|
-
shadow8: {
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
blur: number;
|
|
37
|
-
color: string;
|
|
38
|
-
}[];
|
|
39
|
-
shadowBrand16: {
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
blur: number;
|
|
43
|
-
color: string;
|
|
44
|
-
}[];
|
|
45
|
-
shadowBrand2: {
|
|
46
|
-
x: number;
|
|
47
|
-
y: number;
|
|
48
|
-
blur: number;
|
|
49
|
-
color: string;
|
|
50
|
-
}[];
|
|
51
|
-
shadowBrand28: {
|
|
52
|
-
x: number;
|
|
53
|
-
y: number;
|
|
54
|
-
blur: number;
|
|
55
|
-
color: string;
|
|
56
|
-
}[];
|
|
57
|
-
shadowBrand4: {
|
|
58
|
-
x: number;
|
|
59
|
-
y: number;
|
|
60
|
-
blur: number;
|
|
61
|
-
color: string;
|
|
62
|
-
}[];
|
|
63
|
-
shadowBrand64: {
|
|
64
|
-
x: number;
|
|
65
|
-
y: number;
|
|
66
|
-
blur: number;
|
|
67
|
-
color: string;
|
|
68
|
-
}[];
|
|
69
|
-
shadowBrand8: {
|
|
70
|
-
x: number;
|
|
71
|
-
y: number;
|
|
72
|
-
blur: number;
|
|
73
|
-
color: string;
|
|
74
|
-
}[];
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=getiOSTokens.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getiOSTokens.d.ts","sourceRoot":"","sources":["../src/getiOSTokens.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUzD"}
|
package/lib/getiOSTokens.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import iOSLightShadowTokens from '@fluentui-react-native/design-tokens-ios/light/tokens-shadow.json';
|
|
2
|
-
import iOSDarkShadowTokens from '@fluentui-react-native/design-tokens-ios/dark/tokens-shadow.json';
|
|
3
|
-
import { assertNever } from 'assert-never';
|
|
4
|
-
export function getiOSShadowTokens(mode) {
|
|
5
|
-
if (mode === 'light') {
|
|
6
|
-
return iOSLightShadowTokens;
|
|
7
|
-
}
|
|
8
|
-
else if (mode === 'dark') {
|
|
9
|
-
return iOSDarkShadowTokens;
|
|
10
|
-
}
|
|
11
|
-
else if (mode === 'highContrast') {
|
|
12
|
-
throw new Error('highContrast is not a valid AppearanceOptions on iOS');
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
assertNever(mode);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=getiOSTokens.js.map
|
package/lib/getiOSTokens.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getiOSTokens.js","sourceRoot":"","sources":["../src/getiOSTokens.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,mEAAmE,CAAC;AACrG,OAAO,mBAAmB,MAAM,kEAAkE,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,UAAU,kBAAkB,CAAC,IAAuB;IACxD,IAAI,IAAI,KAAK,OAAO,EAAE;QACpB,OAAO,oBAAoB,CAAC;KAC7B;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE;QAC1B,OAAO,mBAAmB,CAAC;KAC5B;SAAM,IAAI,IAAI,KAAK,cAAc,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;KACzE;SAAM;QACL,WAAW,CAAC,IAAI,CAAC,CAAC;KACnB;AACH,CAAC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AppearanceOptions } from '@fluentui-react-native/theme-types';
|
|
2
|
-
export declare function getiOSShadowTokens(mode: AppearanceOptions): {
|
|
3
|
-
shadow16: {
|
|
4
|
-
x: number;
|
|
5
|
-
y: number;
|
|
6
|
-
blur: number;
|
|
7
|
-
color: string;
|
|
8
|
-
}[];
|
|
9
|
-
shadow2: {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
blur: number;
|
|
13
|
-
color: string;
|
|
14
|
-
}[];
|
|
15
|
-
shadow28: {
|
|
16
|
-
x: number;
|
|
17
|
-
y: number;
|
|
18
|
-
blur: number;
|
|
19
|
-
color: string;
|
|
20
|
-
}[];
|
|
21
|
-
shadow4: {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
blur: number;
|
|
25
|
-
color: string;
|
|
26
|
-
}[];
|
|
27
|
-
shadow64: {
|
|
28
|
-
x: number;
|
|
29
|
-
y: number;
|
|
30
|
-
blur: number;
|
|
31
|
-
color: string;
|
|
32
|
-
}[];
|
|
33
|
-
shadow8: {
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
blur: number;
|
|
37
|
-
color: string;
|
|
38
|
-
}[];
|
|
39
|
-
shadowBrand16: {
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
blur: number;
|
|
43
|
-
color: string;
|
|
44
|
-
}[];
|
|
45
|
-
shadowBrand2: {
|
|
46
|
-
x: number;
|
|
47
|
-
y: number;
|
|
48
|
-
blur: number;
|
|
49
|
-
color: string;
|
|
50
|
-
}[];
|
|
51
|
-
shadowBrand28: {
|
|
52
|
-
x: number;
|
|
53
|
-
y: number;
|
|
54
|
-
blur: number;
|
|
55
|
-
color: string;
|
|
56
|
-
}[];
|
|
57
|
-
shadowBrand4: {
|
|
58
|
-
x: number;
|
|
59
|
-
y: number;
|
|
60
|
-
blur: number;
|
|
61
|
-
color: string;
|
|
62
|
-
}[];
|
|
63
|
-
shadowBrand64: {
|
|
64
|
-
x: number;
|
|
65
|
-
y: number;
|
|
66
|
-
blur: number;
|
|
67
|
-
color: string;
|
|
68
|
-
}[];
|
|
69
|
-
shadowBrand8: {
|
|
70
|
-
x: number;
|
|
71
|
-
y: number;
|
|
72
|
-
blur: number;
|
|
73
|
-
color: string;
|
|
74
|
-
}[];
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=getiOSTokens.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getiOSTokens.d.ts","sourceRoot":"","sources":["../src/getiOSTokens.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUzD"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getiOSShadowTokens = void 0;
|
|
7
|
-
var tokens_shadow_json_1 = __importDefault(require("@fluentui-react-native/design-tokens-ios/light/tokens-shadow.json"));
|
|
8
|
-
var tokens_shadow_json_2 = __importDefault(require("@fluentui-react-native/design-tokens-ios/dark/tokens-shadow.json"));
|
|
9
|
-
var assert_never_1 = require("assert-never");
|
|
10
|
-
function getiOSShadowTokens(mode) {
|
|
11
|
-
if (mode === 'light') {
|
|
12
|
-
return tokens_shadow_json_1.default;
|
|
13
|
-
}
|
|
14
|
-
else if (mode === 'dark') {
|
|
15
|
-
return tokens_shadow_json_2.default;
|
|
16
|
-
}
|
|
17
|
-
else if (mode === 'highContrast') {
|
|
18
|
-
throw new Error('highContrast is not a valid AppearanceOptions on iOS');
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
(0, assert_never_1.assertNever)(mode);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.getiOSShadowTokens = getiOSShadowTokens;
|
|
25
|
-
//# sourceMappingURL=getiOSTokens.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getiOSTokens.js","sourceRoot":"","sources":["../src/getiOSTokens.ts"],"names":[],"mappings":";;;;;;AAAA,yHAAqG;AACrG,wHAAmG;AAEnG,6CAA2C;AAE3C,SAAgB,kBAAkB,CAAC,IAAuB;IACxD,IAAI,IAAI,KAAK,OAAO,EAAE;QACpB,OAAO,4BAAoB,CAAC;KAC7B;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE;QAC1B,OAAO,4BAAmB,CAAC;KAC5B;SAAM,IAAI,IAAI,KAAK,cAAc,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;KACzE;SAAM;QACL,IAAA,0BAAW,EAAC,IAAI,CAAC,CAAC;KACnB;AACH,CAAC;AAVD,gDAUC"}
|
package/src/getiOSTokens.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import iOSLightShadowTokens from '@fluentui-react-native/design-tokens-ios/light/tokens-shadow.json';
|
|
2
|
-
import iOSDarkShadowTokens from '@fluentui-react-native/design-tokens-ios/dark/tokens-shadow.json';
|
|
3
|
-
import { AppearanceOptions } from '@fluentui-react-native/theme-types';
|
|
4
|
-
import { assertNever } from 'assert-never';
|
|
5
|
-
|
|
6
|
-
export function getiOSShadowTokens(mode: AppearanceOptions) {
|
|
7
|
-
if (mode === 'light') {
|
|
8
|
-
return iOSLightShadowTokens;
|
|
9
|
-
} else if (mode === 'dark') {
|
|
10
|
-
return iOSDarkShadowTokens;
|
|
11
|
-
} else if (mode === 'highContrast') {
|
|
12
|
-
throw new Error('highContrast is not a valid AppearanceOptions on iOS');
|
|
13
|
-
} else {
|
|
14
|
-
assertNever(mode);
|
|
15
|
-
}
|
|
16
|
-
}
|