@fluentui-react-native/tester 0.64.13 → 0.65.2

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 (72) hide show
  1. package/CHANGELOG.json +66 -1
  2. package/CHANGELOG.md +32 -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/Menu/E2EMenuTest.d.ts.map +1 -1
  10. package/lib/FluentTester/TestComponents/Menu/E2EMenuTest.js +3 -3
  11. package/lib/FluentTester/TestComponents/Menu/E2EMenuTest.js.map +1 -1
  12. package/lib/FluentTester/TestComponents/Menu/MenuTest.d.ts.map +1 -1
  13. package/lib/FluentTester/TestComponents/Menu/MenuTest.js +22 -22
  14. package/lib/FluentTester/TestComponents/Menu/MenuTest.js.map +1 -1
  15. package/lib/FluentTester/TestComponents/Notification/NotificationTest.d.ts +3 -0
  16. package/lib/FluentTester/TestComponents/Notification/NotificationTest.d.ts.map +1 -0
  17. package/lib/FluentTester/TestComponents/Notification/NotificationTest.js +95 -0
  18. package/lib/FluentTester/TestComponents/Notification/NotificationTest.js.map +1 -0
  19. package/lib/FluentTester/TestComponents/Notification/consts.d.ts +3 -0
  20. package/lib/FluentTester/TestComponents/Notification/consts.d.ts.map +1 -0
  21. package/lib/FluentTester/TestComponents/Notification/consts.js +3 -0
  22. package/lib/FluentTester/TestComponents/Notification/consts.js.map +1 -0
  23. package/lib/FluentTester/TestComponents/Notification/index.d.ts +3 -0
  24. package/lib/FluentTester/TestComponents/Notification/index.d.ts.map +1 -0
  25. package/lib/FluentTester/TestComponents/Notification/index.js +3 -0
  26. package/lib/FluentTester/TestComponents/Notification/index.js.map +1 -0
  27. package/lib/FluentTester/testPages.d.ts.map +1 -1
  28. package/lib/FluentTester/testPages.ios.d.ts.map +1 -1
  29. package/lib/FluentTester/testPages.ios.js +6 -0
  30. package/lib/FluentTester/testPages.ios.js.map +1 -1
  31. package/lib/FluentTester/testPages.js +6 -0
  32. package/lib/FluentTester/testPages.js.map +1 -1
  33. package/lib-commonjs/FluentTester/TestComponents/Avatar/BasicAvatar.d.ts.map +1 -1
  34. package/lib-commonjs/FluentTester/TestComponents/Avatar/BasicAvatar.js +3 -7
  35. package/lib-commonjs/FluentTester/TestComponents/Avatar/BasicAvatar.js.map +1 -1
  36. package/lib-commonjs/FluentTester/TestComponents/Avatar/CustomizedAvatar.d.ts.map +1 -1
  37. package/lib-commonjs/FluentTester/TestComponents/Avatar/CustomizedAvatar.js +48 -39
  38. package/lib-commonjs/FluentTester/TestComponents/Avatar/CustomizedAvatar.js.map +1 -1
  39. package/lib-commonjs/FluentTester/TestComponents/Menu/E2EMenuTest.d.ts.map +1 -1
  40. package/lib-commonjs/FluentTester/TestComponents/Menu/E2EMenuTest.js +3 -3
  41. package/lib-commonjs/FluentTester/TestComponents/Menu/E2EMenuTest.js.map +1 -1
  42. package/lib-commonjs/FluentTester/TestComponents/Menu/MenuTest.d.ts.map +1 -1
  43. package/lib-commonjs/FluentTester/TestComponents/Menu/MenuTest.js +22 -22
  44. package/lib-commonjs/FluentTester/TestComponents/Menu/MenuTest.js.map +1 -1
  45. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.d.ts +3 -0
  46. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.d.ts.map +1 -0
  47. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.js +100 -0
  48. package/lib-commonjs/FluentTester/TestComponents/Notification/NotificationTest.js.map +1 -0
  49. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.d.ts +3 -0
  50. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.d.ts.map +1 -0
  51. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.js +6 -0
  52. package/lib-commonjs/FluentTester/TestComponents/Notification/consts.js.map +1 -0
  53. package/lib-commonjs/FluentTester/TestComponents/Notification/index.d.ts +3 -0
  54. package/lib-commonjs/FluentTester/TestComponents/Notification/index.d.ts.map +1 -0
  55. package/lib-commonjs/FluentTester/TestComponents/Notification/index.js +6 -0
  56. package/lib-commonjs/FluentTester/TestComponents/Notification/index.js.map +1 -0
  57. package/lib-commonjs/FluentTester/testPages.d.ts.map +1 -1
  58. package/lib-commonjs/FluentTester/testPages.ios.d.ts.map +1 -1
  59. package/lib-commonjs/FluentTester/testPages.ios.js +6 -0
  60. package/lib-commonjs/FluentTester/testPages.ios.js.map +1 -1
  61. package/lib-commonjs/FluentTester/testPages.js +6 -0
  62. package/lib-commonjs/FluentTester/testPages.js.map +1 -1
  63. package/package.json +3 -3
  64. package/src/FluentTester/TestComponents/Avatar/BasicAvatar.tsx +8 -7
  65. package/src/FluentTester/TestComponents/Avatar/CustomizedAvatar.tsx +80 -54
  66. package/src/FluentTester/TestComponents/Menu/E2EMenuTest.tsx +5 -3
  67. package/src/FluentTester/TestComponents/Menu/MenuTest.tsx +24 -22
  68. package/src/FluentTester/TestComponents/Notification/NotificationTest.tsx +124 -0
  69. package/src/FluentTester/TestComponents/Notification/consts.ts +2 -0
  70. package/src/FluentTester/TestComponents/Notification/index.ts +2 -0
  71. package/src/FluentTester/testPages.ios.ts +6 -0
  72. 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
  };
@@ -33,9 +33,11 @@ export const E2EMenuTest: React.FunctionComponent = () => {
33
33
  </MenuTrigger>
34
34
  <MenuPopover testID={MENUPOPOVER_TEST_COMPONENT}>
35
35
  <MenuList>
36
- <MenuItem testID={MENUITEM_TEST_COMPONENT} accessibilityLabel={MENUITEM_ACCESSIBILITY_LABEL} content="A plain MenuItem" />
37
- <MenuItem disabled content="A second disabled plain MenuItem" />
38
- <MenuItem testID={MENUITEM_NO_A11Y_LABEL_COMPONENT} content={MENUITEM_TEST_LABEL} />
36
+ <MenuItem testID={MENUITEM_TEST_COMPONENT} accessibilityLabel={MENUITEM_ACCESSIBILITY_LABEL}>
37
+ A plain MenuItem
38
+ </MenuItem>
39
+ <MenuItem disabled>A second disabled plain MenuItem</MenuItem>
40
+ <MenuItem testID={MENUITEM_NO_A11Y_LABEL_COMPONENT}>{MENUITEM_TEST_LABEL}</MenuItem>
39
41
  </MenuList>
40
42
  </MenuPopover>
41
43
  </Menu>
@@ -26,9 +26,9 @@ const MenuDefault: React.FunctionComponent = () => {
26
26
  </MenuTrigger>
27
27
  <MenuPopover>
28
28
  <MenuList>
29
- <MenuItem content="A plain MenuItem" />
30
- <MenuItem disabled content="A second disabled plain MenuItem" />
31
- <MenuItem content="A third plain MenuItem" />
29
+ <MenuItem>A plain MenuItem</MenuItem>
30
+ <MenuItem disabled>A second disabled plain MenuItem</MenuItem>
31
+ <MenuItem>A third plain MenuItem</MenuItem>
32
32
  </MenuList>
33
33
  </MenuPopover>
34
34
  </Menu>
@@ -45,9 +45,9 @@ const MenuCheckmarks: React.FunctionComponent = () => {
45
45
  </MenuTrigger>
46
46
  <MenuPopover>
47
47
  <MenuList>
48
- <MenuItemCheckbox name="itemOne" content="A MenuItem with checkmark" />
48
+ <MenuItemCheckbox name="itemOne">A MenuItem with checkmark</MenuItemCheckbox>
49
49
  <MenuDivider />
50
- <MenuItemCheckbox name="itemTwo" content="Another MenuItem with checkmark" />
50
+ <MenuItemCheckbox name="itemTwo">Another MenuItem with checkmark</MenuItemCheckbox>
51
51
  </MenuList>
52
52
  </MenuPopover>
53
53
  </Menu>
@@ -57,10 +57,12 @@ const MenuCheckmarks: React.FunctionComponent = () => {
57
57
  </MenuTrigger>
58
58
  <MenuPopover>
59
59
  <MenuList>
60
- <MenuItem content="A plain MenuItem" />
61
- <MenuItemCheckbox name="itemTwo" content="A MenuItem with checkmark" />
62
- <MenuItemCheckbox disabled name="itemThree" content="A disabled MenuItem with checkmark" />
63
- <MenuItemCheckbox name="itemFour" content="A MenuItem with checkmark" />
60
+ <MenuItem>A plain MenuItem</MenuItem>
61
+ <MenuItemCheckbox name="itemTwo">A MenuItem with checkmark</MenuItemCheckbox>
62
+ <MenuItemCheckbox disabled name="itemThree">
63
+ A disabled MenuItem with checkmark
64
+ </MenuItemCheckbox>
65
+ <MenuItemCheckbox name="itemFour">A MenuItem with checkmark</MenuItemCheckbox>
64
66
  </MenuList>
65
67
  </MenuPopover>
66
68
  </Menu>
@@ -70,9 +72,9 @@ const MenuCheckmarks: React.FunctionComponent = () => {
70
72
  </MenuTrigger>
71
73
  <MenuPopover>
72
74
  <MenuList>
73
- <MenuItem content="A plain MenuItem" />
74
- <MenuItemCheckbox name="itemTwo" content="A MenuItem with checkmark" />
75
- <MenuItemCheckbox name="itemThree" content="A MenuItem with checkmark" />
75
+ <MenuItem>A plain MenuItem</MenuItem>
76
+ <MenuItemCheckbox name="itemTwo">A MenuItem with checkmark</MenuItemCheckbox>
77
+ <MenuItemCheckbox name="itemThree">A MenuItem with checkmark</MenuItemCheckbox>
76
78
  </MenuList>
77
79
  </MenuPopover>
78
80
  </Menu>
@@ -98,10 +100,10 @@ const MenuRadioItem: React.FunctionComponent = () => {
98
100
  </MenuTrigger>
99
101
  <MenuPopover>
100
102
  <MenuList>
101
- <MenuItemRadio name="itemOne" content="A MenuItem with checkmark and radio selection" />
102
- <MenuItemRadio name="itemTwo" content="Another MenuItem with checkmark and radio selection" />
103
- <MenuItemRadio name="itemThree" content="A third MenuItem with checkmark and radio selection" />
104
- <MenuItemCheckbox name="itemFour" content="A MenuItem with checkmark and toggle selection" />
103
+ <MenuItemRadio name="itemOne">A MenuItem with checkmark and radio selection</MenuItemRadio>
104
+ <MenuItemRadio name="itemTwo">Another MenuItem with checkmark and radio selection</MenuItemRadio>
105
+ <MenuItemRadio name="itemThree">A third MenuItem with checkmark and radio selection</MenuItemRadio>
106
+ <MenuItemCheckbox name="itemFour">A MenuItem with checkmark and toggle selection</MenuItemCheckbox>
105
107
  </MenuList>
106
108
  </MenuPopover>
107
109
  </Menu>
@@ -113,12 +115,12 @@ const Submenu: React.FunctionComponent = () => {
113
115
  return (
114
116
  <Menu>
115
117
  <MenuTrigger>
116
- <MenuItem content="A second MenuItem" />
118
+ <MenuItem>A second MenuItem</MenuItem>
117
119
  </MenuTrigger>
118
120
  <MenuPopover>
119
121
  <MenuList>
120
- <MenuItem content="A nested MenuItem" />
121
- <MenuItem content="A second nested MenuItem" />
122
+ <MenuItem>A nested MenuItem</MenuItem>
123
+ <MenuItem>A second nested MenuItem</MenuItem>
122
124
  <Submenu />
123
125
  </MenuList>
124
126
  </MenuPopover>
@@ -135,7 +137,7 @@ const MenuSubMenu: React.FunctionComponent = () => {
135
137
  </MenuTrigger>
136
138
  <MenuPopover>
137
139
  <MenuList>
138
- <MenuItem content="A MenuItem" />
140
+ <MenuItem>A MenuItem</MenuItem>
139
141
  <Submenu />
140
142
  </MenuList>
141
143
  </MenuPopover>
@@ -153,7 +155,7 @@ const MenuOpenOnHover: React.FunctionComponent = () => {
153
155
  </MenuTrigger>
154
156
  <MenuPopover>
155
157
  <MenuList>
156
- <MenuItem content="A MenuItem" />
158
+ <MenuItem>A MenuItem</MenuItem>
157
159
  <Submenu />
158
160
  </MenuList>
159
161
  </MenuPopover>
@@ -173,7 +175,7 @@ const MenuControlledOpen: React.FunctionComponent = () => {
173
175
  </MenuTrigger>
174
176
  <MenuPopover>
175
177
  <MenuList>
176
- <MenuItem content="A MenuItem" />
178
+ <MenuItem>A MenuItem</MenuItem>
177
179
  <Submenu />
178
180
  </MenuList>
179
181
  </MenuPopover>
@@ -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
  ];