@hero-design/rn 7.0.1 → 7.0.4

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 (85) hide show
  1. package/assets/fonts/hero-icons.ttf +0 -0
  2. package/es/index.js +10043 -148
  3. package/jest.config.js +1 -0
  4. package/lib/index.js +10046 -147
  5. package/package.json +14 -3
  6. package/playground/components/Badge.tsx +50 -0
  7. package/playground/components/Card.tsx +223 -37
  8. package/playground/components/Icon.tsx +140 -0
  9. package/playground/components/Typography.tsx +21 -0
  10. package/playground/index.tsx +42 -11
  11. package/react-native.config.js +5 -0
  12. package/src/components/Badge/StyledBadge.tsx +34 -0
  13. package/src/components/Badge/__tests__/Badge.spec.tsx +50 -0
  14. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +161 -0
  15. package/src/components/Badge/index.tsx +35 -0
  16. package/src/components/Icon/HeroIcon/index.tsx +30 -0
  17. package/src/components/Icon/HeroIcon/selection.json +1 -0
  18. package/src/components/Icon/IconList.ts +298 -0
  19. package/src/components/Icon/__tests__/Icon.spec.tsx +36 -0
  20. package/src/components/Icon/__tests__/__snapshots__/Icon.spec.tsx.snap +43 -0
  21. package/src/components/Icon/index.tsx +47 -0
  22. package/src/components/Typography/Text/StyledText.tsx +69 -0
  23. package/src/components/Typography/Text/__test__/StyledText.spec.tsx +62 -0
  24. package/src/components/Typography/Text/__test__/__snapshots__/StyledText.spec.tsx.snap +172 -0
  25. package/src/components/Typography/Text/__test__/index.spec.tsx +11 -0
  26. package/src/components/Typography/Text/index.tsx +41 -0
  27. package/src/components/Typography/index.tsx +11 -0
  28. package/src/index.ts +15 -2
  29. package/src/testHelpers/renderWithTheme.tsx +8 -0
  30. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +71 -0
  31. package/src/theme/components/badge.ts +38 -0
  32. package/src/theme/components/icon.ts +24 -0
  33. package/src/theme/components/typography.ts +32 -0
  34. package/src/theme/global/typography.ts +4 -0
  35. package/src/theme/index.ts +12 -3
  36. package/testUtils/setup.ts +3 -0
  37. package/tsconfig.json +2 -6
  38. package/types/index.d.ts +3 -4
  39. package/types/playground/components/Badge.d.ts +2 -0
  40. package/types/playground/components/Card.d.ts +2 -0
  41. package/types/playground/components/Divider.d.ts +2 -0
  42. package/types/playground/components/Icon.d.ts +2 -0
  43. package/types/playground/components/Typography.d.ts +2 -0
  44. package/types/playground/index.d.ts +2 -0
  45. package/types/src/components/Badge/StyledBadge.d.ts +9 -0
  46. package/types/{components/Card/__tests__/Card.spec.d.ts → src/components/Badge/__tests__/Badge.spec.d.ts} +0 -0
  47. package/types/src/components/Badge/index.d.ts +22 -0
  48. package/types/{components → src/components}/Card/StyledCard.d.ts +0 -0
  49. package/types/{components/Card/__tests__/StyledCard.spec.d.ts → src/components/Card/__tests__/Card.spec.d.ts} +0 -0
  50. package/types/{components/Divider/__tests__/StyledDivider.spec.d.ts → src/components/Card/__tests__/StyledCard.spec.d.ts} +0 -0
  51. package/types/{components → src/components}/Card/index.d.ts +0 -0
  52. package/types/{components → src/components}/Divider/StyledDivider.d.ts +0 -0
  53. package/types/{theme/__tests__/index.spec.d.ts → src/components/Divider/__tests__/StyledDivider.spec.d.ts} +0 -0
  54. package/types/{components → src/components}/Divider/index.d.ts +0 -0
  55. package/types/src/components/Icon/HeroIcon/index.d.ts +7 -0
  56. package/types/src/components/Icon/IconList.d.ts +2 -0
  57. package/types/src/components/Icon/__tests__/Icon.spec.d.ts +1 -0
  58. package/types/src/components/Icon/index.d.ts +27 -0
  59. package/types/src/components/Typography/Text/StyledText.d.ts +7 -0
  60. package/types/src/components/Typography/Text/__test__/StyledText.spec.d.ts +1 -0
  61. package/types/src/components/Typography/Text/__test__/index.spec.d.ts +1 -0
  62. package/types/src/components/Typography/Text/index.d.ts +22 -0
  63. package/types/src/components/Typography/index.d.ts +6 -0
  64. package/types/src/index.d.ts +8 -0
  65. package/types/src/styled-components.d.ts +6 -0
  66. package/types/src/testHelpers/renderWithTheme.d.ts +3 -0
  67. package/types/src/theme/__tests__/index.spec.d.ts +1 -0
  68. package/types/src/theme/components/badge.d.ts +29 -0
  69. package/types/{theme → src/theme}/components/card.d.ts +0 -0
  70. package/types/{theme → src/theme}/components/divider.d.ts +0 -0
  71. package/types/src/theme/components/icon.d.ts +19 -0
  72. package/types/src/theme/components/typography.d.ts +25 -0
  73. package/types/{theme → src/theme}/global/borders.d.ts +0 -0
  74. package/types/src/theme/global/colors.d.ts +26 -0
  75. package/types/src/theme/global/index.d.ts +67 -0
  76. package/types/src/theme/global/space.d.ts +12 -0
  77. package/types/src/theme/global/typography.d.ts +25 -0
  78. package/types/src/theme/index.d.ts +19 -0
  79. package/types/theme/colors.d.ts +24 -0
  80. package/types/theme/components/demoStyle.d.ts +11 -0
  81. package/types/theme/global/colors.d.ts +0 -2
  82. package/types/theme/global/index.d.ts +0 -5
  83. package/types/theme/index.d.ts +2 -4
  84. package/types/theme/space.d.ts +12 -0
  85. package/types/theme/typography.d.ts +21 -0
@@ -0,0 +1,298 @@
1
+ const IconList = [
2
+ 'activate',
3
+ 'add-person',
4
+ 'adjustment',
5
+ 'alignment',
6
+ 'bank',
7
+ 'bell',
8
+ 'billing',
9
+ 'bookmark',
10
+ 'box-check',
11
+ 'box',
12
+ 'buildings',
13
+ 'cake',
14
+ 'calendar-clock',
15
+ 'calendar',
16
+ 'carat-down-small',
17
+ 'carat-down',
18
+ 'carat-left',
19
+ 'carat-right',
20
+ 'carat-up',
21
+ 'circle-add',
22
+ 'circle-cancel',
23
+ 'circle-check',
24
+ 'circle-down',
25
+ 'circle-info',
26
+ 'circle-left',
27
+ 'circle-ok',
28
+ 'circle-pencil',
29
+ 'circle-question',
30
+ 'circle-remove',
31
+ 'circle-right',
32
+ 'circle-up',
33
+ 'circle-warning',
34
+ 'clock',
35
+ 'cloud-download',
36
+ 'cloud-upload',
37
+ 'cog',
38
+ 'coin',
39
+ 'contacts',
40
+ 'credit-card',
41
+ 'diamond',
42
+ 'direction-arrows',
43
+ 'directory',
44
+ 'document',
45
+ 'dollar-coin-shine',
46
+ 'double-buildings',
47
+ 'edit-template',
48
+ 'envelope',
49
+ 'expense',
50
+ 'eye-circle',
51
+ 'eye-invisible',
52
+ 'eye',
53
+ 'face-meh',
54
+ 'face-sad',
55
+ 'face-smiley',
56
+ 'feed',
57
+ 'feedbacks',
58
+ 'file-certified',
59
+ 'file-clone',
60
+ 'file-copy',
61
+ 'file-csv',
62
+ 'file-dispose',
63
+ 'file-doc',
64
+ 'file-excel',
65
+ 'file-export',
66
+ 'file-lock',
67
+ 'file-pdf',
68
+ 'file-powerpoint',
69
+ 'file-search',
70
+ 'file-secured',
71
+ 'file-sheets',
72
+ 'file-slide',
73
+ 'file-verified',
74
+ 'file-word',
75
+ 'file',
76
+ 'folder-user',
77
+ 'folder',
78
+ 'funnel-filter',
79
+ 'global-dollar',
80
+ 'globe',
81
+ 'graduation-cap',
82
+ 'graph',
83
+ 'happy-sun',
84
+ 'health-bag',
85
+ 'heart',
86
+ 'home',
87
+ 'image',
88
+ 'import',
89
+ 'incident-siren',
90
+ 'instapay',
91
+ 'list',
92
+ 'loading',
93
+ 'loading-2',
94
+ 'location',
95
+ 'lock',
96
+ 'media-content',
97
+ 'menu',
98
+ 'moneybag',
99
+ 'moon',
100
+ 'multiple-stars',
101
+ 'multiple-users',
102
+ 'node',
103
+ 'open-folder',
104
+ 'paperclip',
105
+ 'payment-summary',
106
+ 'pencil',
107
+ 'phone',
108
+ 'piggy-bank',
109
+ 'plane',
110
+ 'play-circle',
111
+ 'print',
112
+ 'raising-hands',
113
+ 'reply',
114
+ 'reschedule',
115
+ 'rostering',
116
+ 'save',
117
+ 'schedule',
118
+ 'search-person',
119
+ 'send',
120
+ 'speaker',
121
+ 'star-medal',
122
+ 'star',
123
+ 'steps-circle',
124
+ 'stopwatch',
125
+ 'suitcase',
126
+ 'survey',
127
+ 'switch',
128
+ 'tag',
129
+ 'target',
130
+ 'teams',
131
+ 'timesheet',
132
+ 'touch-id',
133
+ 'trash-bin',
134
+ 'unlock',
135
+ 'user',
136
+ 'video-1',
137
+ 'video-2',
138
+ 'activate-outlined',
139
+ 'add-person-outlined',
140
+ 'add-section-outlined',
141
+ 'add-time-outlined',
142
+ 'add',
143
+ 'adjustment-outlined',
144
+ 'alignment-2-outlined',
145
+ 'alignment-outlined',
146
+ 'all-caps',
147
+ 'arrow-down',
148
+ 'arrow-left',
149
+ 'arrow-right',
150
+ 'arrow-up',
151
+ 'at-sign',
152
+ 'bell-outlined',
153
+ 'billing-outlined',
154
+ 'body-outlined',
155
+ 'bold',
156
+ 'bookmark-outlined',
157
+ 'box-check-outlined',
158
+ 'box-outlined',
159
+ 'bullet-points',
160
+ 'cake-outlined',
161
+ 'calendar-dates-outlined',
162
+ 'calendar-star-outlined',
163
+ 'camera-outlined',
164
+ 'cancel',
165
+ 'checkmark',
166
+ 'circle-add-outlined',
167
+ 'circle-cancel-outlined',
168
+ 'circle-down-outlined',
169
+ 'circle-info-outlined',
170
+ 'circle-left-outlined',
171
+ 'circle-ok-outlined',
172
+ 'circle-question-outlined',
173
+ 'circle-remove-outlined',
174
+ 'circle-right-outlined',
175
+ 'circle-up-outlined',
176
+ 'circle-warning-outlined',
177
+ 'clock-2-outlined',
178
+ 'clock-outlined',
179
+ 'cog-outlined',
180
+ 'coin-outlined',
181
+ 'comment-outlined',
182
+ 'contacts-outlined',
183
+ 'credit-card-outlined',
184
+ 'direction-arrows-outlined',
185
+ 'directory-outlined',
186
+ 'document-outlined',
187
+ 'dollar-coin-shine-outlined',
188
+ 'dollar-sign',
189
+ 'double-buildings-outlined',
190
+ 'double-left-arrows',
191
+ 'double-right-arrows',
192
+ 'download-outlined',
193
+ 'edit-template-outlined',
194
+ 'email-outlined',
195
+ 'enter-arrow',
196
+ 'envelope-outlined',
197
+ 'expense-outlined',
198
+ 'external-link',
199
+ 'eye-invisible-outlined',
200
+ 'eye-outlined',
201
+ 'face-id',
202
+ 'face-meh-outlined',
203
+ 'face-open-smiley-outlined',
204
+ 'face-sad-outlined',
205
+ 'face-smiley-outlined',
206
+ 'feed-outlined',
207
+ 'file-certified-outlined',
208
+ 'file-clone-outlined',
209
+ 'file-copy-outlined',
210
+ 'file-dispose-outlined',
211
+ 'file-download-outlined',
212
+ 'file-export-outlined',
213
+ 'file-lock-outlined',
214
+ 'file-outlined',
215
+ 'file-search-outlined',
216
+ 'file-secured-outlined',
217
+ 'file-verified-outlined',
218
+ 'folder-outlined',
219
+ 'folder-user-outlined',
220
+ 'funnel-filter-outline',
221
+ 'graph-outlined',
222
+ 'happy-sun-outlined',
223
+ 'health-bag-outlined',
224
+ 'heart-outlined',
225
+ 'home-outlined',
226
+ 'image-outlined',
227
+ 'import-outlined',
228
+ 'instapay-outlined',
229
+ 'italic',
230
+ 'link-1',
231
+ 'link-2',
232
+ 'list-outlined',
233
+ 'location-outlined',
234
+ 'lock-outlined',
235
+ 'locked-file-outlined',
236
+ 'log-out',
237
+ 'media-content-outlined',
238
+ 'menu-close',
239
+ 'menu-expand',
240
+ 'menu-fold-outlined',
241
+ 'menu-unfold-outlined',
242
+ 'moneybag-outlined',
243
+ 'moon-outlined',
244
+ 'more-horizontal',
245
+ 'more-vertical',
246
+ 'multiple-folders-outlined',
247
+ 'multiple-users-outlined',
248
+ 'node-outlined',
249
+ 'number-points',
250
+ 'number',
251
+ 'payment-summary-outlined',
252
+ 'payslip-outlined',
253
+ 'pencil-outlined',
254
+ 'percentage',
255
+ 'phone-outlined',
256
+ 'piggy-bank-outlined',
257
+ 'plane-outlined',
258
+ 'play-circle-outlined',
259
+ 'print-outlined',
260
+ 'qr-code-outlined',
261
+ 're-assign',
262
+ 'refresh',
263
+ 'remove',
264
+ 'reply-outlined',
265
+ 'restart',
266
+ 'return-arrow',
267
+ 'rostering-outlined',
268
+ 'save-outlined',
269
+ 'schedule-outlined',
270
+ 'search-outlined',
271
+ 'send-outlined',
272
+ 'share-1',
273
+ 'share-2',
274
+ 'single-down-arrow',
275
+ 'single-left-arrow',
276
+ 'single-right-arrow',
277
+ 'single-up-arrow',
278
+ 'speaker-outlined',
279
+ 'star-outlined',
280
+ 'stopwatch-outlined',
281
+ 'strikethrough',
282
+ 'survey-outlined',
283
+ 'switch-outlined',
284
+ 'sync',
285
+ 'target-outlined',
286
+ 'timesheet-outlined',
287
+ 'transfer',
288
+ 'trash-bin-outlined',
289
+ 'unavailable',
290
+ 'underline',
291
+ 'unlock-outlined',
292
+ 'upload-outlined',
293
+ 'user-outlined',
294
+ 'video-1-outlined',
295
+ 'video-2-outlined',
296
+ ] as const;
297
+
298
+ export default IconList;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react-native';
3
+ import { ThemeProvider, theme } from '../../../index';
4
+ import Icon from '..';
5
+
6
+ describe('Icon', () => {
7
+ it('renders correctly', () => {
8
+ const { toJSON } = render(
9
+ <ThemeProvider theme={theme}>
10
+ <Icon icon="home" />
11
+ </ThemeProvider>
12
+ );
13
+
14
+ expect(toJSON()).toMatchSnapshot();
15
+ });
16
+
17
+ it('renders correctly with intent', () => {
18
+ const { toJSON } = render(
19
+ <ThemeProvider theme={theme}>
20
+ <Icon icon="home" intent="primary" />
21
+ </ThemeProvider>
22
+ );
23
+
24
+ expect(toJSON()).toMatchSnapshot();
25
+ });
26
+
27
+ it('renders correctly with color and size', () => {
28
+ const { toJSON } = render(
29
+ <ThemeProvider theme={theme}>
30
+ <Icon icon="home" intent="danger" size="large" />
31
+ </ThemeProvider>
32
+ );
33
+
34
+ expect(toJSON()).toMatchSnapshot();
35
+ });
36
+ });
@@ -0,0 +1,43 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Icon renders correctly 1`] = `
4
+ <HeroIcon
5
+ name="home"
6
+ style={
7
+ Object {
8
+ "color": "#292a2b",
9
+ "fontSize": 24,
10
+ }
11
+ }
12
+ themeIntent="text"
13
+ themeSize="medium"
14
+ />
15
+ `;
16
+
17
+ exports[`Icon renders correctly with color and size 1`] = `
18
+ <HeroIcon
19
+ name="home"
20
+ style={
21
+ Object {
22
+ "color": "#de350b",
23
+ "fontSize": 28,
24
+ }
25
+ }
26
+ themeIntent="danger"
27
+ themeSize="large"
28
+ />
29
+ `;
30
+
31
+ exports[`Icon renders correctly with intent 1`] = `
32
+ <HeroIcon
33
+ name="home"
34
+ style={
35
+ Object {
36
+ "color": "#7622d7",
37
+ "fontSize": 24,
38
+ }
39
+ }
40
+ themeIntent="primary"
41
+ themeSize="medium"
42
+ />
43
+ `;
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ import IconList from './IconList';
4
+ import HeroIcon from './HeroIcon';
5
+
6
+ type IconName = typeof IconList[number];
7
+
8
+ interface IconProps {
9
+ /**
10
+ * Name of the `Icon`.
11
+ */
12
+ icon: IconName;
13
+ /**
14
+ * Addditional style to be applied for `Icon`.
15
+ */
16
+ style?: StyleProp<ViewStyle>;
17
+ /**
18
+ * Size of the `Icon`.
19
+ */
20
+ size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
21
+ /**
22
+ * Intent of the `Icon`.
23
+ */
24
+ intent?: 'text' | 'primary' | 'info' | 'danger' | 'success' | 'warning';
25
+ /**
26
+ * Testing id of the component.
27
+ */
28
+ testID?: string;
29
+ }
30
+
31
+ const Icon = ({
32
+ icon,
33
+ style,
34
+ size = 'medium',
35
+ intent = 'text',
36
+ testID,
37
+ }: IconProps) => (
38
+ <HeroIcon
39
+ name={icon}
40
+ themeIntent={intent}
41
+ themeSize={size}
42
+ style={style}
43
+ testID={testID}
44
+ />
45
+ );
46
+
47
+ export default Icon;
@@ -0,0 +1,69 @@
1
+ import { Text } from 'react-native';
2
+ import styled, { css } from '../../../styled-components';
3
+
4
+ const StyledText = styled(Text)<{
5
+ themeFontSize: 'small' | 'medium' | 'large' | 'xlarge';
6
+ themeFontWeight: 'light' | 'regular' | 'semi-bold';
7
+ themeIntent: 'body' | 'subdued';
8
+ }>`
9
+ ${({ themeFontSize, theme }) => {
10
+ switch (themeFontSize) {
11
+ case 'small':
12
+ return css`
13
+ font-size: ${theme.__hd__.typography.fontSizes.small}px;
14
+ line-height: ${theme.__hd__.typography.lineHeights.small};
15
+ letter-spacing: ${theme.__hd__.typography.fontSizes.small * 0.03}px;
16
+ `;
17
+ case 'medium':
18
+ return css`
19
+ font-size: ${theme.__hd__.typography.fontSizes.medium}px;
20
+ line-height: ${theme.__hd__.typography.lineHeights.medium};
21
+ letter-spacing: ${theme.__hd__.typography.fontSizes.medium * 0.03}px;
22
+ `;
23
+ case 'large':
24
+ return css`
25
+ font-size: ${theme.__hd__.typography.fontSizes.large}px;
26
+ line-height: ${theme.__hd__.typography.lineHeights.large};
27
+ letter-spacing: ${theme.__hd__.typography.fontSizes.large * 0.03}px;
28
+ `;
29
+ case 'xlarge':
30
+ return css`
31
+ font-size: ${theme.__hd__.typography.fontSizes.xlarge}px;
32
+ line-height: ${theme.__hd__.typography.lineHeights.xlarge};
33
+ letter-spacing: ${theme.__hd__.typography.fontSizes.xlarge * 0.03}px;
34
+ `;
35
+ }
36
+ }}
37
+
38
+ ${({ themeFontWeight, theme }) => {
39
+ switch (themeFontWeight) {
40
+ case 'light':
41
+ return css`
42
+ font-weight: ${theme.__hd__.typography.fontWeights.light};
43
+ `;
44
+ case 'regular':
45
+ return css`
46
+ font-weight: ${theme.__hd__.typography.fontWeights.regular};
47
+ `;
48
+ case 'semi-bold':
49
+ return css`
50
+ font-weight: ${theme.__hd__.typography.fontWeights.semiBold};
51
+ `;
52
+ }
53
+ }}
54
+
55
+ ${({ themeIntent, theme }) => {
56
+ switch (themeIntent) {
57
+ case 'body':
58
+ return css`
59
+ color: ${theme.__hd__.typography.colors.body};
60
+ `;
61
+ case 'subdued':
62
+ return css`
63
+ color: ${theme.__hd__.typography.colors.subdued};
64
+ `;
65
+ }
66
+ }}
67
+ `;
68
+
69
+ export { StyledText };
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import renderWithTheme from '../../../../testHelpers/renderWithTheme';
3
+ import { StyledText } from '../StyledText';
4
+
5
+ describe('StyledText', () => {
6
+ it.each`
7
+ fontSize
8
+ ${'small'}
9
+ ${'medium'}
10
+ ${'large'}
11
+ ${'xlarge'}
12
+ `('has $fontSize fontSize style', ({ fontSize }) => {
13
+ const { toJSON } = renderWithTheme(
14
+ <StyledText
15
+ themeFontSize={fontSize}
16
+ themeFontWeight="regular"
17
+ themeIntent="body"
18
+ >
19
+ This is a test
20
+ </StyledText>
21
+ );
22
+
23
+ expect(toJSON()).toMatchSnapshot();
24
+ });
25
+
26
+ it.each`
27
+ fontWeight
28
+ ${'light'}
29
+ ${'regular'}
30
+ ${'semi-bold'}
31
+ `('has $fontWeight fontWeight style', ({ fontWeight }) => {
32
+ const { toJSON } = renderWithTheme(
33
+ <StyledText
34
+ themeFontSize="medium"
35
+ themeFontWeight={fontWeight}
36
+ themeIntent="body"
37
+ >
38
+ This is a test
39
+ </StyledText>
40
+ );
41
+
42
+ expect(toJSON()).toMatchSnapshot();
43
+ });
44
+
45
+ it.each`
46
+ intent
47
+ ${'body'}
48
+ ${'subdued'}
49
+ `('has $intent intent style', ({ intent }) => {
50
+ const { toJSON } = renderWithTheme(
51
+ <StyledText
52
+ themeFontSize="medium"
53
+ themeFontWeight="regular"
54
+ themeIntent={intent}
55
+ >
56
+ This is a test
57
+ </StyledText>
58
+ );
59
+
60
+ expect(toJSON()).toMatchSnapshot();
61
+ });
62
+ });