@hero-design/rn 7.13.0 → 7.14.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 (155) hide show
  1. package/.eslintrc.json +3 -1
  2. package/.turbo/turbo-build.log +3 -2
  3. package/assets/fonts/hero-icons.ttf +0 -0
  4. package/babel.config.js +16 -0
  5. package/es/index.js +26957 -7622
  6. package/lib/assets/fonts/hero-icons.ttf +0 -0
  7. package/lib/index.js +26963 -7624
  8. package/package.json +9 -4
  9. package/rollup.config.js +1 -0
  10. package/src/components/Accordion/AccordionItem.tsx +50 -0
  11. package/src/components/Accordion/StyledAccordion.tsx +29 -0
  12. package/src/components/Accordion/__tests__/AccordionItem.spec.tsx +56 -0
  13. package/src/components/Accordion/__tests__/StyledAccordion.spec.tsx +17 -0
  14. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +529 -0
  15. package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +33 -0
  16. package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +822 -0
  17. package/src/components/Accordion/__tests__/index.spec.tsx +54 -0
  18. package/src/components/Accordion/index.tsx +82 -0
  19. package/src/components/Accordion/utils.tsx +11 -0
  20. package/src/components/Button/IconButton.tsx +1 -1
  21. package/src/components/Calendar/CalendarRowItem.tsx +54 -0
  22. package/src/components/Calendar/StyledCalendar.tsx +76 -0
  23. package/src/components/Calendar/__tests__/CalendarRowItem.spec.tsx +76 -0
  24. package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +411 -0
  25. package/src/components/Calendar/__tests__/helper.spec.ts +50 -0
  26. package/src/components/Calendar/__tests__/index.spec.tsx +99 -0
  27. package/src/components/Calendar/helpers.ts +29 -0
  28. package/src/components/Calendar/index.tsx +217 -0
  29. package/src/components/Collapse/index.tsx +13 -15
  30. package/src/components/ContentNavigator/index.tsx +6 -0
  31. package/src/components/Empty/StyledEmpty.tsx +47 -0
  32. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +66 -0
  33. package/src/components/Empty/__tests__/index.spec.tsx +17 -0
  34. package/src/components/Empty/index.tsx +53 -0
  35. package/src/components/FAB/ActionGroup/ActionItem.tsx +6 -2
  36. package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -0
  37. package/src/components/FAB/ActionGroup/StyledActionItem.tsx +7 -1
  38. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +84 -22
  39. package/src/components/FAB/ActionGroup/index.tsx +8 -1
  40. package/src/components/Icon/HeroIcon/selection.json +1 -1
  41. package/src/components/Icon/IconList.ts +13 -0
  42. package/src/components/List/BasicListItem.tsx +44 -34
  43. package/src/components/List/ListItem.tsx +67 -58
  44. package/src/components/List/StyledBasicListItem.tsx +2 -3
  45. package/src/components/List/StyledListItem.tsx +2 -2
  46. package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +5 -2
  47. package/src/components/List/__tests__/StyledListItem.spec.tsx +4 -1
  48. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +15 -10
  49. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +52 -32
  50. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +128 -48
  51. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +132 -52
  52. package/src/components/RichTextEditor/EditorEvent.ts +7 -0
  53. package/src/components/RichTextEditor/EditorToolbar.tsx +220 -0
  54. package/src/components/RichTextEditor/MentionList.tsx +69 -0
  55. package/src/components/RichTextEditor/RichTextEditor.tsx +396 -0
  56. package/src/components/RichTextEditor/StyledRichTextEditor.ts +20 -0
  57. package/src/components/RichTextEditor/StyledToolbar.ts +32 -0
  58. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +130 -0
  59. package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +109 -0
  60. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +245 -0
  61. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +324 -0
  62. package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +45 -0
  63. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +526 -0
  64. package/src/components/RichTextEditor/constants.ts +20 -0
  65. package/src/components/RichTextEditor/hero-editor.d.ts +8 -0
  66. package/src/components/RichTextEditor/index.tsx +8 -0
  67. package/src/components/RichTextEditor/utils/events.ts +31 -0
  68. package/src/components/RichTextEditor/utils/rnWebView.ts +19 -0
  69. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +77 -0
  70. package/src/components/SectionHeading/__tests__/index.spec.tsx +14 -0
  71. package/src/components/SectionHeading/index.tsx +16 -9
  72. package/src/components/Tag/StyledTag.tsx +12 -2
  73. package/src/components/Tag/__tests__/Tag.spec.tsx +35 -8
  74. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +118 -4
  75. package/src/components/Tag/index.tsx +9 -2
  76. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -0
  77. package/src/components/Typography/Text/StyledText.tsx +2 -1
  78. package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +1 -0
  79. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +22 -0
  80. package/src/components/Typography/Text/index.tsx +2 -1
  81. package/src/index.ts +8 -0
  82. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +101 -4
  83. package/src/theme/components/accordion.ts +19 -0
  84. package/src/theme/components/calendar.ts +34 -0
  85. package/src/theme/components/card.ts +1 -1
  86. package/src/theme/components/empty.ts +38 -0
  87. package/src/theme/components/fab.ts +4 -3
  88. package/src/theme/components/list.ts +1 -0
  89. package/src/theme/components/pinInput.ts +1 -1
  90. package/src/theme/components/richTextEditor.ts +34 -0
  91. package/src/theme/components/tag.ts +8 -2
  92. package/src/theme/components/typography.ts +1 -0
  93. package/src/theme/global/borders.ts +6 -6
  94. package/src/theme/global/colors.ts +4 -1
  95. package/src/theme/index.ts +12 -0
  96. package/testUtils/setup.tsx +17 -0
  97. package/types/components/Accordion/AccordionItem.d.ts +14 -0
  98. package/types/components/Accordion/StyledAccordion.d.ts +32 -0
  99. package/types/components/Accordion/__tests__/AccordionItem.spec.d.ts +1 -0
  100. package/types/components/Accordion/__tests__/StyledAccordion.spec.d.ts +1 -0
  101. package/types/components/Accordion/__tests__/index.spec.d.ts +1 -0
  102. package/types/components/Accordion/index.d.ts +38 -0
  103. package/types/components/Accordion/utils.d.ts +1 -0
  104. package/types/components/Button/IconButton.d.ts +1 -1
  105. package/types/components/Calendar/CalendarRowItem.d.ts +10 -0
  106. package/types/components/Calendar/StyledCalendar.d.ts +54 -0
  107. package/types/components/Calendar/__tests__/CalendarRowItem.spec.d.ts +1 -0
  108. package/types/components/Calendar/__tests__/helper.spec.d.ts +1 -0
  109. package/types/components/Calendar/__tests__/index.spec.d.ts +1 -0
  110. package/types/components/Calendar/helpers.d.ts +3 -0
  111. package/types/components/Calendar/index.d.ts +40 -0
  112. package/types/components/Collapse/index.d.ts +1 -1
  113. package/types/components/ContentNavigator/index.d.ts +5 -1
  114. package/types/components/Empty/StyledEmpty.d.ts +31 -0
  115. package/types/components/Empty/__tests__/index.spec.d.ts +1 -0
  116. package/types/components/Empty/index.d.ts +26 -0
  117. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +6 -1
  118. package/types/components/FAB/ActionGroup/index.d.ts +6 -1
  119. package/types/components/FAB/index.d.ts +1 -1
  120. package/types/components/Icon/IconList.d.ts +1 -1
  121. package/types/components/Icon/utils.d.ts +1 -1
  122. package/types/components/List/StyledBasicListItem.d.ts +3 -3
  123. package/types/components/List/StyledListItem.d.ts +3 -3
  124. package/types/components/RichTextEditor/EditorEvent.d.ts +3 -0
  125. package/types/components/RichTextEditor/EditorToolbar.d.ts +17 -0
  126. package/types/components/RichTextEditor/MentionList.d.ts +12 -0
  127. package/types/components/RichTextEditor/RichTextEditor.d.ts +65 -0
  128. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +16 -0
  129. package/types/components/RichTextEditor/StyledToolbar.d.ts +21 -0
  130. package/types/components/RichTextEditor/__tests__/EditorToolbar.spec.d.ts +1 -0
  131. package/types/components/RichTextEditor/__tests__/MentionList.spec.d.ts +1 -0
  132. package/types/components/RichTextEditor/__tests__/RichTextEditor.spec.d.ts +1 -0
  133. package/types/components/RichTextEditor/constants.d.ts +19 -0
  134. package/types/components/RichTextEditor/index.d.ts +5 -0
  135. package/types/components/RichTextEditor/utils/events.d.ts +8 -0
  136. package/types/components/RichTextEditor/utils/rnWebView.d.ts +7 -0
  137. package/types/components/SectionHeading/index.d.ts +2 -2
  138. package/types/components/Select/MultiSelect/OptionList.d.ts +1 -1
  139. package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
  140. package/types/components/Tag/StyledTag.d.ts +1 -1
  141. package/types/components/Tag/index.d.ts +1 -1
  142. package/types/components/Typography/Text/StyledText.d.ts +1 -1
  143. package/types/components/Typography/Text/index.d.ts +1 -1
  144. package/types/index.d.ts +5 -1
  145. package/types/theme/components/accordion.d.ts +13 -0
  146. package/types/theme/components/calendar.d.ts +26 -0
  147. package/types/theme/components/empty.d.ts +28 -0
  148. package/types/theme/components/fab.d.ts +1 -0
  149. package/types/theme/components/list.d.ts +1 -0
  150. package/types/theme/components/richTextEditor.d.ts +26 -0
  151. package/types/theme/components/tag.d.ts +8 -2
  152. package/types/theme/components/typography.d.ts +1 -0
  153. package/types/theme/global/colors.d.ts +4 -1
  154. package/types/theme/global/index.d.ts +4 -1
  155. package/types/theme/index.d.ts +8 -0
@@ -0,0 +1,217 @@
1
+ import React from 'react';
2
+ import format from 'date-fns/fp/format';
3
+ import ContentNavigator from '../ContentNavigator';
4
+ import Typography from '../Typography';
5
+ import {
6
+ StyledCalendarDayNameCell,
7
+ StyledCalendarHeader,
8
+ StyledCalendarRow,
9
+ StyledCalendarRowItem,
10
+ StyledContainer,
11
+ StyledDisabledCalendarRowItem,
12
+ } from './StyledCalendar';
13
+ import CalendarRowItem from './CalendarRowItem';
14
+ import { getValidDate, initArray, isEqDate } from './helpers';
15
+
16
+ const DAYS_OF_WEEK = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
17
+ // Sunday first column => 0
18
+ // Sunday last column => 1
19
+ const WEEK_INDEX_OFFSET = 1;
20
+ const SUNDAY_INDEX = 6;
21
+
22
+ // Always render 7 rows x 6 items for consistent layout
23
+ const TOTAL_DATES_ITEMS = 7 * 6;
24
+
25
+ type ParsedMaskedDate = {
26
+ [key: string]: boolean;
27
+ };
28
+
29
+ export interface CalendarProps {
30
+ /**
31
+ * Selected date value.
32
+ */
33
+ value?: Date;
34
+ /**
35
+ * Visible date of month that calendar opens to display. Default is now.
36
+ */
37
+ visibleDate: Date;
38
+ /**
39
+ * Mininum date. Restrict the range of possible date values.
40
+ */
41
+ minDate?: Date;
42
+ /**
43
+ * Maximum date. Restrict the range of possible date values.
44
+ */
45
+ maxDate?: Date;
46
+ /**
47
+ * Callback is called when selected date value is changed.
48
+ */
49
+ onChange?: (date: Date) => void;
50
+ /**
51
+ * Handler to be called when the user taps the previous button.
52
+ */
53
+ onPreviousPress?: () => void;
54
+ /**
55
+ * Handler to be called when the user taps the next button.
56
+ */
57
+ onNextPress?: () => void;
58
+ /**
59
+ * Handler to be called when the user taps the title.
60
+ */
61
+ onTitlePress?: () => void;
62
+ /**
63
+ * Mark dates to display on calendar..
64
+ */
65
+ markedDates?: Date[];
66
+ }
67
+
68
+ const Calendar = ({
69
+ value,
70
+ visibleDate,
71
+ onChange,
72
+ onPreviousPress = () => {},
73
+ onNextPress = () => {},
74
+ onTitlePress = () => {},
75
+ minDate,
76
+ maxDate,
77
+ markedDates = [],
78
+ }: CalendarProps) => {
79
+ const currentMonth = visibleDate.getMonth();
80
+ const currentYear = visibleDate.getFullYear();
81
+ const now = new Date();
82
+ const parsedMaskedDate: ParsedMaskedDate = markedDates.reduce(
83
+ (current, markedDate) => ({
84
+ ...current,
85
+ [markedDate.toDateString()]: true,
86
+ }),
87
+ {}
88
+ );
89
+
90
+ const firstDateOfMonth = new Date(currentYear, currentMonth, 1);
91
+ const lastDateOfMonth = new Date(currentYear, currentMonth + 1, 0);
92
+
93
+ const lastDateOfPreviousMonth = new Date(currentYear, currentMonth, 0);
94
+
95
+ // Index of day in week is shifted by 1 due to Sunday is the last column
96
+ const firstDayWeekIndexOfMonth =
97
+ firstDateOfMonth.getDay() === 0
98
+ ? SUNDAY_INDEX
99
+ : firstDateOfMonth.getDay() - WEEK_INDEX_OFFSET;
100
+
101
+ const lastDayIndexOfCurrentMonth = lastDateOfMonth.getDate();
102
+ const lastDayIndexOfPreviousMonth = lastDateOfPreviousMonth.getDate();
103
+
104
+ const daysOfPreviousMonth = initArray(firstDayWeekIndexOfMonth, index => {
105
+ const reversedIndex = firstDayWeekIndexOfMonth - index - 1;
106
+ const count = lastDayIndexOfPreviousMonth - reversedIndex;
107
+ return getValidDate(
108
+ new Date(currentYear, currentMonth - 1, count),
109
+ minDate,
110
+ maxDate
111
+ );
112
+ });
113
+
114
+ const daysOfCurrentMonth = initArray(lastDayIndexOfCurrentMonth, index =>
115
+ getValidDate(
116
+ new Date(currentYear, currentMonth, index + 1),
117
+ minDate,
118
+ maxDate
119
+ )
120
+ );
121
+
122
+ const daysOfNextMonth = initArray(
123
+ TOTAL_DATES_ITEMS -
124
+ (daysOfPreviousMonth.length + daysOfCurrentMonth.length),
125
+ index =>
126
+ getValidDate(
127
+ new Date(currentYear, currentMonth + 1, index + 1),
128
+ minDate,
129
+ maxDate
130
+ )
131
+ );
132
+
133
+ const disablePrevButton =
134
+ minDate === undefined
135
+ ? false
136
+ : !daysOfPreviousMonth.some(date => date !== undefined) &&
137
+ minDate >= firstDateOfMonth;
138
+
139
+ const disableNextButton =
140
+ maxDate === undefined
141
+ ? false
142
+ : !daysOfNextMonth.some(date => date !== undefined) ||
143
+ maxDate <= lastDateOfMonth;
144
+
145
+ return (
146
+ <StyledContainer>
147
+ <StyledCalendarHeader>
148
+ <ContentNavigator
149
+ value={format('MMMM yyyy', visibleDate)}
150
+ onPreviousPress={onPreviousPress}
151
+ onNextPress={onNextPress}
152
+ onPress={onTitlePress}
153
+ previousDisabled={disablePrevButton}
154
+ nextDisabled={disableNextButton}
155
+ fontSize="large"
156
+ />
157
+ </StyledCalendarHeader>
158
+ <StyledCalendarRow>
159
+ {DAYS_OF_WEEK.map(day => (
160
+ <StyledCalendarRowItem key={day}>
161
+ <StyledCalendarDayNameCell>
162
+ <Typography.Text>{day}</Typography.Text>
163
+ </StyledCalendarDayNameCell>
164
+ </StyledCalendarRowItem>
165
+ ))}
166
+ </StyledCalendarRow>
167
+ <StyledCalendarRow>
168
+ {daysOfPreviousMonth.map(date =>
169
+ date ? (
170
+ <CalendarRowItem
171
+ key={date.toDateString()}
172
+ date={date}
173
+ isCurrent={isEqDate(now, date)}
174
+ isSelected={isEqDate(value, date)}
175
+ onPress={() => onChange?.(date)}
176
+ textIntent="subdued"
177
+ marked={parsedMaskedDate[date.toDateString()]}
178
+ />
179
+ ) : (
180
+ <StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
181
+ )
182
+ )}
183
+ {daysOfCurrentMonth.map(date =>
184
+ date ? (
185
+ <CalendarRowItem
186
+ key={date.toDateString()}
187
+ date={date}
188
+ isCurrent={isEqDate(now, date)}
189
+ isSelected={isEqDate(value, date)}
190
+ onPress={() => onChange?.(date)}
191
+ marked={parsedMaskedDate[date.toDateString()]}
192
+ />
193
+ ) : (
194
+ <StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
195
+ )
196
+ )}
197
+ {daysOfNextMonth.map(date =>
198
+ date ? (
199
+ <CalendarRowItem
200
+ key={date.toDateString()}
201
+ date={date}
202
+ isCurrent={isEqDate(now, date)}
203
+ isSelected={isEqDate(value, date)}
204
+ onPress={() => onChange?.(date)}
205
+ textIntent="subdued"
206
+ marked={parsedMaskedDate[date.toDateString()]}
207
+ />
208
+ ) : (
209
+ <StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
210
+ )
211
+ )}
212
+ </StyledCalendarRow>
213
+ </StyledContainer>
214
+ );
215
+ };
216
+
217
+ export default Calendar;
@@ -13,7 +13,7 @@ import {
13
13
  } from './StyledCollapse';
14
14
  import { usePrevious } from '../../utils/hooks';
15
15
 
16
- interface CollapseProps extends ViewProps {
16
+ export interface CollapseProps extends ViewProps {
17
17
  /*
18
18
  * The collapse's content.
19
19
  */
@@ -39,35 +39,33 @@ const Collapse = ({ open = false, children, testID, style }: CollapseProps) => {
39
39
  const previousOpenState = usePrevious(open);
40
40
 
41
41
  useEffect(() => {
42
- if (open !== previousOpenState && previousOpenState !== undefined) {
42
+ if (
43
+ (open !== previousOpenState && previousOpenState !== undefined) ||
44
+ open
45
+ ) {
43
46
  Animated.timing(collapseAnim, {
44
47
  toValue: open ? contentHeight : 0,
45
- easing: Easing.inOut(Easing.ease),
48
+ easing: Easing.inOut(Easing.cubic),
46
49
  useNativeDriver: false,
47
50
  }).start();
48
51
  }
49
52
  }, [open, previousOpenState, contentHeight]);
50
53
 
51
- const fetchMaxHeight = useCallback(
52
- ({ height }) => {
53
- setContentHeight(height);
54
- },
55
- [contentHeight]
56
- );
54
+ const fetchMaxHeight = useCallback(({ height }) => {
55
+ setContentHeight(height);
56
+ }, []);
57
57
 
58
58
  return (
59
59
  <StyledWrapper
60
- style={[
61
- style,
62
- {
63
- height: collapseAnim,
64
- },
65
- ]}
60
+ style={{
61
+ height: collapseAnim,
62
+ }}
66
63
  testID={testID}
67
64
  >
68
65
  <StyledHiddenWrapper>
69
66
  <StyledChildWrapper
70
67
  onLayout={event => fetchMaxHeight(event.nativeEvent.layout)}
68
+ style={style}
71
69
  >
72
70
  {children}
73
71
  </StyledChildWrapper>
@@ -28,6 +28,10 @@ interface ContentNavigatorProps {
28
28
  * Whether the next icon is disabled.
29
29
  */
30
30
  nextDisabled?: boolean;
31
+ /**
32
+ * Content font size.
33
+ */
34
+ fontSize?: 'medium' | 'large';
31
35
  /**
32
36
  * Additional style.
33
37
  */
@@ -45,6 +49,7 @@ function ContentNavigator({
45
49
  value,
46
50
  previousDisabled = false,
47
51
  nextDisabled = false,
52
+ fontSize = 'medium',
48
53
  testID,
49
54
  style,
50
55
  }: ContentNavigatorProps) {
@@ -58,6 +63,7 @@ function ContentNavigator({
58
63
  />
59
64
  <Value
60
65
  fontWeight="semi-bold"
66
+ fontSize={fontSize}
61
67
  onPress={onPress}
62
68
  testID="content-navigator-value"
63
69
  >
@@ -0,0 +1,47 @@
1
+ import { View, Text } from 'react-native';
2
+ import styled from '@emotion/native';
3
+
4
+ type ThemeVariant = 'light' | 'dark';
5
+
6
+ const StyledWrapper = styled(View)(() => ({
7
+ display: 'flex',
8
+ flex: 1,
9
+ flexDirection: 'column',
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ }));
13
+
14
+ const StyledIllustration = styled(View)(({ theme }) => ({
15
+ height: theme.__hd__.empty.sizes.illustration,
16
+ width: theme.__hd__.empty.sizes.illustration,
17
+ borderRadius: theme.__hd__.empty.radii.illustration,
18
+ backgroundColor: theme.__hd__.empty.colors.illustrationBackground,
19
+ marginBottom: theme.__hd__.empty.space.large,
20
+ }));
21
+
22
+ const StyledTitle = styled(Text)<{ themeVariant: ThemeVariant }>(
23
+ ({ theme, themeVariant }) => ({
24
+ fontFamily: theme.__hd__.empty.fonts.title,
25
+ fontSize: theme.__hd__.empty.fontSizes.title,
26
+ textAlign: 'center',
27
+ marginBottom: theme.__hd__.empty.space.medium,
28
+ color:
29
+ themeVariant === 'dark'
30
+ ? theme.__hd__.empty.colors.invertedText
31
+ : theme.__hd__.empty.colors.text,
32
+ })
33
+ );
34
+
35
+ const StyledDescription = styled(Text)<{ themeVariant: ThemeVariant }>(
36
+ ({ theme, themeVariant }) => ({
37
+ fontFamily: theme.__hd__.empty.fonts.description,
38
+ fontSize: theme.__hd__.empty.fontSizes.description,
39
+ textAlign: 'center',
40
+ color:
41
+ themeVariant === 'dark'
42
+ ? theme.__hd__.empty.colors.invertedText
43
+ : theme.__hd__.empty.colors.subduedText,
44
+ })
45
+ );
46
+
47
+ export { StyledWrapper, StyledIllustration, StyledTitle, StyledDescription };
@@ -0,0 +1,66 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Empty renders empty state content correctly 1`] = `
4
+ <View
5
+ style={
6
+ Array [
7
+ Object {
8
+ "alignItems": "center",
9
+ "display": "flex",
10
+ "flex": 1,
11
+ "flexDirection": "column",
12
+ "justifyContent": "center",
13
+ },
14
+ undefined,
15
+ ]
16
+ }
17
+ >
18
+ <View
19
+ style={
20
+ Array [
21
+ Object {
22
+ "backgroundColor": "#dadbde",
23
+ "borderRadius": 999,
24
+ "height": 168,
25
+ "marginBottom": 24,
26
+ "width": 168,
27
+ },
28
+ undefined,
29
+ ]
30
+ }
31
+ />
32
+ <Text
33
+ style={
34
+ Array [
35
+ Object {
36
+ "color": "#292a2b",
37
+ "fontFamily": "BeVietnamPro-SemiBold",
38
+ "fontSize": 28,
39
+ "marginBottom": 16,
40
+ "textAlign": "center",
41
+ },
42
+ undefined,
43
+ ]
44
+ }
45
+ themeVariant="light"
46
+ >
47
+ You have no notification at this time
48
+ </Text>
49
+ <Text
50
+ style={
51
+ Array [
52
+ Object {
53
+ "color": "#727478",
54
+ "fontFamily": "BeVietnamPro-Light",
55
+ "fontSize": 16,
56
+ "textAlign": "center",
57
+ },
58
+ undefined,
59
+ ]
60
+ }
61
+ themeVariant="light"
62
+ >
63
+ We'll notify you later.
64
+ </Text>
65
+ </View>
66
+ `;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+
3
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
+ import Empty from '..';
5
+
6
+ describe('Empty', () => {
7
+ it('renders empty state content correctly', () => {
8
+ const { toJSON } = renderWithTheme(
9
+ <Empty
10
+ title="You have no notification at this time"
11
+ description="We'll notify you later."
12
+ />
13
+ );
14
+
15
+ expect(toJSON()).toMatchSnapshot();
16
+ });
17
+ });
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+
4
+ import {
5
+ StyledWrapper,
6
+ StyledIllustration,
7
+ StyledTitle,
8
+ StyledDescription,
9
+ } from './StyledEmpty';
10
+
11
+ interface EmptyProps {
12
+ /**
13
+ * Empty's title.
14
+ */
15
+ title: string;
16
+ /**
17
+ * Empty's description.
18
+ */
19
+ description?: string;
20
+ /**
21
+ * Empty's variant
22
+ * 'dark' if rendered on a dark background and 'white' otherwise
23
+ */
24
+ variant?: 'light' | 'dark';
25
+ /**
26
+ * Additional style.
27
+ */
28
+ style?: StyleProp<ViewStyle>;
29
+ /**
30
+ * Testing id of the component.
31
+ */
32
+ testID?: string;
33
+ }
34
+
35
+ const Empty = ({
36
+ title,
37
+ description,
38
+ style,
39
+ testID,
40
+ variant = 'light',
41
+ }: EmptyProps): JSX.Element => (
42
+ <StyledWrapper style={style} testID={testID}>
43
+ <StyledIllustration />
44
+ <StyledTitle themeVariant={variant}>{title}</StyledTitle>
45
+ {description && (
46
+ <StyledDescription themeVariant={variant}>
47
+ {description}
48
+ </StyledDescription>
49
+ )}
50
+ </StyledWrapper>
51
+ );
52
+
53
+ export default Empty;
@@ -1,7 +1,11 @@
1
1
  import React, { ComponentProps } from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
3
  import Icon from '../../Icon';
4
- import { StyledActionItem, StyledActionItemText } from './StyledActionItem';
4
+ import {
5
+ StyledActionItem,
6
+ StyledActionItemText,
7
+ StyledIcon,
8
+ } from './StyledActionItem';
5
9
 
6
10
  export interface ActionItemProps {
7
11
  testID?: string;
@@ -18,7 +22,7 @@ const ActionItem = ({
18
22
  testID,
19
23
  }: ActionItemProps) => (
20
24
  <StyledActionItem style={style} onPress={onPress} testID={testID}>
21
- <Icon icon={icon} />
25
+ <StyledIcon icon={icon} />
22
26
  <StyledActionItemText>{title}</StyledActionItemText>
23
27
  </StyledActionItem>
24
28
  );
@@ -43,6 +43,7 @@ const StyledBackdrop = styled(Animated.View)<
43
43
  const StyledHeaderText = styled(Typography.Text)<TextProps>(({ theme }) => ({
44
44
  fontSize: theme.__hd__.fab.fontSizes.header,
45
45
  lineHeight: theme.__hd__.fab.lineHeights.header,
46
+ color: theme.__hd__.fab.colors.titleText,
46
47
  fontFamily: theme.__hd__.fab.fonts.header,
47
48
  marginRight: theme.__hd__.fab.space.headerTextMarginRight,
48
49
  marginBottom: theme.__hd__.fab.space.headerTextMarginBottom,
@@ -1,6 +1,7 @@
1
1
  import { TouchableOpacity, TouchableOpacityProps } from 'react-native';
2
2
  import styled from '@emotion/native';
3
3
  import Typography from '../../Typography';
4
+ import Icon, { IconProps } from '../../Icon';
4
5
 
5
6
  const StyledActionItem = styled(TouchableOpacity)<TouchableOpacityProps>(
6
7
  ({ theme }) => ({
@@ -25,7 +26,12 @@ const StyledActionItemText = styled(Typography.Text)<TouchableOpacityProps>(
25
26
  fontSize: theme.__hd__.fab.fontSizes.actionItemText,
26
27
  lineHeight: theme.__hd__.fab.lineHeights.actionItemText,
27
28
  fontFamily: theme.__hd__.fab.fonts.actionItemText,
29
+ color: theme.__hd__.fab.colors.actionItemText,
28
30
  })
29
31
  );
30
32
 
31
- export { StyledActionItem, StyledActionItemText };
33
+ const StyledIcon = styled(Icon)<IconProps>(({ theme }) => ({
34
+ color: theme.__hd__.fab.colors.actionItemText,
35
+ }));
36
+
37
+ export { StyledIcon, StyledActionItem, StyledActionItemText };