@fluentui-react-native/tester 0.64.13 → 0.65.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.
Files changed (58) hide show
  1. package/CHANGELOG.json +30 -1
  2. package/CHANGELOG.md +15 -2
  3. package/lib/FluentTester/TestComponents/Avatar/BasicAvatar.d.ts.map +1 -1
  4. package/lib/FluentTester/TestComponents/Avatar/BasicAvatar.js +3 -7
  5. package/lib/FluentTester/TestComponents/Avatar/BasicAvatar.js.map +1 -1
  6. package/lib/FluentTester/TestComponents/Avatar/CustomizedAvatar.d.ts.map +1 -1
  7. package/lib/FluentTester/TestComponents/Avatar/CustomizedAvatar.js +49 -40
  8. package/lib/FluentTester/TestComponents/Avatar/CustomizedAvatar.js.map +1 -1
  9. package/lib/FluentTester/TestComponents/Notification/NotificationTest.d.ts +3 -0
  10. package/lib/FluentTester/TestComponents/Notification/NotificationTest.d.ts.map +1 -0
  11. package/lib/FluentTester/TestComponents/Notification/NotificationTest.js +95 -0
  12. package/lib/FluentTester/TestComponents/Notification/NotificationTest.js.map +1 -0
  13. package/lib/FluentTester/TestComponents/Notification/consts.d.ts +3 -0
  14. package/lib/FluentTester/TestComponents/Notification/consts.d.ts.map +1 -0
  15. package/lib/FluentTester/TestComponents/Notification/consts.js +3 -0
  16. package/lib/FluentTester/TestComponents/Notification/consts.js.map +1 -0
  17. package/lib/FluentTester/TestComponents/Notification/index.d.ts +3 -0
  18. package/lib/FluentTester/TestComponents/Notification/index.d.ts.map +1 -0
  19. package/lib/FluentTester/TestComponents/Notification/index.js +3 -0
  20. package/lib/FluentTester/TestComponents/Notification/index.js.map +1 -0
  21. package/lib/FluentTester/testPages.d.ts.map +1 -1
  22. package/lib/FluentTester/testPages.ios.d.ts.map +1 -1
  23. package/lib/FluentTester/testPages.ios.js +6 -0
  24. package/lib/FluentTester/testPages.ios.js.map +1 -1
  25. package/lib/FluentTester/testPages.js +6 -0
  26. package/lib/FluentTester/testPages.js.map +1 -1
  27. package/lib-commonjs/FluentTester/TestComponents/Avatar/BasicAvatar.d.ts.map +1 -1
  28. package/lib-commonjs/FluentTester/TestComponents/Avatar/BasicAvatar.js +3 -7
  29. package/lib-commonjs/FluentTester/TestComponents/Avatar/BasicAvatar.js.map +1 -1
  30. package/lib-commonjs/FluentTester/TestComponents/Avatar/CustomizedAvatar.d.ts.map +1 -1
  31. package/lib-commonjs/FluentTester/TestComponents/Avatar/CustomizedAvatar.js +48 -39
  32. package/lib-commonjs/FluentTester/TestComponents/Avatar/CustomizedAvatar.js.map +1 -1
  33. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.d.ts +3 -0
  34. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.d.ts.map +1 -0
  35. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.js +100 -0
  36. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.js.map +1 -0
  37. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.d.ts +3 -0
  38. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.d.ts.map +1 -0
  39. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.js +6 -0
  40. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.js.map +1 -0
  41. package/lib-commonjs/FluentTester/TestComponents/Notification/index.d.ts +3 -0
  42. package/lib-commonjs/FluentTester/TestComponents/Notification/index.d.ts.map +1 -0
  43. package/lib-commonjs/FluentTester/TestComponents/Notification/index.js +6 -0
  44. package/lib-commonjs/FluentTester/TestComponents/Notification/index.js.map +1 -0
  45. package/lib-commonjs/FluentTester/testPages.d.ts.map +1 -1
  46. package/lib-commonjs/FluentTester/testPages.ios.d.ts.map +1 -1
  47. package/lib-commonjs/FluentTester/testPages.ios.js +6 -0
  48. package/lib-commonjs/FluentTester/testPages.ios.js.map +1 -1
  49. package/lib-commonjs/FluentTester/testPages.js +6 -0
  50. package/lib-commonjs/FluentTester/testPages.js.map +1 -1
  51. package/package.json +2 -2
  52. package/src/FluentTester/TestComponents/Avatar/BasicAvatar.tsx +8 -7
  53. package/src/FluentTester/TestComponents/Avatar/CustomizedAvatar.tsx +80 -54
  54. package/src/FluentTester/TestComponents/Notification/NotificationTest.tsx +124 -0
  55. package/src/FluentTester/TestComponents/Notification/consts.ts +2 -0
  56. package/src/FluentTester/TestComponents/Notification/index.ts +2 -0
  57. package/src/FluentTester/testPages.ios.ts +6 -0
  58. package/src/FluentTester/testPages.ts +6 -0
@@ -1,57 +1,64 @@
1
1
  import React, { useState, useMemo } from 'react';
2
- import { JSAvatar, IconAlignment, AvatarSize } from '@fluentui-react-native/experimental-avatar';
3
- import { Switch, View, Text, TextInput } from 'react-native';
2
+ import { JSAvatar, AvatarSize } from '@fluentui-react-native/experimental-avatar';
3
+ import { Switch, View, Text, TextInput, Platform } from 'react-native';
4
4
  import { steveBallmerPhotoUrl } from './../PersonaCoin/styles';
5
- import { AlignmentPicker } from '../Common/AlignmentPicker';
6
5
  import { commonTestStyles as commonStyles } from '../Common/styles';
7
6
  import { FontWeight } from '@fluentui-react-native/theme-types';
7
+ import { SvgIconProps } from '@fluentui-react-native/icon';
8
+ import TestSvg from '../../test-data/test.svg';
8
9
 
9
10
  export const CustomizeUsage: React.FunctionComponent = () => {
10
11
  const [showImage, setShowImage] = useState(true);
11
- const [coinColor, setCoinColor] = useState<string>();
12
+ const [showInitials, setShowInitials] = useState(true);
13
+ const [avatarColor, setAvatarColor] = useState<string>();
12
14
  const [textColor, setTextColor] = useState<string>();
13
15
  const [size, setSize] = useState<string>('96');
14
16
  const [iconSize, setIconSize] = useState<number>(24);
17
+ const [iconColor, setIconColor] = useState<string>(undefined);
15
18
  const [initialsSize, setInitialsSize] = useState<number>(16);
16
19
  const [fontWeight, setFontWeight] = useState<string>('normal');
17
20
  const [fontFamily, setFontFamily] = useState<string>('Georgia');
18
- const [horizontalAlignment, setHorizontalAlignment] = useState<IconAlignment>();
19
- const [verticalAlignment, setVerticalAlignment] = useState<IconAlignment>();
20
21
 
21
- const [ringColor, setRingColor] = useState<string>('red');
22
- const [ringBackgroundColor, setRingBackgroundColor] = useState<string>(undefined);
22
+ const [ringColor, setRingColor] = useState<string>(undefined);
23
+ const [ringBackgroundColor, setRingBackgroundColor] = useState<string>('yellow');
24
+ const [ringThickness, setRingThickness] = useState<string>('4');
23
25
  const [showRing, setShowRing] = useState<boolean>(true);
24
- const [transparent, setTransparent] = useState<boolean>(false);
25
26
 
26
27
  const CustomizedAvatar = useMemo(() => {
27
28
  const tokens = {
28
- backgroundColor: coinColor,
29
+ avatarColor,
29
30
  color: textColor,
30
- horizontalIconAlignment: horizontalAlignment,
31
- verticalIconAlignment: verticalAlignment,
31
+ size: parseInt(size) as AvatarSize,
32
32
  iconSize: iconSize,
33
+ iconColor,
33
34
  fontSize: initialsSize,
34
35
  fontWeight: fontWeight as FontWeight,
35
36
  fontFamily,
36
- size: parseInt(size) as AvatarSize,
37
37
  ringColor,
38
38
  ringBackgroundColor,
39
+ ringThickness: parseInt(ringThickness),
39
40
  };
40
41
  return JSAvatar.customize(tokens);
41
42
  }, [
42
- coinColor,
43
+ avatarColor,
43
44
  textColor,
44
- horizontalAlignment,
45
- verticalAlignment,
45
+ iconColor,
46
46
  iconSize,
47
47
  initialsSize,
48
48
  size,
49
49
  ringColor,
50
50
  ringBackgroundColor,
51
+ ringThickness,
51
52
  fontWeight,
52
53
  fontFamily,
53
54
  ]);
54
55
 
56
+ const svgIconsEnabled = ['ios', 'macos', 'win32', 'android'].includes(Platform.OS as string);
57
+ const svgProps: SvgIconProps = {
58
+ src: TestSvg,
59
+ viewBox: '0 0 500 500',
60
+ };
61
+
55
62
  return (
56
63
  <View style={commonStyles.root}>
57
64
  <View style={commonStyles.settings}>
@@ -59,55 +66,53 @@ export const CustomizeUsage: React.FunctionComponent = () => {
59
66
  <Text>Show image</Text>
60
67
  <Switch value={showImage} onValueChange={setShowImage} />
61
68
  </View>
62
-
63
69
  <View style={commonStyles.switch}>
64
- <Text>Show rings</Text>
65
- <Switch value={showRing} onValueChange={setShowRing} />
70
+ <Text>Show initials</Text>
71
+ <Switch value={showInitials} onValueChange={setShowInitials} />
66
72
  </View>
67
73
 
68
74
  <View style={commonStyles.switch}>
69
- <Text>Transparent Ring</Text>
70
- <Switch value={transparent} onValueChange={setTransparent} />
75
+ <Text>Show rings</Text>
76
+ <Switch value={showRing} onValueChange={setShowRing} />
71
77
  </View>
72
-
73
78
  <View style={{ flexDirection: 'row' }}>
74
79
  <View>
80
+ <Text style={{ fontWeight: 'bold' }}>Avatar tokens</Text>
75
81
  <TextInput
76
82
  style={[commonStyles.textBox]}
77
83
  placeholder="Background color"
78
84
  blurOnSubmit={true}
79
85
  onSubmitEditing={(e) => {
80
- setCoinColor(e.nativeEvent.text);
86
+ setAvatarColor(e.nativeEvent.text);
81
87
  }}
82
88
  />
83
89
 
84
90
  <TextInput
85
91
  style={[commonStyles.textBox]}
86
- placeholder="Ring color"
92
+ placeholder="Avatar size"
87
93
  blurOnSubmit={true}
88
94
  onSubmitEditing={(e) => {
89
- setRingColor(e.nativeEvent.text);
95
+ setSize(e.nativeEvent.text);
90
96
  }}
91
97
  />
92
98
 
93
99
  <TextInput
94
100
  style={[commonStyles.textBox]}
95
- placeholder="Avatar size"
101
+ placeholder="Icon size"
96
102
  blurOnSubmit={true}
97
103
  onSubmitEditing={(e) => {
98
- setSize(e.nativeEvent.text);
104
+ setIconSize(parseInt(e.nativeEvent.text));
99
105
  }}
100
106
  />
101
-
102
107
  <TextInput
103
108
  style={[commonStyles.textBox]}
104
- placeholder="Icon size"
109
+ placeholder="Icon color"
105
110
  blurOnSubmit={true}
106
111
  onSubmitEditing={(e) => {
107
- setIconSize(parseInt(e.nativeEvent.text));
112
+ setIconColor(e.nativeEvent.text);
108
113
  }}
109
114
  />
110
-
115
+ <Text style={{ fontWeight: 'bold' }}>Ring tokens</Text>
111
116
  <TextInput
112
117
  style={[commonStyles.textBox]}
113
118
  placeholder="Ring background color"
@@ -116,6 +121,22 @@ export const CustomizeUsage: React.FunctionComponent = () => {
116
121
  setRingBackgroundColor(e.nativeEvent.text);
117
122
  }}
118
123
  />
124
+ <TextInput
125
+ style={[commonStyles.textBox]}
126
+ placeholder="Ring color"
127
+ blurOnSubmit={true}
128
+ onSubmitEditing={(e) => {
129
+ setRingColor(e.nativeEvent.text);
130
+ }}
131
+ />
132
+ <TextInput
133
+ style={[commonStyles.textBox]}
134
+ placeholder="Ring thickness"
135
+ blurOnSubmit={true}
136
+ onSubmitEditing={(e) => {
137
+ setRingThickness(e.nativeEvent.text);
138
+ }}
139
+ />
119
140
  </View>
120
141
  <View style={{ paddingHorizontal: 20 }}>
121
142
  <Text style={{ fontWeight: 'bold' }}>Font tokens</Text>
@@ -153,30 +174,35 @@ export const CustomizeUsage: React.FunctionComponent = () => {
153
174
  />
154
175
  </View>
155
176
  </View>
156
-
157
- <Text>These features will be available later</Text>
158
- <AlignmentPicker style={commonStyles.header} label="Horizontal icon alignment" onSelectionChange={setHorizontalAlignment} />
159
- <AlignmentPicker style={commonStyles.header} label="Vertical icon alignment" onSelectionChange={setVerticalAlignment} />
160
177
  </View>
161
-
162
- <CustomizedAvatar
163
- active="active"
164
- activeAppearance="ring"
165
- avatarColor="colorful"
166
- initials="SB"
167
- accessibilityLabel="Former CEO of Microsoft"
168
- badge={{ status: 'blocked' }}
169
- imageUrl={showImage ? steveBallmerPhotoUrl : undefined}
170
- ring={
171
- showRing
172
- ? {
173
- ringThickness: 4,
174
- innerGap: 4,
175
- transparent,
176
- }
177
- : undefined
178
- }
179
- />
178
+ <View>
179
+ <Text>Customized Avatar</Text>
180
+ <CustomizedAvatar
181
+ active="active"
182
+ activeAppearance="ring"
183
+ avatarColor={avatarColor}
184
+ accessibilityLabel="Former CEO of Microsoft"
185
+ initials={showInitials ? 'SB' : undefined}
186
+ imageUrl={showImage ? steveBallmerPhotoUrl : undefined}
187
+ icon={svgIconsEnabled ? { svgSource: svgProps } : undefined}
188
+ transparentRing={!showRing}
189
+ />
190
+ </View>
191
+ <View style={{ marginLeft: 20 }}>
192
+ <Text>Avatar customized with props</Text>
193
+ <JSAvatar
194
+ active="active"
195
+ activeAppearance="ring"
196
+ avatarColor={avatarColor}
197
+ accessibilityLabel="Former CEO of Microsoft"
198
+ imageUrl={showImage ? steveBallmerPhotoUrl : undefined}
199
+ ringBackgroundColor={ringBackgroundColor}
200
+ ringColor={ringColor}
201
+ ringThickness={parseInt(ringThickness)}
202
+ size={parseInt(size) as AvatarSize}
203
+ transparentRing={!showRing}
204
+ />
205
+ </View>
180
206
  </View>
181
207
  );
182
208
  };
@@ -0,0 +1,124 @@
1
+ import * as React from 'react';
2
+ import { StyleSheet, View, Text } from 'react-native';
3
+ import { Test, TestSection, PlatformStatus } from '../Test';
4
+
5
+ const NotificationVariants = ['primary', 'neutral', 'danger', 'warning'] as const;
6
+ type NotificationVariant = typeof NotificationVariants[number];
7
+
8
+ interface NotificationProps {
9
+ /**
10
+ * Notification variants: 'primary' | 'neutral' |'danger' | 'warning'
11
+ */
12
+ variant: NotificationVariant;
13
+ startText: string;
14
+ endText: string;
15
+ }
16
+
17
+ const Notification = (props: NotificationProps) => {
18
+ const variant = props.variant;
19
+ const startText = props.startText;
20
+ const endText = props.endText;
21
+
22
+ let containerBackgroundColor = 'skyblue';
23
+ let foregroundColor = 'black';
24
+
25
+ switch (variant) {
26
+ case 'primary':
27
+ containerBackgroundColor = 'skyblue';
28
+ break;
29
+ case 'neutral':
30
+ containerBackgroundColor = 'lightgrey';
31
+ break;
32
+ case 'danger':
33
+ containerBackgroundColor = 'pink';
34
+ foregroundColor = 'maroon';
35
+ break;
36
+ case 'warning':
37
+ containerBackgroundColor = 'lightyellow';
38
+ foregroundColor = 'brown';
39
+ break;
40
+ }
41
+
42
+ const styles = StyleSheet.create({
43
+ container: {
44
+ borderRadius: 12,
45
+ backgroundColor: containerBackgroundColor,
46
+
47
+ flex: 1,
48
+ flexDirection: 'row',
49
+ justifyContent: 'space-between',
50
+ alignItems: 'center',
51
+ padding: 16,
52
+ },
53
+ start: {
54
+ fontSize: 16,
55
+ color: foregroundColor,
56
+
57
+ flex: 1,
58
+ flexGrow: 1,
59
+ },
60
+ end: {
61
+ fontSize: 16,
62
+ fontWeight: '500',
63
+ color: foregroundColor,
64
+
65
+ marginLeft: 34,
66
+ },
67
+ });
68
+
69
+ return (
70
+ <View style={styles.container}>
71
+ <Text style={styles.start}>{startText}</Text>
72
+ <Text style={styles.end}>{endText}</Text>
73
+ </View>
74
+ );
75
+ };
76
+
77
+ const PrimaryTest: React.FunctionComponent = () => {
78
+ return <Notification variant={'primary'} startText="Mail Archived" endText="Undo" />;
79
+ };
80
+
81
+ const NeutralTest: React.FunctionComponent = () => {
82
+ return <Notification variant={'neutral'} startText="Some items require you to sign in to view them" endText="Sign in" />;
83
+ };
84
+
85
+ const DangerTest: React.FunctionComponent = () => {
86
+ return <Notification variant={'danger'} startText="There was a problem, and your recent changes may not have saved" endText="Retry" />;
87
+ };
88
+
89
+ const WarningTest: React.FunctionComponent = () => {
90
+ return <Notification variant={'warning'} startText="Read Only" endText="X" />;
91
+ };
92
+
93
+ const notificationSections: TestSection[] = [
94
+ {
95
+ name: 'Primary',
96
+ component: PrimaryTest,
97
+ },
98
+ {
99
+ name: 'Neutral',
100
+ component: NeutralTest,
101
+ },
102
+ {
103
+ name: 'Danger',
104
+ component: DangerTest,
105
+ },
106
+ {
107
+ name: 'Warning',
108
+ component: WarningTest,
109
+ },
110
+ ];
111
+
112
+ export const NotificationTest: React.FunctionComponent = () => {
113
+ const status: PlatformStatus = {
114
+ win32Status: 'Backlog',
115
+ uwpStatus: 'Backlog',
116
+ iosStatus: 'Beta',
117
+ macosStatus: 'Backlog',
118
+ androidStatus: 'Backlog',
119
+ };
120
+
121
+ const description = 'Testing notification component';
122
+
123
+ return <Test name="Notification Test" description={description} sections={notificationSections} status={status}></Test>;
124
+ };
@@ -0,0 +1,2 @@
1
+ export const HOMEPAGE_NOTIFICATION_BUTTON = 'Homepage_Notification_Button';
2
+ export const NOTIFICATION_TESTPAGE = 'Notification_TestPage';
@@ -0,0 +1,2 @@
1
+ export * from './NotificationTest';
2
+ export * from './consts';
@@ -19,6 +19,7 @@ import { HOMEPAGE_THEME_BUTTON, ThemeTest } from './TestComponents/Theme';
19
19
  import { ActivityIndicatorTest, HOMEPAGE_ACTIVITY_INDICATOR_BUTTON } from './TestComponents/ActivityIndicator';
20
20
  import { HOMEPAGE_TOKEN_BUTTON, TokenTest } from './TestComponents/Tokens';
21
21
  import { HOMEPAGE_EXPERIMENTAL_TEXT_BUTTON, TextExperimentalTest } from './TestComponents/TextExperimental';
22
+ import { HOMEPAGE_NOTIFICATION_BUTTON, NotificationTest } from './TestComponents/Notification';
22
23
 
23
24
  export const tests: TestDescription[] = [
24
25
  {
@@ -121,4 +122,9 @@ export const tests: TestDescription[] = [
121
122
  component: TokenTest,
122
123
  testPage: HOMEPAGE_TOKEN_BUTTON,
123
124
  },
125
+ {
126
+ name: 'Notification Test',
127
+ component: NotificationTest,
128
+ testPage: HOMEPAGE_NOTIFICATION_BUTTON,
129
+ },
124
130
  ];
@@ -27,6 +27,7 @@ import { HOMEPAGE_CHECKBOX_EXPERIMENTAL_BUTTON, ExperimentalCheckboxTest } from
27
27
  import { HOMEPAGE_EXPERIMENTAL_TEXT_BUTTON, TextExperimentalTest } from './TestComponents/TextExperimental';
28
28
  import { ExperimentalMenuButtonTest, HOMEPAGE_EXPERIMENTAL_MENU_BUTTON } from './TestComponents/MenuButtonExperimental';
29
29
  import { MenuTest, HOMEPAGE_MENU_BUTTON } from './TestComponents/Menu';
30
+ import { NotificationTest, HOMEPAGE_NOTIFICATION_BUTTON } from './TestComponents/Notification';
30
31
 
31
32
  export const tests: TestDescription[] = [
32
33
  {
@@ -174,4 +175,9 @@ export const tests: TestDescription[] = [
174
175
  component: MenuTest,
175
176
  testPage: HOMEPAGE_MENU_BUTTON,
176
177
  },
178
+ {
179
+ name: 'Notification Test',
180
+ component: NotificationTest,
181
+ testPage: HOMEPAGE_NOTIFICATION_BUTTON,
182
+ },
177
183
  ];