@fluentui-react-native/tester 0.128.2 → 0.129.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 +271 -1
- package/CHANGELOG.md +53 -2
- package/docs/android.md +7 -16
- package/docs/ios.md +7 -16
- package/docs/macos.md +7 -16
- package/docs/windows.md +7 -16
- package/lib/fluent-tester/src/FluentTester.js +1 -1
- package/lib/fluent-tester/src/FluentTester.js.map +1 -1
- package/lib/fluent-tester/src/FluentTesterApp.d.ts.map +1 -1
- package/lib/fluent-tester/src/FluentTesterApp.js +3 -30
- package/lib/fluent-tester/src/FluentTesterApp.js.map +1 -1
- package/lib/fluent-tester/src/TestComponents/ColorTokens/ColorTokenTest.d.ts.map +1 -1
- package/lib/fluent-tester/src/TestComponents/ColorTokens/ColorTokenTest.js +111 -23
- package/lib/fluent-tester/src/TestComponents/ColorTokens/ColorTokenTest.js.map +1 -1
- package/lib-commonjs/fluent-tester/src/FluentTester.js +1 -1
- package/lib-commonjs/fluent-tester/src/FluentTester.js.map +1 -1
- package/lib-commonjs/fluent-tester/src/FluentTesterApp.d.ts.map +1 -1
- package/lib-commonjs/fluent-tester/src/FluentTesterApp.js +2 -29
- package/lib-commonjs/fluent-tester/src/FluentTesterApp.js.map +1 -1
- package/lib-commonjs/fluent-tester/src/TestComponents/ColorTokens/ColorTokenTest.d.ts.map +1 -1
- package/lib-commonjs/fluent-tester/src/TestComponents/ColorTokens/ColorTokenTest.js +109 -21
- package/lib-commonjs/fluent-tester/src/TestComponents/ColorTokens/ColorTokenTest.js.map +1 -1
- package/package.json +74 -60
- package/src/FluentTester.tsx +1 -1
- package/src/FluentTesterApp.tsx +3 -31
- package/src/TestComponents/ColorTokens/ColorTokenTest.tsx +147 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/tester",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.129.0",
|
|
4
4
|
"description": "A test app to test FluentUI React Native Components during development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Microsoft <fluentuinativeowners@microsoft.com>",
|
|
@@ -33,71 +33,71 @@
|
|
|
33
33
|
"directory": "apps/fluent-tester"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@fluentui-react-native/android-theme": ">=0.16.
|
|
37
|
-
"@fluentui-react-native/apple-theme": ">=0.18.
|
|
38
|
-
"@fluentui-react-native/avatar": "^1.6.
|
|
39
|
-
"@fluentui-react-native/badge": ">=0.4.
|
|
40
|
-
"@fluentui-react-native/button": ">=0.32.
|
|
41
|
-
"@fluentui-react-native/default-theme": ">=0.16.
|
|
42
|
-
"@fluentui-react-native/dropdown": ">=0.7.
|
|
43
|
-
"@fluentui-react-native/experimental-activity-indicator": ">=0.7.
|
|
44
|
-
"@fluentui-react-native/experimental-
|
|
45
|
-
"@fluentui-react-native/experimental-
|
|
46
|
-
"@fluentui-react-native/experimental-
|
|
47
|
-
"@fluentui-react-native/experimental-
|
|
48
|
-
"@fluentui-react-native/experimental-
|
|
36
|
+
"@fluentui-react-native/android-theme": ">=0.16.2 <1.0.0",
|
|
37
|
+
"@fluentui-react-native/apple-theme": ">=0.18.5 <1.0.0",
|
|
38
|
+
"@fluentui-react-native/avatar": "^1.6.1",
|
|
39
|
+
"@fluentui-react-native/badge": ">=0.4.22 <1.0.0",
|
|
40
|
+
"@fluentui-react-native/button": ">=0.32.26 <1.0.0",
|
|
41
|
+
"@fluentui-react-native/default-theme": ">=0.16.27 <1.0.0",
|
|
42
|
+
"@fluentui-react-native/dropdown": ">=0.7.21 <1.0.0",
|
|
43
|
+
"@fluentui-react-native/experimental-activity-indicator": ">=0.7.14 <1.0.0",
|
|
44
|
+
"@fluentui-react-native/experimental-appearance-additions": "^0.2.1",
|
|
45
|
+
"@fluentui-react-native/experimental-avatar": ">=0.17.11 <1.0.0",
|
|
46
|
+
"@fluentui-react-native/experimental-button": "0.16.84",
|
|
47
|
+
"@fluentui-react-native/experimental-checkbox": "0.13.33",
|
|
48
|
+
"@fluentui-react-native/experimental-expander": "0.5.14",
|
|
49
|
+
"@fluentui-react-native/experimental-menu-button": ">=0.6.23 <1.0.0",
|
|
49
50
|
"@fluentui-react-native/experimental-native-date-picker": ">=0.7.4 <1.0.0",
|
|
50
|
-
"@fluentui-react-native/experimental-radio-group": "^0.9.
|
|
51
|
-
"@fluentui-react-native/experimental-shadow": "0.2.
|
|
52
|
-
"@fluentui-react-native/experimental-shimmer": "0.8.
|
|
53
|
-
"@fluentui-react-native/experimental-tabs": "0.8.
|
|
54
|
-
"@fluentui-react-native/experimental-text": ">=0.11.
|
|
55
|
-
"@fluentui-react-native/framework": ">=0.8.
|
|
56
|
-
"@fluentui-react-native/icon": "0.17.
|
|
57
|
-
"@fluentui-react-native/interactive-hooks": ">=0.22.
|
|
58
|
-
"@fluentui-react-native/menu": "^1.2.
|
|
51
|
+
"@fluentui-react-native/experimental-radio-group": "^0.9.14",
|
|
52
|
+
"@fluentui-react-native/experimental-shadow": "0.2.63",
|
|
53
|
+
"@fluentui-react-native/experimental-shimmer": "0.8.14",
|
|
54
|
+
"@fluentui-react-native/experimental-tabs": "0.8.28",
|
|
55
|
+
"@fluentui-react-native/experimental-text": ">=0.11.47 <1.0.0",
|
|
56
|
+
"@fluentui-react-native/framework": ">=0.8.37 <1.0.0",
|
|
57
|
+
"@fluentui-react-native/icon": "0.17.8",
|
|
58
|
+
"@fluentui-react-native/interactive-hooks": ">=0.22.14 <1.0.0",
|
|
59
|
+
"@fluentui-react-native/menu": "^1.2.24",
|
|
59
60
|
"@fluentui-react-native/merge-props": ">=0.5.1 <1.0.0",
|
|
60
|
-
"@fluentui-react-native/
|
|
61
|
-
"@fluentui-react-native/
|
|
62
|
-
"@fluentui-react-native/stack": ">=0.7.
|
|
63
|
-
"@fluentui-react-native/switch": "^0.8.
|
|
64
|
-
"@fluentui-react-native/text": ">=0.19.
|
|
65
|
-
"@fluentui-react-native/theme": ">=0.7.
|
|
66
|
-
"@fluentui-react-native/theme-tokens": "^0.24.
|
|
67
|
-
"@fluentui-react-native/theme-types": ">=0.30.
|
|
61
|
+
"@fluentui-react-native/notification": "0.21.22",
|
|
62
|
+
"@fluentui-react-native/separator": "^0.14.11",
|
|
63
|
+
"@fluentui-react-native/stack": ">=0.7.48 <1.0.0",
|
|
64
|
+
"@fluentui-react-native/switch": "^0.8.20",
|
|
65
|
+
"@fluentui-react-native/text": ">=0.19.16 <1.0.0",
|
|
66
|
+
"@fluentui-react-native/theme": ">=0.7.19 <1.0.0",
|
|
67
|
+
"@fluentui-react-native/theme-tokens": "^0.24.1",
|
|
68
|
+
"@fluentui-react-native/theme-types": ">=0.30.1 <1.0.0",
|
|
68
69
|
"@fluentui-react-native/themed-stylesheet": "^1.4.1",
|
|
69
|
-
"@fluentui-react-native/theming-utils": ">=0.23.
|
|
70
|
-
"@fluentui-react-native/win32-theme": ">=0.24.
|
|
71
|
-
"@fluentui/react-native": ">=0.35.
|
|
70
|
+
"@fluentui-react-native/theming-utils": ">=0.23.1 <1.0.0",
|
|
71
|
+
"@fluentui-react-native/win32-theme": ">=0.24.14 <1.0.0",
|
|
72
|
+
"@fluentui/react-native": ">=0.35.13 <1.0.0",
|
|
72
73
|
"@fortawesome/fontawesome-svg-core": "^6.2.0",
|
|
73
74
|
"@fortawesome/free-solid-svg-icons": "^6.2.0",
|
|
74
75
|
"@fortawesome/react-native-fontawesome": "^0.3.0",
|
|
75
76
|
"@react-native-community/slider": "^4.2.0",
|
|
76
77
|
"@react-native-menu/menu": "^0.1.2",
|
|
77
78
|
"@react-native-picker/picker": "^2.2.1",
|
|
79
|
+
"@warren-ms/react-native-icons": "^0.0.13",
|
|
78
80
|
"react": "17.0.2",
|
|
79
|
-
"react-dom": "17.0.2",
|
|
80
81
|
"react-native": "^0.68.0",
|
|
81
82
|
"react-native-macos": "^0.68.0",
|
|
82
|
-
"react-native-svg": "12.
|
|
83
|
+
"react-native-svg": "^12.3.0",
|
|
83
84
|
"react-native-windows": "^0.68.0",
|
|
84
|
-
"tslib": "^2.3.1"
|
|
85
|
-
"@warren-ms/react-native-icons": "^0.0.13"
|
|
85
|
+
"tslib": "^2.3.1"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@babel/core": "^7.8.0",
|
|
89
89
|
"@babel/runtime": "^7.8.0",
|
|
90
90
|
"@fluentui-react-native/eslint-config-rules": "^0.1.1",
|
|
91
|
+
"@fluentui-react-native/focus-zone": "^0.11.26",
|
|
91
92
|
"@fluentui-react-native/scripts": "^0.1.1",
|
|
92
|
-
"@rnx-kit/cli": "^0.
|
|
93
|
+
"@rnx-kit/cli": "^0.16.2",
|
|
93
94
|
"@rnx-kit/metro-config": "^1.3.1",
|
|
94
95
|
"flow-bin": "^0.113.0",
|
|
95
96
|
"metro-config": "^0.67.0",
|
|
96
97
|
"metro-react-native-babel-preset": "^0.67.0",
|
|
97
98
|
"react-native-svg-transformer": "^1.0.0",
|
|
98
99
|
"react-native-test-app": "^2.0.2",
|
|
99
|
-
"react-test-renderer": "17.0.2"
|
|
100
|
-
"@fluentui-react-native/focus-zone": "^0.11.25"
|
|
100
|
+
"react-test-renderer": "17.0.2"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
103
|
"@office-iss/react-native-win32": "^0.68.0"
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
"preset": "react-native"
|
|
107
107
|
},
|
|
108
108
|
"rnx-kit": {
|
|
109
|
-
"reactNativeVersion": "^0.68",
|
|
110
109
|
"kitType": "app",
|
|
111
110
|
"bundle": [
|
|
112
111
|
{
|
|
@@ -119,13 +118,20 @@
|
|
|
119
118
|
"macos",
|
|
120
119
|
"windows"
|
|
121
120
|
],
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
121
|
+
"plugins": [
|
|
122
|
+
[
|
|
123
|
+
"@rnx-kit/metro-plugin-cyclic-dependencies-detector",
|
|
124
|
+
{
|
|
125
|
+
"throwOnError": true
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
"@rnx-kit/metro-plugin-duplicates-checker",
|
|
130
|
+
{
|
|
131
|
+
"throwOnError": false
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
],
|
|
129
135
|
"platforms": {
|
|
130
136
|
"android": {
|
|
131
137
|
"bundleOutput": "dist/index.android.bundle",
|
|
@@ -147,17 +153,25 @@
|
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
],
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
"
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
"alignDeps": {
|
|
157
|
+
"presets": [
|
|
158
|
+
"microsoft/react-native",
|
|
159
|
+
"@fluentui-react-native/scripts/align-deps-preset.js"
|
|
160
|
+
],
|
|
161
|
+
"requirements": [
|
|
162
|
+
"react-native@0.68"
|
|
163
|
+
],
|
|
164
|
+
"capabilities": [
|
|
165
|
+
"core-android",
|
|
166
|
+
"core-ios",
|
|
167
|
+
"core-macos",
|
|
168
|
+
"core-windows",
|
|
169
|
+
"babel-preset-react-native",
|
|
170
|
+
"metro-config",
|
|
171
|
+
"react",
|
|
172
|
+
"svg"
|
|
173
|
+
]
|
|
174
|
+
}
|
|
161
175
|
},
|
|
162
176
|
"depcheck": {
|
|
163
177
|
"ignoreMatches": [
|
package/src/FluentTester.tsx
CHANGED
package/src/FluentTesterApp.tsx
CHANGED
|
@@ -2,41 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { ThemeProvider } from '@fluentui-react-native/theme';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { Platform
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
6
|
import { FluentTester, FluentTesterProps } from './FluentTester';
|
|
7
7
|
import { testerTheme } from './theme/index';
|
|
8
|
-
|
|
9
|
-
type SizeClassIOS = 'regular' | 'compact' | undefined;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Hook that "guesses" our Size Class on iOS based on our window width.
|
|
13
|
-
* Note: this is hacky and should not be used.
|
|
14
|
-
*
|
|
15
|
-
* For more information about Size Classes, see the following:
|
|
16
|
-
* https://developer.apple.com/documentation/uikit/uitraitcollection
|
|
17
|
-
* https://developer.apple.com/design/human-interface-guidelines/foundations/layout/#platform-considerations
|
|
18
|
-
* @returns SizeClassIOS: enum determining our size class
|
|
19
|
-
*/
|
|
20
|
-
const useSizeClassIOS_DO_NOT_USE: () => SizeClassIOS = () => {
|
|
21
|
-
if (Platform.OS === 'ios') {
|
|
22
|
-
/**
|
|
23
|
-
* Technically this violates the rules of hooks (calling hooks inside conditions) but Platform.OS checks are pretty non-conditional.
|
|
24
|
-
* This is necessary because useWindowDimensions() does not work in win32.
|
|
25
|
-
*/
|
|
26
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
27
|
-
const width = useWindowDimensions().width;
|
|
28
|
-
if (Platform.isPad && width > 375) {
|
|
29
|
-
return 'regular';
|
|
30
|
-
} else {
|
|
31
|
-
return 'compact';
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
8
|
+
import { useHorizontalSizeClass } from '@fluentui-react-native/experimental-appearance-additions';
|
|
37
9
|
|
|
38
10
|
export const FluentTesterApp: React.FunctionComponent<FluentTesterProps> = (props) => {
|
|
39
|
-
const sizeClass =
|
|
11
|
+
const sizeClass = useHorizontalSizeClass();
|
|
40
12
|
const isMobile = Platform.OS === 'android' || (Platform.OS === 'ios' && Platform.isPad === false);
|
|
41
13
|
|
|
42
14
|
// If on iPad we are presented in a Split View or Slide Over context, show the single pane view.
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { View, ViewStyle, StyleSheet, ColorValue } from 'react-native';
|
|
2
|
+
import { View, ViewStyle, StyleSheet, ColorValue, Platform } from 'react-native';
|
|
3
3
|
import { useTheme, Theme } from '@fluentui-react-native/theme-types';
|
|
4
4
|
import { themedStyleSheet } from '@fluentui-react-native/themed-stylesheet';
|
|
5
5
|
import { getCurrentAppearance } from '@fluentui-react-native/theming-utils';
|
|
6
6
|
import { createOfficeAliasTokens } from '@fluentui-react-native/win32-theme';
|
|
7
7
|
import { createAliasTokens } from '@fluentui-react-native/default-theme';
|
|
8
8
|
import { commonTestStyles } from '../Common/styles';
|
|
9
|
-
import { Text } from '@fluentui/react-native';
|
|
9
|
+
import { Text, ToggleButton } from '@fluentui/react-native';
|
|
10
10
|
import { Test, TestSection, PlatformStatus } from '../Test';
|
|
11
11
|
import { COLORTOKENS_TEST_COMPONENT, COLORTOKEN_TESTPAGE } from '../../../../E2E/src/ColorTokens/consts';
|
|
12
12
|
import { testProps } from '../Common/TestProps';
|
|
13
|
+
import { globalTokens } from '@fluentui-react-native/theme-tokens';
|
|
14
|
+
import Svg, { G, Path, SvgProps } from 'react-native-svg';
|
|
15
|
+
import { SvgIconProps } from '@fluentui-react-native/icon';
|
|
13
16
|
|
|
14
17
|
const getThemedStyles = themedStyleSheet((theme: Theme) => {
|
|
15
18
|
return {
|
|
@@ -29,52 +32,72 @@ const styles = StyleSheet.create({
|
|
|
29
32
|
alignItems: 'center',
|
|
30
33
|
marginVertical: 5,
|
|
31
34
|
},
|
|
32
|
-
pickerContainer: {
|
|
33
|
-
flexDirection: 'row',
|
|
34
|
-
justifyContent: 'space-evenly',
|
|
35
|
-
},
|
|
36
35
|
stackStyle: {
|
|
37
36
|
borderWidth: 2,
|
|
38
37
|
padding: 12,
|
|
39
38
|
margin: 8,
|
|
40
39
|
},
|
|
40
|
+
statusView: {
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'space-between',
|
|
44
|
+
margin: 8,
|
|
45
|
+
},
|
|
46
|
+
// Needed to ensure that with the button is toggled on, the top of the newly shown
|
|
47
|
+
// content is visible so the user knows to scroll down
|
|
48
|
+
toggleButtonAreaPadding: {
|
|
49
|
+
paddingBottom: 10,
|
|
50
|
+
},
|
|
41
51
|
});
|
|
42
52
|
|
|
43
|
-
const getSwatchColorStyle = (
|
|
44
|
-
styles[
|
|
45
|
-
return styles[
|
|
53
|
+
const getSwatchColorStyle = (colorName: string, colorValue: ColorValue): ViewStyle => {
|
|
54
|
+
styles[colorName] = styles[colorName] || { backgroundColor: colorValue };
|
|
55
|
+
return styles[colorName];
|
|
46
56
|
};
|
|
47
57
|
|
|
48
|
-
type ColorTokenProps = {
|
|
58
|
+
type ColorTokenProps = { colorValue: ColorValue; colorName: string };
|
|
49
59
|
const ColorToken: React.FunctionComponent<ColorTokenProps> = (p: ColorTokenProps) => {
|
|
60
|
+
if (p.colorValue === undefined) {
|
|
61
|
+
console.warn('Color token ' + p.colorName + ' is undefined');
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
const themedStyles = getThemedStyles(useTheme());
|
|
51
65
|
return (
|
|
52
66
|
<View style={styles.swatchItem}>
|
|
53
67
|
<View
|
|
54
|
-
style={[getSwatchColorStyle(p.
|
|
68
|
+
style={[getSwatchColorStyle(p.colorName, p.colorValue), themedStyles.swatch]}
|
|
55
69
|
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
|
|
56
70
|
{...testProps(COLORTOKENS_TEST_COMPONENT)}
|
|
57
71
|
/>
|
|
58
|
-
<Text>{p.
|
|
72
|
+
<Text>{p.colorName + ' (' + p.colorValue?.toString() + ')'}</Text>
|
|
59
73
|
</View>
|
|
60
74
|
);
|
|
61
75
|
};
|
|
62
76
|
|
|
63
|
-
const
|
|
77
|
+
const getSwatch = (item) => {
|
|
78
|
+
const { colorValue, colorName } = item;
|
|
79
|
+
return <ColorToken key={colorName} colorValue={colorValue} colorName={colorName} />;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/// Alias color tokens
|
|
83
|
+
|
|
84
|
+
const AliasColorTokensSwatchList: React.FunctionComponent = () => {
|
|
64
85
|
const theme = useTheme();
|
|
86
|
+
|
|
65
87
|
const isOfficeTheme =
|
|
66
88
|
theme.name === 'White' ||
|
|
67
89
|
theme.name === 'Colorful' ||
|
|
68
90
|
theme.name === 'DarkGray' ||
|
|
69
91
|
theme.name === 'Black' ||
|
|
70
92
|
theme.name === 'HighContrast';
|
|
93
|
+
|
|
71
94
|
const aliasColorTokens = isOfficeTheme
|
|
72
95
|
? createOfficeAliasTokens(theme.name)
|
|
73
96
|
: createAliasTokens(getCurrentAppearance(theme.host.appearance, 'light'));
|
|
74
97
|
|
|
75
98
|
const aggregator = React.useCallback(
|
|
76
|
-
(
|
|
77
|
-
return {
|
|
99
|
+
(colorName: string) => {
|
|
100
|
+
return { colorName: colorName, colorValue: aliasColorTokens[colorName] };
|
|
78
101
|
},
|
|
79
102
|
[aliasColorTokens],
|
|
80
103
|
);
|
|
@@ -83,15 +106,107 @@ const AliasTokensSwatchList: React.FunctionComponent = () => {
|
|
|
83
106
|
return Object.keys(aliasColorTokens).map(aggregator);
|
|
84
107
|
}, [aliasColorTokens, aggregator]);
|
|
85
108
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}, []);
|
|
109
|
+
const aliasColorTokensAsArray = React.useMemo(flattenArray, [flattenArray]);
|
|
110
|
+
|
|
111
|
+
const renderSwatch = React.useCallback(getSwatch, []);
|
|
112
|
+
|
|
91
113
|
return (
|
|
92
114
|
<View style={commonTestStyles.view}>
|
|
93
|
-
<
|
|
94
|
-
|
|
115
|
+
<View style={styles.stackStyle}>{aliasColorTokensAsArray.map((item) => renderSwatch(item))}</View>
|
|
116
|
+
</View>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/// Global color tokens - neutral
|
|
121
|
+
|
|
122
|
+
const globalNeutralColorNamesSortedDarkToLight = Object.keys(globalTokens.color)
|
|
123
|
+
.filter((globalColorName) => globalColorName.includes('grey') || globalColorName === 'black' || globalColorName === 'white')
|
|
124
|
+
.sort((color1, color2) => {
|
|
125
|
+
const color1hex = globalTokens.color[color1];
|
|
126
|
+
const color2hex = globalTokens.color[color2];
|
|
127
|
+
// All global color tokens are hex based colors, so we can make the assumption that ordering the hex values alphabetically
|
|
128
|
+
// will order the colors from dark to light
|
|
129
|
+
return color1hex === color2hex ? 0 : color1hex < color2hex ? -1 : 1;
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const globalNeutralColorTokensAsArray = globalNeutralColorNamesSortedDarkToLight.map((colorName: string) => {
|
|
133
|
+
return {
|
|
134
|
+
colorName: colorName,
|
|
135
|
+
colorValue: globalTokens.color[colorName],
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const GlobalNeutralColorTokensSwatchList: React.FunctionComponent = () => {
|
|
140
|
+
const renderSwatch = React.useCallback(getSwatch, []);
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<View style={commonTestStyles.view}>
|
|
144
|
+
<View style={styles.stackStyle}>{globalNeutralColorTokensAsArray.map((item) => renderSwatch(item))}</View>
|
|
145
|
+
</View>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/// Global color tokens - shared
|
|
150
|
+
|
|
151
|
+
const globalSharedColorNames = Object.keys(globalTokens.color).filter((key) => globalTokens.color[key].primary !== undefined);
|
|
152
|
+
const globalSharedColorVariantsSortedDarkToLight = Object.keys(globalTokens.color.red).sort((color1, color2) => {
|
|
153
|
+
const color1hex = globalTokens.color.red[color1];
|
|
154
|
+
const color2hex = globalTokens.color.red[color2];
|
|
155
|
+
// All global color tokens are hex based colors, so we can make the assumption that ordering the hex values alphabetically
|
|
156
|
+
// will order the colors from dark to light
|
|
157
|
+
return color1hex === color2hex ? 0 : color1hex < color2hex ? -1 : 1;
|
|
158
|
+
});
|
|
159
|
+
const globalSharedColorTokensAsArray = globalSharedColorNames
|
|
160
|
+
.map((sharedColorName) => {
|
|
161
|
+
return globalSharedColorVariantsSortedDarkToLight.map((variant) => {
|
|
162
|
+
return {
|
|
163
|
+
colorName: sharedColorName + '.' + variant,
|
|
164
|
+
colorValue: globalTokens.color[sharedColorName][variant],
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
})
|
|
168
|
+
.reduce((accumulator, sharedColor) => accumulator.concat(sharedColor));
|
|
169
|
+
|
|
170
|
+
const GlobalSharedColorTokensSwatchList: React.FunctionComponent = () => {
|
|
171
|
+
const renderSwatch = React.useCallback(getSwatch, []);
|
|
172
|
+
|
|
173
|
+
const [showGlobalSharedColors, setShowGlobalSharedColors] = React.useState(false);
|
|
174
|
+
|
|
175
|
+
const toggleSvg: React.FunctionComponent<SvgProps> = () => {
|
|
176
|
+
const plusPath =
|
|
177
|
+
'M6.5 1.75C6.5 1.33579 6.16421 1 5.75 1C5.33579 1 5 1.33579 5 1.75V5H1.75C1.33579 5 1 5.33579 1 5.75C1 6.16421 1.33579 6.5 1.75 6.5H5V9.75C5 10.1642 5.33579 10.5 5.75 10.5C6.16421 10.5 6.5 10.1642 6.5 9.75V6.5H9.75C10.1642 6.5 10.5 6.16421 10.5 5.75C10.5 5.33579 10.1642 5 9.75 5H6.5V1.75Z';
|
|
178
|
+
const minusPath = 'M2.75 5.25h6.5s0.75 0 0.75 0.75v0s0 0.75 -0.75 0.75h-6.5s-0.75 0 -0.75 -0.75v0s0 -0.75 0.75 -0.75';
|
|
179
|
+
|
|
180
|
+
const path = showGlobalSharedColors ? minusPath : plusPath;
|
|
181
|
+
return (
|
|
182
|
+
<Svg>
|
|
183
|
+
<G>
|
|
184
|
+
<Path d={path} fill="black" />
|
|
185
|
+
</G>
|
|
186
|
+
</Svg>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const svgProps: SvgIconProps = { src: toggleSvg };
|
|
191
|
+
const plusCodepoint = 0x2795;
|
|
192
|
+
const minusCodepoint = 0x2796;
|
|
193
|
+
const fontIconProps = {
|
|
194
|
+
codepoint: showGlobalSharedColors ? minusCodepoint : plusCodepoint,
|
|
195
|
+
fontSize: 10,
|
|
196
|
+
};
|
|
197
|
+
const toggleIconProps = Platform.OS === 'windows' ? { fontSource: fontIconProps } : { svgSource: svgProps, width: 12, height: 12 };
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<View style={styles.toggleButtonAreaPadding}>
|
|
201
|
+
<View style={styles.statusView}>
|
|
202
|
+
<Text variant="subheaderStandard">Show color tokens</Text>
|
|
203
|
+
<ToggleButton iconOnly={true} icon={toggleIconProps} onClick={() => setShowGlobalSharedColors(!showGlobalSharedColors)} />
|
|
204
|
+
</View>
|
|
205
|
+
{showGlobalSharedColors && (
|
|
206
|
+
<View style={commonTestStyles.view}>
|
|
207
|
+
<View style={styles.stackStyle}>{globalSharedColorTokensAsArray.map((item) => renderSwatch(item))}</View>
|
|
208
|
+
</View>
|
|
209
|
+
)}
|
|
95
210
|
</View>
|
|
96
211
|
);
|
|
97
212
|
};
|
|
@@ -100,7 +215,15 @@ const themeSections: TestSection[] = [
|
|
|
100
215
|
{
|
|
101
216
|
name: 'Alias Color Tokens',
|
|
102
217
|
testID: COLORTOKEN_TESTPAGE,
|
|
103
|
-
component: () => <
|
|
218
|
+
component: () => <AliasColorTokensSwatchList />,
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: 'Global Color Tokens - Neutral Colors',
|
|
222
|
+
component: () => <GlobalNeutralColorTokensSwatchList />,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'Global Color Tokens - Shared Colors',
|
|
226
|
+
component: () => <GlobalSharedColorTokensSwatchList />,
|
|
104
227
|
},
|
|
105
228
|
];
|
|
106
229
|
|
|
@@ -113,7 +236,7 @@ export const ColorTokensTest: React.FunctionComponent = () => {
|
|
|
113
236
|
androidStatus: 'Experimental',
|
|
114
237
|
};
|
|
115
238
|
|
|
116
|
-
const description = 'Alias tokens given from token pipeline.
|
|
239
|
+
const description = 'Alias and global tokens given from token pipeline. Used to style components.';
|
|
117
240
|
|
|
118
241
|
return <Test name="Color Tokens Test" description={description} sections={themeSections} status={status} />;
|
|
119
242
|
};
|