@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,50 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react-native';
3
+ import { ThemeProvider, theme } from '../../../index';
4
+ import Badge from '..';
5
+
6
+ describe('Badge', () => {
7
+ it('has success style when intent is success', () => {
8
+ const { getByText, toJSON } = render(
9
+ <ThemeProvider theme={theme}>
10
+ <Badge content="APPROVED" intent="success" />
11
+ </ThemeProvider>
12
+ );
13
+
14
+ expect(toJSON()).toMatchSnapshot();
15
+ expect(getByText('APPROVED')).toBeDefined();
16
+ });
17
+
18
+ it('has warning style when intent is warning', () => {
19
+ const { getByText, toJSON } = render(
20
+ <ThemeProvider theme={theme}>
21
+ <Badge content="PENDING" intent="warning" />
22
+ </ThemeProvider>
23
+ );
24
+
25
+ expect(toJSON()).toMatchSnapshot();
26
+ expect(getByText('PENDING')).toBeDefined();
27
+ });
28
+
29
+ it('has danger style when intent is danger', () => {
30
+ const { getByText, toJSON } = render(
31
+ <ThemeProvider theme={theme}>
32
+ <Badge content="DECLINED" intent="danger" />
33
+ </ThemeProvider>
34
+ );
35
+
36
+ expect(toJSON()).toMatchSnapshot();
37
+ expect(getByText('DECLINED')).toBeDefined();
38
+ });
39
+
40
+ it('has info style when intent is info', () => {
41
+ const { getByText, toJSON } = render(
42
+ <ThemeProvider theme={theme}>
43
+ <Badge content="SUBMITTED" intent="info" />
44
+ </ThemeProvider>
45
+ );
46
+
47
+ expect(toJSON()).toMatchSnapshot();
48
+ expect(getByText('SUBMITTED')).toBeDefined();
49
+ });
50
+ });
@@ -0,0 +1,161 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Badge has danger style when intent is danger 1`] = `
4
+ <View
5
+ style={
6
+ Object {
7
+ "backgroundColor": "#fcebe7",
8
+ "borderBottomColor": "#de350b",
9
+ "borderBottomLeftRadius": 4,
10
+ "borderBottomRightRadius": 4,
11
+ "borderBottomWidth": 1,
12
+ "borderLeftColor": "#de350b",
13
+ "borderLeftWidth": 1,
14
+ "borderRightColor": "#de350b",
15
+ "borderRightWidth": 1,
16
+ "borderTopColor": "#de350b",
17
+ "borderTopLeftRadius": 4,
18
+ "borderTopRightRadius": 4,
19
+ "borderTopWidth": 1,
20
+ "paddingBottom": 4,
21
+ "paddingLeft": 8,
22
+ "paddingRight": 8,
23
+ "paddingTop": 4,
24
+ }
25
+ }
26
+ themeIntent="danger"
27
+ >
28
+ <Text
29
+ style={
30
+ Object {
31
+ "color": "#de350b",
32
+ "fontSize": 12,
33
+ "fontWeight": "600",
34
+ }
35
+ }
36
+ themeIntent="danger"
37
+ >
38
+ DECLINED
39
+ </Text>
40
+ </View>
41
+ `;
42
+
43
+ exports[`Badge has info style when intent is info 1`] = `
44
+ <View
45
+ style={
46
+ Object {
47
+ "backgroundColor": "#ecf0ff",
48
+ "borderBottomColor": "#4568fb",
49
+ "borderBottomLeftRadius": 4,
50
+ "borderBottomRightRadius": 4,
51
+ "borderBottomWidth": 1,
52
+ "borderLeftColor": "#4568fb",
53
+ "borderLeftWidth": 1,
54
+ "borderRightColor": "#4568fb",
55
+ "borderRightWidth": 1,
56
+ "borderTopColor": "#4568fb",
57
+ "borderTopLeftRadius": 4,
58
+ "borderTopRightRadius": 4,
59
+ "borderTopWidth": 1,
60
+ "paddingBottom": 4,
61
+ "paddingLeft": 8,
62
+ "paddingRight": 8,
63
+ "paddingTop": 4,
64
+ }
65
+ }
66
+ themeIntent="info"
67
+ >
68
+ <Text
69
+ style={
70
+ Object {
71
+ "color": "#4568fb",
72
+ "fontSize": 12,
73
+ "fontWeight": "600",
74
+ }
75
+ }
76
+ themeIntent="info"
77
+ >
78
+ SUBMITTED
79
+ </Text>
80
+ </View>
81
+ `;
82
+
83
+ exports[`Badge has success style when intent is success 1`] = `
84
+ <View
85
+ style={
86
+ Object {
87
+ "backgroundColor": "#f0fef4",
88
+ "borderBottomColor": "#017d6d",
89
+ "borderBottomLeftRadius": 4,
90
+ "borderBottomRightRadius": 4,
91
+ "borderBottomWidth": 1,
92
+ "borderLeftColor": "#017d6d",
93
+ "borderLeftWidth": 1,
94
+ "borderRightColor": "#017d6d",
95
+ "borderRightWidth": 1,
96
+ "borderTopColor": "#017d6d",
97
+ "borderTopLeftRadius": 4,
98
+ "borderTopRightRadius": 4,
99
+ "borderTopWidth": 1,
100
+ "paddingBottom": 4,
101
+ "paddingLeft": 8,
102
+ "paddingRight": 8,
103
+ "paddingTop": 4,
104
+ }
105
+ }
106
+ themeIntent="success"
107
+ >
108
+ <Text
109
+ style={
110
+ Object {
111
+ "color": "#017d6d",
112
+ "fontSize": 12,
113
+ "fontWeight": "600",
114
+ }
115
+ }
116
+ themeIntent="success"
117
+ >
118
+ APPROVED
119
+ </Text>
120
+ </View>
121
+ `;
122
+
123
+ exports[`Badge has warning style when intent is warning 1`] = `
124
+ <View
125
+ style={
126
+ Object {
127
+ "backgroundColor": "#fff6eb",
128
+ "borderBottomColor": "#d98a2c",
129
+ "borderBottomLeftRadius": 4,
130
+ "borderBottomRightRadius": 4,
131
+ "borderBottomWidth": 1,
132
+ "borderLeftColor": "#d98a2c",
133
+ "borderLeftWidth": 1,
134
+ "borderRightColor": "#d98a2c",
135
+ "borderRightWidth": 1,
136
+ "borderTopColor": "#d98a2c",
137
+ "borderTopLeftRadius": 4,
138
+ "borderTopRightRadius": 4,
139
+ "borderTopWidth": 1,
140
+ "paddingBottom": 4,
141
+ "paddingLeft": 8,
142
+ "paddingRight": 8,
143
+ "paddingTop": 4,
144
+ }
145
+ }
146
+ themeIntent="warning"
147
+ >
148
+ <Text
149
+ style={
150
+ Object {
151
+ "color": "#d98a2c",
152
+ "fontSize": 12,
153
+ "fontWeight": "600",
154
+ }
155
+ }
156
+ themeIntent="warning"
157
+ >
158
+ PENDING
159
+ </Text>
160
+ </View>
161
+ `;
@@ -0,0 +1,35 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ import React, { ReactElement } from 'react';
3
+ import { StyledView, StyledText } from './StyledBadge';
4
+
5
+ interface BadgeProps {
6
+ /**
7
+ * Content of the `Badge`.
8
+ */
9
+ content: string;
10
+ /**
11
+ * Visual intent color to apply to `Badge`.
12
+ */
13
+ intent?: 'success' | 'warning' | 'danger' | 'info';
14
+ /**
15
+ * Addditional style to be applied for `Badge`.
16
+ */
17
+ style?: StyleProp<ViewStyle>;
18
+ /**
19
+ * Testing id of the component.
20
+ */
21
+ testID?: string;
22
+ }
23
+
24
+ const Badge = ({
25
+ content,
26
+ intent = 'info',
27
+ style,
28
+ testID,
29
+ }: BadgeProps): ReactElement => (
30
+ <StyledView testID={testID} themeIntent={intent} style={style}>
31
+ <StyledText themeIntent={intent}>{content}</StyledText>
32
+ </StyledView>
33
+ );
34
+
35
+ export default Badge;
@@ -0,0 +1,30 @@
1
+ import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
2
+ import styled, { css } from 'styled-components-native';
3
+ import heroIconConfig from './selection.json';
4
+
5
+ type ThemeSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
6
+ type ThemeIntent =
7
+ | 'text'
8
+ | 'primary'
9
+ | 'info'
10
+ | 'danger'
11
+ | 'success'
12
+ | 'warning';
13
+
14
+ const HeroIcon = createIconSetFromIcoMoon(
15
+ heroIconConfig,
16
+ 'hero-icons',
17
+ 'hero-icons.ttf'
18
+ );
19
+
20
+ const StyledHeroIcon = styled(HeroIcon)<{
21
+ themeSize: ThemeSize;
22
+ themeIntent: ThemeIntent;
23
+ }>`
24
+ ${({ themeIntent, themeSize }) => css`
25
+ color: ${({ theme }) => theme.__hd__.icon.colors[themeIntent]};
26
+ font-size: ${({ theme }) => theme.__hd__.icon.sizes[themeSize]}px;
27
+ `};
28
+ `;
29
+
30
+ export default StyledHeroIcon;