@hero-design/rn 6.7.4-1 → 7.0.1
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 +11 -2
- package/app.json +4 -0
- package/babel.config.js +15 -1
- package/es/index.js +96 -50
- package/jest.config.js +4 -0
- package/lib/index.js +96 -49
- package/package.json +16 -6
- package/playground/components/Card.tsx +52 -0
- package/playground/components/Divider.tsx +13 -0
- package/playground/index.tsx +4 -2
- package/src/components/Card/StyledCard.tsx +9 -0
- package/src/components/Card/__tests__/Card.spec.tsx +36 -0
- package/src/components/{ExampleComponent/__tests__/StyledView.spec.tsx → Card/__tests__/StyledCard.spec.tsx} +4 -9
- 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/Divider/StyledDivider.tsx +70 -0
- package/src/components/Divider/__tests__/StyledDivider.spec.tsx +42 -0
- package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +165 -0
- package/src/components/Divider/index.tsx +22 -0
- package/src/index.ts +4 -4
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +89 -0
- package/src/theme/__tests__/index.spec.ts +7 -0
- package/src/theme/components/card.ts +15 -0
- package/src/theme/components/divider.ts +23 -0
- package/src/theme/global/borders.ts +3 -0
- package/src/theme/global/colors.ts +3 -1
- package/src/theme/global/index.ts +2 -0
- package/src/theme/index.ts +6 -3
- package/tsconfig.json +4 -0
- package/types/components/Card/StyledCard.d.ts +3 -0
- package/types/components/Card/__tests__/Card.spec.d.ts +1 -0
- package/types/components/Card/__tests__/StyledCard.spec.d.ts +1 -0
- package/types/components/Card/index.d.ts +5 -0
- package/types/components/Divider/StyledDivider.d.ts +7 -0
- package/types/components/Divider/__tests__/StyledDivider.spec.d.ts +1 -0
- package/types/components/Divider/index.d.ts +12 -0
- package/types/index.d.ts +4 -3
- package/types/theme/__tests__/index.spec.d.ts +1 -0
- package/types/theme/components/card.d.ts +10 -0
- package/types/theme/components/divider.d.ts +17 -0
- package/types/theme/global/borders.d.ts +4 -0
- package/types/theme/global/colors.d.ts +2 -0
- package/types/theme/global/index.d.ts +5 -0
- package/types/theme/index.d.ts +4 -2
- package/playground/components/ExampleComponent.tsx +0 -8
- package/src/components/ExampleComponent/StyledView.tsx +0 -68
- package/src/components/ExampleComponent/__tests__/__snapshots__/StyledView.spec.tsx.snap +0 -23
- package/src/components/ExampleComponent/index.tsx +0 -26
- package/src/theme/components/exampleComponent.ts +0 -19
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import styled from 'styled-components-native';
|
|
3
|
+
|
|
4
|
+
const StyledCard = styled(View)<{}>`
|
|
5
|
+
border-radius: ${({ theme }) => theme.__hd__.card.radii.default};
|
|
6
|
+
padding: ${({ theme }) => theme.__hd__.card.padding.default};
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
export { StyledCard };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, RenderAPI } from '@testing-library/react-native';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import Card from '..';
|
|
5
|
+
import { theme, ThemeProvider } from '../../../index';
|
|
6
|
+
|
|
7
|
+
describe('Card', () => {
|
|
8
|
+
let wrapper: RenderAPI;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
wrapper = render(
|
|
12
|
+
<ThemeProvider theme={theme}>
|
|
13
|
+
<Card
|
|
14
|
+
style={{ backgroundColor: theme.colors.backgroundDark }}
|
|
15
|
+
testID="card"
|
|
16
|
+
nativeID="card-native-id"
|
|
17
|
+
hitSlop={{ top: 1, left: 1, bottom: 1, right: 1 }}
|
|
18
|
+
pointerEvents="box-only"
|
|
19
|
+
removeClippedSubviews
|
|
20
|
+
>
|
|
21
|
+
<View testID="child-view" />
|
|
22
|
+
</Card>
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders correct', () => {
|
|
28
|
+
expect(wrapper.queryAllByTestId('card')).toHaveLength(1);
|
|
29
|
+
|
|
30
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('has child', () => {
|
|
34
|
+
expect(wrapper.queryAllByTestId('child-view')).toHaveLength(1);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react-native';
|
|
3
3
|
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
-
import {
|
|
4
|
+
import { StyledCard } from '../StyledCard';
|
|
5
5
|
|
|
6
|
-
describe('
|
|
7
|
-
it('renders correct
|
|
6
|
+
describe('StyledCard', () => {
|
|
7
|
+
it('renders correct style', () => {
|
|
8
8
|
const { toJSON } = render(
|
|
9
9
|
<ThemeProvider theme={theme}>
|
|
10
|
-
<
|
|
11
|
-
themeSize="medium"
|
|
12
|
-
themeMargin="medium"
|
|
13
|
-
themeBgColor="primary"
|
|
14
|
-
/>
|
|
10
|
+
<StyledCard />
|
|
15
11
|
</ThemeProvider>
|
|
16
12
|
);
|
|
17
|
-
|
|
18
13
|
expect(toJSON()).toMatchSnapshot();
|
|
19
14
|
});
|
|
20
15
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Card renders correct 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
hitSlop={
|
|
6
|
+
Object {
|
|
7
|
+
"bottom": 1,
|
|
8
|
+
"left": 1,
|
|
9
|
+
"right": 1,
|
|
10
|
+
"top": 1,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
nativeID="card-native-id"
|
|
14
|
+
pointerEvents="box-only"
|
|
15
|
+
removeClippedSubviews={true}
|
|
16
|
+
style={
|
|
17
|
+
Array [
|
|
18
|
+
Object {
|
|
19
|
+
"borderBottomLeftRadius": 12,
|
|
20
|
+
"borderBottomRightRadius": 12,
|
|
21
|
+
"borderTopLeftRadius": 12,
|
|
22
|
+
"borderTopRightRadius": 12,
|
|
23
|
+
"paddingBottom": 16,
|
|
24
|
+
"paddingLeft": 16,
|
|
25
|
+
"paddingRight": 16,
|
|
26
|
+
"paddingTop": 16,
|
|
27
|
+
},
|
|
28
|
+
Object {
|
|
29
|
+
"backgroundColor": "#292a2b",
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
testID="card"
|
|
34
|
+
>
|
|
35
|
+
<View
|
|
36
|
+
testID="child-view"
|
|
37
|
+
/>
|
|
38
|
+
</View>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StyledCard renders correct style 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"borderBottomLeftRadius": 12,
|
|
8
|
+
"borderBottomRightRadius": 12,
|
|
9
|
+
"borderTopLeftRadius": 12,
|
|
10
|
+
"borderTopRightRadius": 12,
|
|
11
|
+
"paddingBottom": 16,
|
|
12
|
+
"paddingLeft": 16,
|
|
13
|
+
"paddingRight": 16,
|
|
14
|
+
"paddingTop": 16,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/>
|
|
18
|
+
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
import { StyledCard } from './StyledCard';
|
|
4
|
+
|
|
5
|
+
interface CardProps extends ViewProps {}
|
|
6
|
+
|
|
7
|
+
const Card = (props: CardProps): JSX.Element => <StyledCard {...props} />;
|
|
8
|
+
|
|
9
|
+
export default Card;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import styled, { css } from 'styled-components-native';
|
|
3
|
+
|
|
4
|
+
type MarginSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
5
|
+
|
|
6
|
+
const StyledDivider = styled(View)<{
|
|
7
|
+
themeMarginHorizontal?: MarginSize;
|
|
8
|
+
themeMarginVertical?: MarginSize;
|
|
9
|
+
}>`
|
|
10
|
+
border-bottom-width: ${({ theme }) =>
|
|
11
|
+
theme.__hd__.divider.borderWiths.default};
|
|
12
|
+
border-bottom-color: ${({ theme }) => theme.__hd__.divider.colors.default};
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
|
|
15
|
+
${({ themeMarginHorizontal, theme }) => {
|
|
16
|
+
switch (themeMarginHorizontal) {
|
|
17
|
+
case undefined:
|
|
18
|
+
return css``;
|
|
19
|
+
case 'xsmall':
|
|
20
|
+
return css`
|
|
21
|
+
margin-horizontal: ${theme.__hd__.divider.space.xsmall};
|
|
22
|
+
`;
|
|
23
|
+
case 'small':
|
|
24
|
+
return css`
|
|
25
|
+
margin-horizontal: ${theme.__hd__.divider.space.small};
|
|
26
|
+
`;
|
|
27
|
+
case 'medium':
|
|
28
|
+
return css`
|
|
29
|
+
margin-horizontal: ${theme.__hd__.divider.space.medium};
|
|
30
|
+
`;
|
|
31
|
+
case 'large':
|
|
32
|
+
return css`
|
|
33
|
+
margin-horizontal: ${theme.__hd__.divider.space.large};
|
|
34
|
+
`;
|
|
35
|
+
case 'xlarge':
|
|
36
|
+
return css`
|
|
37
|
+
margin-horizontal: ${theme.__hd__.divider.space.xlarge};
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
}}
|
|
41
|
+
|
|
42
|
+
${({ themeMarginVertical, theme }) => {
|
|
43
|
+
switch (themeMarginVertical) {
|
|
44
|
+
case undefined:
|
|
45
|
+
return css``;
|
|
46
|
+
case 'xsmall':
|
|
47
|
+
return css`
|
|
48
|
+
margin-vertical: ${theme.__hd__.divider.space.xsmall};
|
|
49
|
+
`;
|
|
50
|
+
case 'small':
|
|
51
|
+
return css`
|
|
52
|
+
margin-vertical: ${theme.__hd__.divider.space.small};
|
|
53
|
+
`;
|
|
54
|
+
case 'medium':
|
|
55
|
+
return css`
|
|
56
|
+
margin-vertical: ${theme.__hd__.divider.space.medium};
|
|
57
|
+
`;
|
|
58
|
+
case 'large':
|
|
59
|
+
return css`
|
|
60
|
+
margin-vertical: ${theme.__hd__.divider.space.large};
|
|
61
|
+
`;
|
|
62
|
+
case 'xlarge':
|
|
63
|
+
return css`
|
|
64
|
+
margin-vertical: ${theme.__hd__.divider.space.xlarge};
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
}}
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
export { StyledDivider };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import Divider from '..';
|
|
5
|
+
|
|
6
|
+
describe('Divider', () => {
|
|
7
|
+
it.each`
|
|
8
|
+
marginHorizontal
|
|
9
|
+
${undefined}
|
|
10
|
+
${'xsmall'}
|
|
11
|
+
${'small'}
|
|
12
|
+
${'medium'}
|
|
13
|
+
${'large'}
|
|
14
|
+
${'xlarge'}
|
|
15
|
+
`('has $marginHorizontal marginHorizontal style', ({ marginHorizontal }) => {
|
|
16
|
+
const { toJSON } = render(
|
|
17
|
+
<ThemeProvider theme={theme}>
|
|
18
|
+
<Divider marginHorizontal={marginHorizontal} />
|
|
19
|
+
</ThemeProvider>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
expect(toJSON()).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it.each`
|
|
26
|
+
marginVertical
|
|
27
|
+
${undefined}
|
|
28
|
+
${'xsmall'}
|
|
29
|
+
${'small'}
|
|
30
|
+
${'medium'}
|
|
31
|
+
${'large'}
|
|
32
|
+
${'xlarge'}
|
|
33
|
+
`('has $marginVertical marginVertical style', ({ marginVertical }) => {
|
|
34
|
+
const { toJSON } = render(
|
|
35
|
+
<ThemeProvider theme={theme}>
|
|
36
|
+
<Divider marginVertical={marginVertical} />
|
|
37
|
+
</ThemeProvider>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(toJSON()).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Divider has large marginHorizontal style 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"borderBottomColor": "#dadbde",
|
|
8
|
+
"borderBottomWidth": 1,
|
|
9
|
+
"marginHorizontal": 24,
|
|
10
|
+
"maxWidth": "100%",
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
themeMarginHorizontal="large"
|
|
14
|
+
/>
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
exports[`Divider has large marginVertical style 1`] = `
|
|
18
|
+
<View
|
|
19
|
+
style={
|
|
20
|
+
Object {
|
|
21
|
+
"borderBottomColor": "#dadbde",
|
|
22
|
+
"borderBottomWidth": 1,
|
|
23
|
+
"marginVertical": 24,
|
|
24
|
+
"maxWidth": "100%",
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
themeMarginVertical="large"
|
|
28
|
+
/>
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
exports[`Divider has medium marginHorizontal style 1`] = `
|
|
32
|
+
<View
|
|
33
|
+
style={
|
|
34
|
+
Object {
|
|
35
|
+
"borderBottomColor": "#dadbde",
|
|
36
|
+
"borderBottomWidth": 1,
|
|
37
|
+
"marginHorizontal": 16,
|
|
38
|
+
"maxWidth": "100%",
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
themeMarginHorizontal="medium"
|
|
42
|
+
/>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Divider has medium marginVertical style 1`] = `
|
|
46
|
+
<View
|
|
47
|
+
style={
|
|
48
|
+
Object {
|
|
49
|
+
"borderBottomColor": "#dadbde",
|
|
50
|
+
"borderBottomWidth": 1,
|
|
51
|
+
"marginVertical": 16,
|
|
52
|
+
"maxWidth": "100%",
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
themeMarginVertical="medium"
|
|
56
|
+
/>
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
exports[`Divider has small marginHorizontal style 1`] = `
|
|
60
|
+
<View
|
|
61
|
+
style={
|
|
62
|
+
Object {
|
|
63
|
+
"borderBottomColor": "#dadbde",
|
|
64
|
+
"borderBottomWidth": 1,
|
|
65
|
+
"marginHorizontal": 8,
|
|
66
|
+
"maxWidth": "100%",
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
themeMarginHorizontal="small"
|
|
70
|
+
/>
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
exports[`Divider has small marginVertical style 1`] = `
|
|
74
|
+
<View
|
|
75
|
+
style={
|
|
76
|
+
Object {
|
|
77
|
+
"borderBottomColor": "#dadbde",
|
|
78
|
+
"borderBottomWidth": 1,
|
|
79
|
+
"marginVertical": 8,
|
|
80
|
+
"maxWidth": "100%",
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
themeMarginVertical="small"
|
|
84
|
+
/>
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
exports[`Divider has undefined marginHorizontal style 1`] = `
|
|
88
|
+
<View
|
|
89
|
+
style={
|
|
90
|
+
Object {
|
|
91
|
+
"borderBottomColor": "#dadbde",
|
|
92
|
+
"borderBottomWidth": 1,
|
|
93
|
+
"maxWidth": "100%",
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
exports[`Divider has undefined marginVertical style 1`] = `
|
|
100
|
+
<View
|
|
101
|
+
style={
|
|
102
|
+
Object {
|
|
103
|
+
"borderBottomColor": "#dadbde",
|
|
104
|
+
"borderBottomWidth": 1,
|
|
105
|
+
"maxWidth": "100%",
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/>
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
exports[`Divider has xlarge marginHorizontal style 1`] = `
|
|
112
|
+
<View
|
|
113
|
+
style={
|
|
114
|
+
Object {
|
|
115
|
+
"borderBottomColor": "#dadbde",
|
|
116
|
+
"borderBottomWidth": 1,
|
|
117
|
+
"marginHorizontal": 32,
|
|
118
|
+
"maxWidth": "100%",
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
themeMarginHorizontal="xlarge"
|
|
122
|
+
/>
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
exports[`Divider has xlarge marginVertical style 1`] = `
|
|
126
|
+
<View
|
|
127
|
+
style={
|
|
128
|
+
Object {
|
|
129
|
+
"borderBottomColor": "#dadbde",
|
|
130
|
+
"borderBottomWidth": 1,
|
|
131
|
+
"marginVertical": 32,
|
|
132
|
+
"maxWidth": "100%",
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
themeMarginVertical="xlarge"
|
|
136
|
+
/>
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
exports[`Divider has xsmall marginHorizontal style 1`] = `
|
|
140
|
+
<View
|
|
141
|
+
style={
|
|
142
|
+
Object {
|
|
143
|
+
"borderBottomColor": "#dadbde",
|
|
144
|
+
"borderBottomWidth": 1,
|
|
145
|
+
"marginHorizontal": 4,
|
|
146
|
+
"maxWidth": "100%",
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
themeMarginHorizontal="xsmall"
|
|
150
|
+
/>
|
|
151
|
+
`;
|
|
152
|
+
|
|
153
|
+
exports[`Divider has xsmall marginVertical style 1`] = `
|
|
154
|
+
<View
|
|
155
|
+
style={
|
|
156
|
+
Object {
|
|
157
|
+
"borderBottomColor": "#dadbde",
|
|
158
|
+
"borderBottomWidth": 1,
|
|
159
|
+
"marginVertical": 4,
|
|
160
|
+
"maxWidth": "100%",
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
themeMarginVertical="xsmall"
|
|
164
|
+
/>
|
|
165
|
+
`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyledDivider } from './StyledDivider';
|
|
3
|
+
|
|
4
|
+
interface DividerProps {
|
|
5
|
+
/**
|
|
6
|
+
* Horizontal margin size. There is no margin by default.
|
|
7
|
+
*/
|
|
8
|
+
marginHorizontal?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
9
|
+
/**
|
|
10
|
+
* Vertical margin size. There is no margin by default.
|
|
11
|
+
*/
|
|
12
|
+
marginVertical?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Divider = ({ marginHorizontal, marginVertical }: DividerProps) => (
|
|
16
|
+
<StyledDivider
|
|
17
|
+
themeMarginHorizontal={marginHorizontal}
|
|
18
|
+
themeMarginVertical={marginVertical}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default Divider;
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ThemeProvider, useTheme } from '
|
|
1
|
+
import { ThemeProvider, useTheme } from 'styled-components-native';
|
|
2
2
|
import theme, { getTheme } from './theme';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import
|
|
4
|
+
import Divider from './components/Divider';
|
|
5
|
+
import Card from './components/Card';
|
|
6
6
|
|
|
7
|
-
export { theme, getTheme, useTheme, ThemeProvider,
|
|
7
|
+
export { theme, getTheme, useTheme, ThemeProvider, Divider, Card };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`theme returns correct theme object 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"__hd__": Object {
|
|
6
|
+
"card": Object {
|
|
7
|
+
"padding": Object {
|
|
8
|
+
"default": "16px",
|
|
9
|
+
},
|
|
10
|
+
"radii": Object {
|
|
11
|
+
"default": "12px",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
"divider": Object {
|
|
15
|
+
"borderWiths": Object {
|
|
16
|
+
"default": "1px",
|
|
17
|
+
},
|
|
18
|
+
"colors": Object {
|
|
19
|
+
"default": "#dadbde",
|
|
20
|
+
},
|
|
21
|
+
"space": Object {
|
|
22
|
+
"large": "24px",
|
|
23
|
+
"medium": "16px",
|
|
24
|
+
"small": "8px",
|
|
25
|
+
"xlarge": "32px",
|
|
26
|
+
"xsmall": "4px",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
"borderWidths": Object {
|
|
31
|
+
"base": 1,
|
|
32
|
+
},
|
|
33
|
+
"colors": Object {
|
|
34
|
+
"backgroundDark": "#292a2b",
|
|
35
|
+
"backgroundLight": "#fafbfb",
|
|
36
|
+
"danger": "#de350b",
|
|
37
|
+
"dangerBackground": "#fcebe7",
|
|
38
|
+
"dangerLight": "#f2ae9d",
|
|
39
|
+
"disabledText": "#8b8d92",
|
|
40
|
+
"info": "#4568fb",
|
|
41
|
+
"infoBackground": "#ecf0ff",
|
|
42
|
+
"infoLight": "#d1d9fe",
|
|
43
|
+
"invertedText": "#ffffff",
|
|
44
|
+
"outline": "#dadbde",
|
|
45
|
+
"platformBackground": "#ffffff",
|
|
46
|
+
"primary": "#7622d7",
|
|
47
|
+
"primaryLight": "#c8a7ef",
|
|
48
|
+
"success": "#01b39c",
|
|
49
|
+
"successBackground": "#f0fef4",
|
|
50
|
+
"successDark": "#017d6d",
|
|
51
|
+
"successLight": "#002d27",
|
|
52
|
+
"text": "#292a2b",
|
|
53
|
+
"warning": "#ffa234",
|
|
54
|
+
"warningBackground": "#fff6eb",
|
|
55
|
+
"warningDark": "#d98a2c",
|
|
56
|
+
},
|
|
57
|
+
"fontSizes": Object {
|
|
58
|
+
"large": 16,
|
|
59
|
+
"medium": 14,
|
|
60
|
+
"small": 12,
|
|
61
|
+
"xlarge": 18,
|
|
62
|
+
"xsmall": 10,
|
|
63
|
+
},
|
|
64
|
+
"fontWeights": Object {
|
|
65
|
+
"bold": 700,
|
|
66
|
+
"light": 200,
|
|
67
|
+
"regular": 400,
|
|
68
|
+
"semiBold": 600,
|
|
69
|
+
},
|
|
70
|
+
"lineHeights": Object {
|
|
71
|
+
"large": 24,
|
|
72
|
+
"medium": 22,
|
|
73
|
+
"small": 20,
|
|
74
|
+
"xlarge": 26,
|
|
75
|
+
"xsmall": 18,
|
|
76
|
+
},
|
|
77
|
+
"space": Object {
|
|
78
|
+
"large": 24,
|
|
79
|
+
"medium": 16,
|
|
80
|
+
"small": 8,
|
|
81
|
+
"xlarge": 32,
|
|
82
|
+
"xsmall": 4,
|
|
83
|
+
"xxlarge": 40,
|
|
84
|
+
"xxsmall": 2,
|
|
85
|
+
"xxxlarge": 48,
|
|
86
|
+
"xxxxlarge": 56,
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
@@ -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,23 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getDividerTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const colors = {
|
|
5
|
+
default: theme.colors.outline,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const space = {
|
|
9
|
+
xsmall: `${theme.space.xsmall}px`,
|
|
10
|
+
small: `${theme.space.small}px`,
|
|
11
|
+
medium: `${theme.space.medium}px`,
|
|
12
|
+
large: `${theme.space.large}px`,
|
|
13
|
+
xlarge: `${theme.space.xlarge}px`,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const borderWiths = {
|
|
17
|
+
default: `${theme.borderWidths.base}px`,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return { colors, space, borderWiths };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default getDividerTheme;
|
|
@@ -16,11 +16,13 @@ const systemPalette = {
|
|
|
16
16
|
warning: palette.orange,
|
|
17
17
|
warningDark: palette.orangeDark15,
|
|
18
18
|
warningBackground: palette.orangeLight90,
|
|
19
|
-
platformBackground: palette.
|
|
19
|
+
platformBackground: palette.white,
|
|
20
|
+
backgroundLight: palette.greyLight95,
|
|
20
21
|
backgroundDark: palette.greyDark75,
|
|
21
22
|
text: palette.greyDark75,
|
|
22
23
|
disabledText: palette.greyDark15,
|
|
23
24
|
invertedText: palette.white,
|
|
25
|
+
outline: palette.greyLight60,
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export { palette, systemPalette };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { systemPalette } from './colors';
|
|
2
2
|
import { space } from './space';
|
|
3
3
|
import { fontSizes, fontWeights, lineHeights } from './typography';
|
|
4
|
+
import { borderWidths } from './borders';
|
|
4
5
|
|
|
5
6
|
const globalTheme = {
|
|
6
7
|
colors: {
|
|
@@ -10,6 +11,7 @@ const globalTheme = {
|
|
|
10
11
|
fontSizes,
|
|
11
12
|
fontWeights,
|
|
12
13
|
lineHeights,
|
|
14
|
+
borderWidths,
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
type GlobalTheme = typeof globalTheme;
|
package/src/theme/index.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import globalTheme, { GlobalTheme } from './global';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import getDividerTheme from './components/divider';
|
|
4
|
+
import getCardTheme from './components/card';
|
|
4
5
|
|
|
5
6
|
type Theme = GlobalTheme & {
|
|
6
7
|
__hd__: {
|
|
7
|
-
|
|
8
|
+
divider: ReturnType<typeof getDividerTheme>;
|
|
9
|
+
card: ReturnType<typeof getCardTheme>;
|
|
8
10
|
};
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
const getTheme = (theme: GlobalTheme = globalTheme): Theme => ({
|
|
12
14
|
...theme,
|
|
13
15
|
__hd__: {
|
|
14
|
-
|
|
16
|
+
divider: getDividerTheme(theme),
|
|
17
|
+
card: getCardTheme(theme),
|
|
15
18
|
},
|
|
16
19
|
});
|
|
17
20
|
|
package/tsconfig.json
CHANGED
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"noUnusedLocals": true,
|
|
14
14
|
"skipLibCheck": true,
|
|
15
15
|
"types": ["jest", "styled-components", "styled-components-react-native"],
|
|
16
|
+
"baseUrl": ".",
|
|
17
|
+
"paths": {
|
|
18
|
+
"styled-components-native": ["./src/styled-components.ts"]
|
|
19
|
+
}
|
|
16
20
|
},
|
|
17
21
|
"include": [
|
|
18
22
|
"src"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|