@hero-design/rn 7.0.0 → 7.0.3
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.
- package/.eslintrc.json +1 -0
- package/.expo/README.md +15 -0
- package/.expo/packager-info.json +10 -0
- package/.expo/settings.json +10 -0
- package/app.json +4 -0
- package/assets/fonts/hero-icons.ttf +0 -0
- package/es/index.js +10053 -131
- package/jest.config.js +2 -1
- package/lib/index.js +10057 -130
- package/package.json +14 -3
- package/playground/components/Badge.tsx +50 -0
- package/playground/components/Card.tsx +238 -0
- package/playground/components/Icon.tsx +140 -0
- package/playground/components/Typography.tsx +21 -0
- package/playground/index.tsx +42 -9
- package/react-native.config.js +5 -0
- package/src/components/Badge/StyledBadge.tsx +34 -0
- package/src/components/Badge/__tests__/Badge.spec.tsx +50 -0
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +161 -0
- package/src/components/Badge/index.tsx +35 -0
- package/src/components/Card/StyledCard.tsx +9 -0
- package/src/components/Card/__tests__/Card.spec.tsx +36 -0
- package/src/components/Card/__tests__/StyledCard.spec.tsx +15 -0
- package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +39 -0
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +18 -0
- package/src/components/Card/index.tsx +9 -0
- package/src/components/Icon/HeroIcon/index.tsx +30 -0
- package/src/components/Icon/HeroIcon/selection.json +1 -0
- package/src/components/Icon/IconList.ts +298 -0
- package/src/components/Icon/__tests__/Icon.spec.tsx +36 -0
- package/src/components/Icon/__tests__/__snapshots__/Icon.spec.tsx.snap +43 -0
- package/src/components/Icon/index.tsx +47 -0
- package/src/components/Typography/Text/StyledText.tsx +69 -0
- package/src/components/Typography/Text/__test__/StyledText.spec.tsx +62 -0
- package/src/components/Typography/Text/__test__/__snapshots__/StyledText.spec.tsx.snap +172 -0
- package/src/components/Typography/Text/__test__/index.spec.tsx +11 -0
- package/src/components/Typography/Text/index.tsx +41 -0
- package/src/components/Typography/index.tsx +11 -0
- package/src/index.ts +15 -1
- package/src/testHelpers/renderWithTheme.tsx +8 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +79 -0
- package/src/theme/components/badge.ts +38 -0
- package/src/theme/components/card.ts +15 -0
- package/src/theme/components/icon.ts +24 -0
- package/src/theme/components/typography.ts +32 -0
- package/src/theme/global/typography.ts +4 -0
- package/src/theme/index.ts +12 -0
- package/testUtils/setup.ts +3 -0
- package/tsconfig.json +2 -6
- package/types/components/ExampleComponent/StyledView.d.ts +7 -0
- package/types/components/{Divider/__tests__/StyledDivider.spec.d.ts → ExampleComponent/__tests__/StyledView.spec.d.ts} +0 -0
- package/types/components/ExampleComponent/index.d.ts +16 -0
- package/types/index.d.ts +3 -3
- package/types/playground/components/Badge.d.ts +2 -0
- package/types/playground/components/Card.d.ts +2 -0
- package/types/playground/components/Divider.d.ts +2 -0
- package/types/playground/components/Icon.d.ts +2 -0
- package/types/playground/components/Typography.d.ts +2 -0
- package/types/playground/index.d.ts +2 -0
- package/types/src/components/Badge/StyledBadge.d.ts +9 -0
- package/types/{theme/__tests__/index.spec.d.ts → src/components/Badge/__tests__/Badge.spec.d.ts} +0 -0
- package/types/src/components/Badge/index.d.ts +22 -0
- package/types/src/components/Card/StyledCard.d.ts +3 -0
- package/types/src/components/Card/__tests__/Card.spec.d.ts +1 -0
- package/types/src/components/Card/__tests__/StyledCard.spec.d.ts +1 -0
- package/types/src/components/Card/index.d.ts +5 -0
- package/types/{components → src/components}/Divider/StyledDivider.d.ts +0 -0
- package/types/src/components/Divider/__tests__/StyledDivider.spec.d.ts +1 -0
- package/types/{components → src/components}/Divider/index.d.ts +0 -0
- package/types/src/components/Icon/HeroIcon/index.d.ts +7 -0
- package/types/src/components/Icon/IconList.d.ts +2 -0
- package/types/src/components/Icon/__tests__/Icon.spec.d.ts +1 -0
- package/types/src/components/Icon/index.d.ts +27 -0
- package/types/src/components/Typography/Text/StyledText.d.ts +7 -0
- package/types/src/components/Typography/Text/__test__/StyledText.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/__test__/index.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/index.d.ts +22 -0
- package/types/src/components/Typography/index.d.ts +6 -0
- package/types/src/index.d.ts +8 -0
- package/types/src/styled-components.d.ts +6 -0
- package/types/src/testHelpers/renderWithTheme.d.ts +3 -0
- package/types/src/theme/__tests__/index.spec.d.ts +1 -0
- package/types/src/theme/components/badge.d.ts +29 -0
- package/types/src/theme/components/card.d.ts +10 -0
- package/types/{theme → src/theme}/components/divider.d.ts +0 -0
- package/types/src/theme/components/icon.d.ts +19 -0
- package/types/src/theme/components/typography.d.ts +25 -0
- package/types/{theme → src/theme}/global/borders.d.ts +0 -0
- package/types/src/theme/global/colors.d.ts +26 -0
- package/types/src/theme/global/index.d.ts +67 -0
- package/types/src/theme/global/space.d.ts +12 -0
- package/types/src/theme/global/typography.d.ts +25 -0
- package/types/src/theme/index.d.ts +19 -0
- package/types/theme/colors.d.ts +24 -0
- package/types/theme/components/demoStyle.d.ts +11 -0
- package/types/theme/components/exampleComponent.d.ts +14 -0
- package/types/theme/global/colors.d.ts +0 -2
- package/types/theme/global/index.d.ts +0 -5
- package/types/theme/index.d.ts +2 -2
- package/types/theme/space.d.ts +12 -0
- package/types/theme/typography.d.ts +21 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StyledText has body intent style 1`] = `
|
|
4
|
+
<Text
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"color": "#292a2b",
|
|
8
|
+
"fontSize": 14,
|
|
9
|
+
"fontWeight": "400",
|
|
10
|
+
"letterSpacing": 0.42,
|
|
11
|
+
"lineHeight": 22,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
themeFontSize="medium"
|
|
15
|
+
themeFontWeight="regular"
|
|
16
|
+
themeIntent="body"
|
|
17
|
+
>
|
|
18
|
+
This is a test
|
|
19
|
+
</Text>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`StyledText has large fontSize style 1`] = `
|
|
23
|
+
<Text
|
|
24
|
+
style={
|
|
25
|
+
Object {
|
|
26
|
+
"color": "#292a2b",
|
|
27
|
+
"fontSize": 16,
|
|
28
|
+
"fontWeight": "400",
|
|
29
|
+
"letterSpacing": 0.48,
|
|
30
|
+
"lineHeight": 24,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
themeFontSize="large"
|
|
34
|
+
themeFontWeight="regular"
|
|
35
|
+
themeIntent="body"
|
|
36
|
+
>
|
|
37
|
+
This is a test
|
|
38
|
+
</Text>
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
exports[`StyledText has light fontWeight style 1`] = `
|
|
42
|
+
<Text
|
|
43
|
+
style={
|
|
44
|
+
Object {
|
|
45
|
+
"color": "#292a2b",
|
|
46
|
+
"fontSize": 14,
|
|
47
|
+
"fontWeight": "200",
|
|
48
|
+
"letterSpacing": 0.42,
|
|
49
|
+
"lineHeight": 22,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
themeFontSize="medium"
|
|
53
|
+
themeFontWeight="light"
|
|
54
|
+
themeIntent="body"
|
|
55
|
+
>
|
|
56
|
+
This is a test
|
|
57
|
+
</Text>
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
exports[`StyledText has medium fontSize style 1`] = `
|
|
61
|
+
<Text
|
|
62
|
+
style={
|
|
63
|
+
Object {
|
|
64
|
+
"color": "#292a2b",
|
|
65
|
+
"fontSize": 14,
|
|
66
|
+
"fontWeight": "400",
|
|
67
|
+
"letterSpacing": 0.42,
|
|
68
|
+
"lineHeight": 22,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
themeFontSize="medium"
|
|
72
|
+
themeFontWeight="regular"
|
|
73
|
+
themeIntent="body"
|
|
74
|
+
>
|
|
75
|
+
This is a test
|
|
76
|
+
</Text>
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
exports[`StyledText has regular fontWeight style 1`] = `
|
|
80
|
+
<Text
|
|
81
|
+
style={
|
|
82
|
+
Object {
|
|
83
|
+
"color": "#292a2b",
|
|
84
|
+
"fontSize": 14,
|
|
85
|
+
"fontWeight": "400",
|
|
86
|
+
"letterSpacing": 0.42,
|
|
87
|
+
"lineHeight": 22,
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
themeFontSize="medium"
|
|
91
|
+
themeFontWeight="regular"
|
|
92
|
+
themeIntent="body"
|
|
93
|
+
>
|
|
94
|
+
This is a test
|
|
95
|
+
</Text>
|
|
96
|
+
`;
|
|
97
|
+
|
|
98
|
+
exports[`StyledText has semi-bold fontWeight style 1`] = `
|
|
99
|
+
<Text
|
|
100
|
+
style={
|
|
101
|
+
Object {
|
|
102
|
+
"color": "#292a2b",
|
|
103
|
+
"fontSize": 14,
|
|
104
|
+
"fontWeight": "600",
|
|
105
|
+
"letterSpacing": 0.42,
|
|
106
|
+
"lineHeight": 22,
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
themeFontSize="medium"
|
|
110
|
+
themeFontWeight="semi-bold"
|
|
111
|
+
themeIntent="body"
|
|
112
|
+
>
|
|
113
|
+
This is a test
|
|
114
|
+
</Text>
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
exports[`StyledText has small fontSize style 1`] = `
|
|
118
|
+
<Text
|
|
119
|
+
style={
|
|
120
|
+
Object {
|
|
121
|
+
"color": "#292a2b",
|
|
122
|
+
"fontSize": 12,
|
|
123
|
+
"fontWeight": "400",
|
|
124
|
+
"letterSpacing": 0.36,
|
|
125
|
+
"lineHeight": 20,
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
themeFontSize="small"
|
|
129
|
+
themeFontWeight="regular"
|
|
130
|
+
themeIntent="body"
|
|
131
|
+
>
|
|
132
|
+
This is a test
|
|
133
|
+
</Text>
|
|
134
|
+
`;
|
|
135
|
+
|
|
136
|
+
exports[`StyledText has subdued intent style 1`] = `
|
|
137
|
+
<Text
|
|
138
|
+
style={
|
|
139
|
+
Object {
|
|
140
|
+
"color": "#8b8d92",
|
|
141
|
+
"fontSize": 14,
|
|
142
|
+
"fontWeight": "400",
|
|
143
|
+
"letterSpacing": 0.42,
|
|
144
|
+
"lineHeight": 22,
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
themeFontSize="medium"
|
|
148
|
+
themeFontWeight="regular"
|
|
149
|
+
themeIntent="subdued"
|
|
150
|
+
>
|
|
151
|
+
This is a test
|
|
152
|
+
</Text>
|
|
153
|
+
`;
|
|
154
|
+
|
|
155
|
+
exports[`StyledText has xlarge fontSize style 1`] = `
|
|
156
|
+
<Text
|
|
157
|
+
style={
|
|
158
|
+
Object {
|
|
159
|
+
"color": "#292a2b",
|
|
160
|
+
"fontSize": 18,
|
|
161
|
+
"fontWeight": "400",
|
|
162
|
+
"letterSpacing": 0.54,
|
|
163
|
+
"lineHeight": 26,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
themeFontSize="xlarge"
|
|
167
|
+
themeFontWeight="regular"
|
|
168
|
+
themeIntent="body"
|
|
169
|
+
>
|
|
170
|
+
This is a test
|
|
171
|
+
</Text>
|
|
172
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../../testHelpers/renderWithTheme';
|
|
3
|
+
import Text from '..';
|
|
4
|
+
|
|
5
|
+
describe('Text', () => {
|
|
6
|
+
it('renders correctly', () => {
|
|
7
|
+
const { queryAllByText } = renderWithTheme(<Text>This is a test</Text>);
|
|
8
|
+
|
|
9
|
+
expect(queryAllByText('This is a test')).toHaveLength(1);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { TextProps as NativeTextProps } from 'react-native';
|
|
3
|
+
import { StyledText } from './StyledText';
|
|
4
|
+
|
|
5
|
+
interface TextProps extends NativeTextProps {
|
|
6
|
+
/**
|
|
7
|
+
* Text content.
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Size of the text.
|
|
12
|
+
*/
|
|
13
|
+
fontSize?: 'small' | 'medium' | 'large' | 'xlarge';
|
|
14
|
+
/**
|
|
15
|
+
* Font weight of the text.
|
|
16
|
+
*/
|
|
17
|
+
fontWeight?: 'light' | 'regular' | 'semi-bold';
|
|
18
|
+
/**
|
|
19
|
+
* Visual intent color to apply to the text.
|
|
20
|
+
*/
|
|
21
|
+
intent?: 'body' | 'subdued';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Text = ({
|
|
25
|
+
children,
|
|
26
|
+
fontSize = 'medium',
|
|
27
|
+
fontWeight = 'regular',
|
|
28
|
+
intent = 'body',
|
|
29
|
+
...nativeProps
|
|
30
|
+
}: TextProps) => (
|
|
31
|
+
<StyledText
|
|
32
|
+
themeFontSize={fontSize}
|
|
33
|
+
themeFontWeight={fontWeight}
|
|
34
|
+
themeIntent={intent}
|
|
35
|
+
{...nativeProps}
|
|
36
|
+
>
|
|
37
|
+
{children}
|
|
38
|
+
</StyledText>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export default Text;
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { ThemeProvider, useTheme } from 'styled-components-native';
|
|
2
2
|
import theme, { getTheme } from './theme';
|
|
3
3
|
|
|
4
|
+
import Badge from './components/Badge';
|
|
5
|
+
import Card from './components/Card';
|
|
4
6
|
import Divider from './components/Divider';
|
|
7
|
+
import Icon from './components/Icon';
|
|
8
|
+
import Typography from './components/Typography';
|
|
5
9
|
|
|
6
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
theme,
|
|
12
|
+
getTheme,
|
|
13
|
+
useTheme,
|
|
14
|
+
ThemeProvider,
|
|
15
|
+
Badge,
|
|
16
|
+
Card,
|
|
17
|
+
Divider,
|
|
18
|
+
Icon,
|
|
19
|
+
Typography,
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, RenderOptions } from '@testing-library/react-native'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
|
+
import { ThemeProvider, theme } from '../index';
|
|
4
|
+
|
|
5
|
+
const renderWithTheme = (ui: JSX.Element, options?: RenderOptions) =>
|
|
6
|
+
render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>, options);
|
|
7
|
+
|
|
8
|
+
export default renderWithTheme;
|
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
exports[`theme returns correct theme object 1`] = `
|
|
4
4
|
Object {
|
|
5
5
|
"__hd__": Object {
|
|
6
|
+
"badge": Object {
|
|
7
|
+
"borderWidths": Object {
|
|
8
|
+
"default": "1px",
|
|
9
|
+
},
|
|
10
|
+
"colors": Object {
|
|
11
|
+
"danger": "#de350b",
|
|
12
|
+
"dangerBackground": "#fcebe7",
|
|
13
|
+
"info": "#4568fb",
|
|
14
|
+
"infoBackground": "#ecf0ff",
|
|
15
|
+
"success": "#017d6d",
|
|
16
|
+
"successBackground": "#f0fef4",
|
|
17
|
+
"warning": "#d98a2c",
|
|
18
|
+
"warningBackground": "#fff6eb",
|
|
19
|
+
},
|
|
20
|
+
"fontSizes": Object {
|
|
21
|
+
"default": "12px",
|
|
22
|
+
},
|
|
23
|
+
"fontWeights": Object {
|
|
24
|
+
"default": 600,
|
|
25
|
+
},
|
|
26
|
+
"padding": Object {
|
|
27
|
+
"default": "4px 8px",
|
|
28
|
+
},
|
|
29
|
+
"radii": Object {
|
|
30
|
+
"default": "4px",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"card": Object {
|
|
34
|
+
"padding": Object {
|
|
35
|
+
"default": "16px",
|
|
36
|
+
},
|
|
37
|
+
"radii": Object {
|
|
38
|
+
"default": "12px",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
6
41
|
"divider": Object {
|
|
7
42
|
"borderWiths": Object {
|
|
8
43
|
"default": "1px",
|
|
@@ -18,6 +53,46 @@ Object {
|
|
|
18
53
|
"xsmall": "4px",
|
|
19
54
|
},
|
|
20
55
|
},
|
|
56
|
+
"icon": Object {
|
|
57
|
+
"colors": Object {
|
|
58
|
+
"danger": "#de350b",
|
|
59
|
+
"info": "#4568fb",
|
|
60
|
+
"primary": "#7622d7",
|
|
61
|
+
"success": "#01b39c",
|
|
62
|
+
"text": "#292a2b",
|
|
63
|
+
"warning": "#ffa234",
|
|
64
|
+
},
|
|
65
|
+
"sizes": Object {
|
|
66
|
+
"large": 28,
|
|
67
|
+
"medium": 24,
|
|
68
|
+
"small": 20,
|
|
69
|
+
"xlarge": 32,
|
|
70
|
+
"xsmall": 16,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
"typography": Object {
|
|
74
|
+
"colors": Object {
|
|
75
|
+
"body": "#292a2b",
|
|
76
|
+
"subdued": "#8b8d92",
|
|
77
|
+
},
|
|
78
|
+
"fontSizes": Object {
|
|
79
|
+
"large": 16,
|
|
80
|
+
"medium": 14,
|
|
81
|
+
"small": 12,
|
|
82
|
+
"xlarge": 18,
|
|
83
|
+
},
|
|
84
|
+
"fontWeights": Object {
|
|
85
|
+
"light": 200,
|
|
86
|
+
"regular": 400,
|
|
87
|
+
"semiBold": 600,
|
|
88
|
+
},
|
|
89
|
+
"lineHeights": Object {
|
|
90
|
+
"large": "24px",
|
|
91
|
+
"medium": "22px",
|
|
92
|
+
"small": "20px",
|
|
93
|
+
"xlarge": "26px",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
21
96
|
},
|
|
22
97
|
"borderWidths": Object {
|
|
23
98
|
"base": 1,
|
|
@@ -52,6 +127,10 @@ Object {
|
|
|
52
127
|
"small": 12,
|
|
53
128
|
"xlarge": 18,
|
|
54
129
|
"xsmall": 10,
|
|
130
|
+
"xxlarge": 20,
|
|
131
|
+
"xxxlarge": 24,
|
|
132
|
+
"xxxxlarge": 28,
|
|
133
|
+
"xxxxxlarge": 32,
|
|
55
134
|
},
|
|
56
135
|
"fontWeights": Object {
|
|
57
136
|
"bold": 700,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getBadgeTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const borderWidths = {
|
|
5
|
+
default: `${theme.borderWidths.base}px`,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const colors = {
|
|
9
|
+
danger: theme.colors.danger,
|
|
10
|
+
dangerBackground: theme.colors.dangerBackground,
|
|
11
|
+
info: theme.colors.info,
|
|
12
|
+
infoBackground: theme.colors.infoBackground,
|
|
13
|
+
success: theme.colors.successDark,
|
|
14
|
+
successBackground: theme.colors.successBackground,
|
|
15
|
+
warning: theme.colors.warningDark,
|
|
16
|
+
warningBackground: theme.colors.warningBackground,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const padding = {
|
|
20
|
+
default: `${theme.space.xsmall}px ${theme.space.small}px`,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const fontSizes = {
|
|
24
|
+
default: `${theme.fontSizes.small}px`,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const fontWeights = {
|
|
28
|
+
default: theme.fontWeights.semiBold,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const radii = {
|
|
32
|
+
default: `4px`,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return { borderWidths, colors, padding, fontSizes, fontWeights, radii };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default getBadgeTheme;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getCardTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const radii = {
|
|
5
|
+
default: `12px`,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const padding = {
|
|
9
|
+
default: `${theme.space.medium}px`,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return { radii, padding };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default getCardTheme;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getIconTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const colors = {
|
|
5
|
+
text: theme.colors.text,
|
|
6
|
+
primary: theme.colors.primary,
|
|
7
|
+
info: theme.colors.info,
|
|
8
|
+
danger: theme.colors.danger,
|
|
9
|
+
success: theme.colors.success,
|
|
10
|
+
warning: theme.colors.warning,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const sizes = {
|
|
14
|
+
xsmall: theme.fontSizes.large,
|
|
15
|
+
small: theme.fontSizes.xxlarge,
|
|
16
|
+
medium: theme.fontSizes.xxxlarge,
|
|
17
|
+
large: theme.fontSizes.xxxxlarge,
|
|
18
|
+
xlarge: theme.fontSizes.xxxxxlarge,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return { colors, sizes };
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default getIconTheme;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getTypographyTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const colors = {
|
|
5
|
+
body: theme.colors.text,
|
|
6
|
+
subdued: theme.colors.disabledText,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const fontSizes = {
|
|
10
|
+
small: theme.fontSizes.small,
|
|
11
|
+
medium: theme.fontSizes.medium,
|
|
12
|
+
large: theme.fontSizes.large,
|
|
13
|
+
xlarge: theme.fontSizes.xlarge,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const fontWeights = {
|
|
17
|
+
light: theme.fontWeights.light,
|
|
18
|
+
regular: theme.fontWeights.regular,
|
|
19
|
+
semiBold: theme.fontWeights.semiBold,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const lineHeights = {
|
|
23
|
+
small: `${theme.lineHeights.small}px`,
|
|
24
|
+
medium: `${theme.lineHeights.medium}px`,
|
|
25
|
+
large: `${theme.lineHeights.large}px`,
|
|
26
|
+
xlarge: `${theme.lineHeights.xlarge}px`,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return { colors, fontSizes, fontWeights, lineHeights };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default getTypographyTheme;
|
package/src/theme/index.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import globalTheme, { GlobalTheme } from './global';
|
|
2
2
|
|
|
3
|
+
import getBadgeTheme from './components/badge';
|
|
4
|
+
import getCardTheme from './components/card';
|
|
3
5
|
import getDividerTheme from './components/divider';
|
|
6
|
+
import getIconTheme from './components/icon';
|
|
7
|
+
import getTypographyTheme from './components/typography';
|
|
4
8
|
|
|
5
9
|
type Theme = GlobalTheme & {
|
|
6
10
|
__hd__: {
|
|
11
|
+
badge: ReturnType<typeof getBadgeTheme>;
|
|
12
|
+
card: ReturnType<typeof getCardTheme>;
|
|
7
13
|
divider: ReturnType<typeof getDividerTheme>;
|
|
14
|
+
icon: ReturnType<typeof getIconTheme>;
|
|
15
|
+
typography: ReturnType<typeof getTypographyTheme>;
|
|
8
16
|
};
|
|
9
17
|
};
|
|
10
18
|
|
|
11
19
|
const getTheme = (theme: GlobalTheme = globalTheme): Theme => ({
|
|
12
20
|
...theme,
|
|
13
21
|
__hd__: {
|
|
22
|
+
badge: getBadgeTheme(theme),
|
|
23
|
+
card: getCardTheme(theme),
|
|
14
24
|
divider: getDividerTheme(theme),
|
|
25
|
+
icon: getIconTheme(theme),
|
|
26
|
+
typography: getTypographyTheme(theme),
|
|
15
27
|
},
|
|
16
28
|
});
|
|
17
29
|
|
package/tsconfig.json
CHANGED
|
@@ -18,11 +18,7 @@
|
|
|
18
18
|
"styled-components-native": ["./src/styled-components.ts"]
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"include": [
|
|
22
|
-
|
|
23
|
-
],
|
|
24
|
-
"exclude": [
|
|
25
|
-
"node_modules"
|
|
26
|
-
],
|
|
21
|
+
"include": ["src", "playground"],
|
|
22
|
+
"exclude": ["node_modules"],
|
|
27
23
|
"extends": "expo/tsconfig.base"
|
|
28
24
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
declare const Square: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
|
|
3
|
+
themeSize: 'small' | 'medium' | 'large';
|
|
4
|
+
themeMargin: 'small' | 'medium' | 'large';
|
|
5
|
+
themeBgColor: 'primary' | 'danger' | 'warning';
|
|
6
|
+
}, never>;
|
|
7
|
+
export { Square };
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/**
|
|
3
|
+
* Size.
|
|
4
|
+
*/
|
|
5
|
+
size?: 'small' | 'medium' | 'large';
|
|
6
|
+
/**
|
|
7
|
+
* Margin.
|
|
8
|
+
*/
|
|
9
|
+
margin: 'small' | 'medium' | 'large';
|
|
10
|
+
/**
|
|
11
|
+
* Background color.
|
|
12
|
+
*/
|
|
13
|
+
bgColor: 'primary' | 'danger' | 'warning';
|
|
14
|
+
}
|
|
15
|
+
declare const ExampleComponent: ({ size, margin, bgColor }: Props) => JSX.Element;
|
|
16
|
+
export default ExampleComponent;
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeProvider, useTheme } from 'styled-components
|
|
1
|
+
import { ThemeProvider, useTheme } from './styled-components';
|
|
2
2
|
import theme, { getTheme } from './theme';
|
|
3
|
-
import
|
|
4
|
-
export { theme, getTheme, useTheme, ThemeProvider,
|
|
3
|
+
import ExampleComponent from './components/ExampleComponent';
|
|
4
|
+
export { theme, getTheme, useTheme, ThemeProvider, ExampleComponent };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Text, View } from 'react-native';
|
|
2
|
+
declare type ThemeIntent = 'success' | 'warning' | 'danger' | 'info';
|
|
3
|
+
declare const StyledView: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
|
|
4
|
+
themeIntent: ThemeIntent;
|
|
5
|
+
}, never>;
|
|
6
|
+
declare const StyledText: import("styled-components").StyledComponent<typeof Text, import("../../theme").Theme, {
|
|
7
|
+
themeIntent: ThemeIntent;
|
|
8
|
+
}, never>;
|
|
9
|
+
export { StyledView, StyledText };
|
package/types/{theme/__tests__/index.spec.d.ts → src/components/Badge/__tests__/Badge.spec.d.ts}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
interface BadgeProps {
|
|
4
|
+
/**
|
|
5
|
+
* Content of the `Badge`.
|
|
6
|
+
*/
|
|
7
|
+
content: string;
|
|
8
|
+
/**
|
|
9
|
+
* Visual intent color to apply to `Badge`.
|
|
10
|
+
*/
|
|
11
|
+
intent?: 'success' | 'warning' | 'danger' | 'info';
|
|
12
|
+
/**
|
|
13
|
+
* Addditional style to be applied for `Badge`.
|
|
14
|
+
*/
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
/**
|
|
17
|
+
* Testing id of the component.
|
|
18
|
+
*/
|
|
19
|
+
testID?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const Badge: ({ content, intent, style, testID, }: BadgeProps) => ReactElement;
|
|
22
|
+
export default Badge;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|