@hero-design/rn 7.0.6 → 7.1.2
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 +4 -3
- package/babel.config.js +1 -1
- package/es/index.js +411 -134
- package/lib/index.js +411 -131
- package/package.json +5 -4
- package/playground/components/BottomNavigation.tsx +69 -0
- package/playground/components/Card.tsx +174 -112
- package/playground/components/FAB.tsx +49 -0
- package/playground/index.tsx +6 -1
- package/rollup.config.js +1 -1
- package/src/components/BottomNavigation/StyledBottomNavigation.tsx +58 -0
- package/src/components/BottomNavigation/__tests__/BottomNavigation.spec.tsx +95 -0
- package/src/components/BottomNavigation/__tests__/__snapshots__/BottomNavigation.spec.tsx.snap +315 -0
- package/src/components/BottomNavigation/index.tsx +169 -0
- package/src/components/Card/StyledCard.tsx +1 -0
- package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +5 -4
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +5 -4
- package/src/components/FAB/AnimatedFABIcon.tsx +47 -0
- package/src/components/FAB/StyledFABContainer.tsx +14 -0
- package/src/components/FAB/StyledFABIcon.tsx +9 -0
- package/src/components/FAB/__tests__/AnimatedFABIcon.spec.tsx +20 -0
- package/src/components/FAB/__tests__/StyledFABContainer.spec.tsx +18 -0
- package/src/components/FAB/__tests__/StyledFABIcon.spec.tsx +16 -0
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +71 -0
- package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +46 -0
- package/src/components/FAB/__tests__/__snapshots__/StyledFABIcon.spec.tsx.snap +21 -0
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +120 -0
- package/src/components/FAB/__tests__/index.spec.tsx +58 -0
- package/src/components/FAB/index.tsx +56 -0
- package/src/components/Icon/index.tsx +1 -1
- package/src/components/Icon/utils.ts +6 -0
- package/src/components/Typography/Text/StyledText.tsx +5 -1
- package/src/components/Typography/Text/index.tsx +1 -1
- package/src/index.ts +6 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +30 -1
- package/src/theme/components/bottomNavigation.ts +23 -0
- package/src/theme/components/card.ts +1 -1
- package/src/theme/components/fab.ts +21 -0
- package/src/theme/components/typography.ts +1 -0
- package/src/theme/global/space.ts +11 -9
- package/src/theme/global/typography.ts +11 -9
- package/src/theme/index.ts +6 -0
- package/src/utils/__tests__/scale.spec.ts +26 -0
- package/src/utils/helpers.ts +4 -0
- package/src/utils/scale.ts +10 -0
- package/testUtils/setup.ts +4 -0
- package/types/playground/components/BottomNavigation.d.ts +2 -0
- package/types/playground/components/FAB.d.ts +2 -0
- package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +17 -0
- package/types/{components/Card/__tests__/Card.spec.d.ts → src/components/BottomNavigation/__tests__/BottomNavigation.spec.d.ts} +0 -0
- package/types/src/components/BottomNavigation/index.d.ts +40 -0
- package/types/src/components/FAB/AnimatedFABIcon.d.ts +6 -0
- package/types/src/components/FAB/StyledFABContainer.d.ts +3 -0
- package/types/src/components/FAB/StyledFABIcon.d.ts +3 -0
- package/types/{components/Card/__tests__/StyledCard.spec.d.ts → src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts} +0 -0
- package/types/{components/Divider/__tests__/StyledDivider.spec.d.ts → src/components/FAB/__tests__/StyledFABContainer.spec.d.ts} +0 -0
- package/types/{components/ExampleComponent/__tests__/StyledView.spec.d.ts → src/components/FAB/__tests__/StyledFABIcon.spec.d.ts} +0 -0
- package/types/src/components/{Typography/Text/__test__ → FAB/__tests__}/index.spec.d.ts +0 -0
- package/types/src/components/FAB/index.d.ts +30 -0
- package/types/src/components/Icon/index.d.ts +1 -1
- package/types/src/components/Icon/utils.d.ts +2 -0
- package/types/src/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/src/components/Typography/Text/index.d.ts +1 -1
- package/types/src/index.d.ts +4 -1
- package/types/src/theme/components/bottomNavigation.d.ts +17 -0
- package/types/src/theme/components/fab.d.ts +15 -0
- package/types/src/theme/components/typography.d.ts +1 -0
- package/types/src/theme/index.d.ts +4 -0
- package/types/src/{components/Typography/Text/__test__/StyledText.spec.d.ts → utils/__tests__/scale.spec.d.ts} +0 -0
- package/types/src/utils/helpers.d.ts +2 -0
- package/types/src/utils/scale.d.ts +2 -0
- package/.expo/README.md +0 -15
- package/.expo/packager-info.json +0 -10
- package/.expo/settings.json +0 -10
- package/types/components/Card/StyledCard.d.ts +0 -3
- package/types/components/Card/index.d.ts +0 -5
- package/types/components/Divider/StyledDivider.d.ts +0 -7
- package/types/components/Divider/index.d.ts +0 -12
- package/types/components/ExampleComponent/StyledView.d.ts +0 -7
- package/types/components/ExampleComponent/index.d.ts +0 -16
- package/types/index.d.ts +0 -5
- package/types/styled-components.d.ts +0 -6
- package/types/theme/__tests__/index.spec.d.ts +0 -1
- package/types/theme/components/card.d.ts +0 -10
- package/types/theme/components/divider.d.ts +0 -17
- package/types/theme/components/exampleComponent.d.ts +0 -14
- package/types/theme/global/borders.d.ts +0 -4
- package/types/theme/global/colors.d.ts +0 -26
- package/types/theme/global/index.d.ts +0 -63
- package/types/theme/global/space.d.ts +0 -12
- package/types/theme/global/typography.d.ts +0 -21
- package/types/theme/index.d.ts +0 -13
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import { AnimatedFABIcon } from '../AnimatedFABIcon';
|
|
5
|
+
|
|
6
|
+
describe('AnimatedFABIcon', () => {
|
|
7
|
+
it.each`
|
|
8
|
+
active
|
|
9
|
+
${true}
|
|
10
|
+
${false}
|
|
11
|
+
`('renders correctly when isActive is $active', ({ active }) => {
|
|
12
|
+
const { toJSON } = render(
|
|
13
|
+
<ThemeProvider theme={theme}>
|
|
14
|
+
<AnimatedFABIcon active={active} icon="add" />
|
|
15
|
+
</ThemeProvider>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(toJSON()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme, Typography } from '../../../index';
|
|
4
|
+
import { StyledFABContainer } from '../StyledFABContainer';
|
|
5
|
+
|
|
6
|
+
describe('StyledFABContainer', () => {
|
|
7
|
+
it('renders correctly', () => {
|
|
8
|
+
const { toJSON } = render(
|
|
9
|
+
<ThemeProvider theme={theme}>
|
|
10
|
+
<StyledFABContainer>
|
|
11
|
+
<Typography.Text> button </Typography.Text>
|
|
12
|
+
</StyledFABContainer>
|
|
13
|
+
</ThemeProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(toJSON()).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import { StyledFABIcon } from '../StyledFABIcon';
|
|
5
|
+
|
|
6
|
+
describe('StyledFABIcon', () => {
|
|
7
|
+
it('renders correctly', () => {
|
|
8
|
+
const { toJSON } = render(
|
|
9
|
+
<ThemeProvider theme={theme}>
|
|
10
|
+
<StyledFABIcon icon="add" />
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
expect(toJSON()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`AnimatedFABIcon renders correctly when isActive is false 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
collapsable={false}
|
|
6
|
+
nativeID="animatedComponent"
|
|
7
|
+
style={
|
|
8
|
+
Object {
|
|
9
|
+
"transform": Array [
|
|
10
|
+
Object {
|
|
11
|
+
"rotate": "0deg",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
>
|
|
17
|
+
<HeroIcon
|
|
18
|
+
name="add"
|
|
19
|
+
style={
|
|
20
|
+
Array [
|
|
21
|
+
Object {
|
|
22
|
+
"color": "#292a2b",
|
|
23
|
+
"fontSize": 24,
|
|
24
|
+
},
|
|
25
|
+
Object {
|
|
26
|
+
"color": "#ffffff",
|
|
27
|
+
"fontSize": 28,
|
|
28
|
+
},
|
|
29
|
+
Object {},
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
themeIntent="text"
|
|
33
|
+
themeSize="medium"
|
|
34
|
+
/>
|
|
35
|
+
</View>
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
exports[`AnimatedFABIcon renders correctly when isActive is true 1`] = `
|
|
39
|
+
<View
|
|
40
|
+
collapsable={false}
|
|
41
|
+
nativeID="animatedComponent"
|
|
42
|
+
style={
|
|
43
|
+
Object {
|
|
44
|
+
"transform": Array [
|
|
45
|
+
Object {
|
|
46
|
+
"rotate": "-45deg",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
<HeroIcon
|
|
53
|
+
name="add"
|
|
54
|
+
style={
|
|
55
|
+
Array [
|
|
56
|
+
Object {
|
|
57
|
+
"color": "#292a2b",
|
|
58
|
+
"fontSize": 24,
|
|
59
|
+
},
|
|
60
|
+
Object {
|
|
61
|
+
"color": "#ffffff",
|
|
62
|
+
"fontSize": 28,
|
|
63
|
+
},
|
|
64
|
+
Object {},
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
themeIntent="text"
|
|
68
|
+
themeSize="medium"
|
|
69
|
+
/>
|
|
70
|
+
</View>
|
|
71
|
+
`;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StyledFABContainer renders correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
accessible={true}
|
|
6
|
+
focusable={false}
|
|
7
|
+
onClick={[Function]}
|
|
8
|
+
onResponderGrant={[Function]}
|
|
9
|
+
onResponderMove={[Function]}
|
|
10
|
+
onResponderRelease={[Function]}
|
|
11
|
+
onResponderTerminate={[Function]}
|
|
12
|
+
onResponderTerminationRequest={[Function]}
|
|
13
|
+
onStartShouldSetResponder={[Function]}
|
|
14
|
+
style={
|
|
15
|
+
Object {
|
|
16
|
+
"alignItems": "center",
|
|
17
|
+
"backgroundColor": "#292a2b",
|
|
18
|
+
"borderBottomLeftRadius": 999,
|
|
19
|
+
"borderBottomRightRadius": 999,
|
|
20
|
+
"borderTopLeftRadius": 999,
|
|
21
|
+
"borderTopRightRadius": 999,
|
|
22
|
+
"height": 64,
|
|
23
|
+
"justifyContent": "center",
|
|
24
|
+
"overflow": "hidden",
|
|
25
|
+
"width": 64,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
>
|
|
29
|
+
<Text
|
|
30
|
+
style={
|
|
31
|
+
Object {
|
|
32
|
+
"color": "#292a2b",
|
|
33
|
+
"fontSize": 14,
|
|
34
|
+
"fontWeight": "400",
|
|
35
|
+
"letterSpacing": 0.42,
|
|
36
|
+
"lineHeight": 22,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
themeFontSize="medium"
|
|
40
|
+
themeFontWeight="regular"
|
|
41
|
+
themeIntent="body"
|
|
42
|
+
>
|
|
43
|
+
button
|
|
44
|
+
</Text>
|
|
45
|
+
</View>
|
|
46
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StyledFABIcon renders correctly 1`] = `
|
|
4
|
+
<HeroIcon
|
|
5
|
+
name="add"
|
|
6
|
+
style={
|
|
7
|
+
Array [
|
|
8
|
+
Object {
|
|
9
|
+
"color": "#292a2b",
|
|
10
|
+
"fontSize": 24,
|
|
11
|
+
},
|
|
12
|
+
Object {
|
|
13
|
+
"color": "#ffffff",
|
|
14
|
+
"fontSize": 28,
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
themeIntent="text"
|
|
19
|
+
themeSize="medium"
|
|
20
|
+
/>
|
|
21
|
+
`;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`FAB when animated is false renders styledFABIcon 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
accessible={true}
|
|
6
|
+
focusable={true}
|
|
7
|
+
onClick={[Function]}
|
|
8
|
+
onResponderGrant={[Function]}
|
|
9
|
+
onResponderMove={[Function]}
|
|
10
|
+
onResponderRelease={[Function]}
|
|
11
|
+
onResponderTerminate={[Function]}
|
|
12
|
+
onResponderTerminationRequest={[Function]}
|
|
13
|
+
onStartShouldSetResponder={[Function]}
|
|
14
|
+
style={
|
|
15
|
+
Array [
|
|
16
|
+
Object {
|
|
17
|
+
"alignItems": "center",
|
|
18
|
+
"backgroundColor": "#292a2b",
|
|
19
|
+
"borderBottomLeftRadius": 999,
|
|
20
|
+
"borderBottomRightRadius": 999,
|
|
21
|
+
"borderTopLeftRadius": 999,
|
|
22
|
+
"borderTopRightRadius": 999,
|
|
23
|
+
"height": 64,
|
|
24
|
+
"justifyContent": "center",
|
|
25
|
+
"overflow": "hidden",
|
|
26
|
+
"width": 64,
|
|
27
|
+
},
|
|
28
|
+
Object {
|
|
29
|
+
"backgroundColor": "#292a2b",
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
>
|
|
34
|
+
<HeroIcon
|
|
35
|
+
name="add"
|
|
36
|
+
style={
|
|
37
|
+
Array [
|
|
38
|
+
Object {
|
|
39
|
+
"color": "#292a2b",
|
|
40
|
+
"fontSize": 24,
|
|
41
|
+
},
|
|
42
|
+
Object {
|
|
43
|
+
"color": "#ffffff",
|
|
44
|
+
"fontSize": 28,
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
testID="styledFABIcon"
|
|
49
|
+
themeIntent="text"
|
|
50
|
+
themeSize="medium"
|
|
51
|
+
/>
|
|
52
|
+
</View>
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`FAB when animated is true renders animatedFABIcon 1`] = `
|
|
56
|
+
<View
|
|
57
|
+
accessible={true}
|
|
58
|
+
focusable={true}
|
|
59
|
+
onClick={[Function]}
|
|
60
|
+
onResponderGrant={[Function]}
|
|
61
|
+
onResponderMove={[Function]}
|
|
62
|
+
onResponderRelease={[Function]}
|
|
63
|
+
onResponderTerminate={[Function]}
|
|
64
|
+
onResponderTerminationRequest={[Function]}
|
|
65
|
+
onStartShouldSetResponder={[Function]}
|
|
66
|
+
style={
|
|
67
|
+
Array [
|
|
68
|
+
Object {
|
|
69
|
+
"alignItems": "center",
|
|
70
|
+
"backgroundColor": "#292a2b",
|
|
71
|
+
"borderBottomLeftRadius": 999,
|
|
72
|
+
"borderBottomRightRadius": 999,
|
|
73
|
+
"borderTopLeftRadius": 999,
|
|
74
|
+
"borderTopRightRadius": 999,
|
|
75
|
+
"height": 64,
|
|
76
|
+
"justifyContent": "center",
|
|
77
|
+
"overflow": "hidden",
|
|
78
|
+
"width": 64,
|
|
79
|
+
},
|
|
80
|
+
Object {
|
|
81
|
+
"backgroundColor": "#292a2b",
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
>
|
|
86
|
+
<View
|
|
87
|
+
collapsable={false}
|
|
88
|
+
nativeID="animatedComponent"
|
|
89
|
+
style={
|
|
90
|
+
Object {
|
|
91
|
+
"transform": Array [
|
|
92
|
+
Object {
|
|
93
|
+
"rotate": "0deg",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
>
|
|
99
|
+
<HeroIcon
|
|
100
|
+
name="add"
|
|
101
|
+
style={
|
|
102
|
+
Array [
|
|
103
|
+
Object {
|
|
104
|
+
"color": "#292a2b",
|
|
105
|
+
"fontSize": 24,
|
|
106
|
+
},
|
|
107
|
+
Object {
|
|
108
|
+
"color": "#ffffff",
|
|
109
|
+
"fontSize": 28,
|
|
110
|
+
},
|
|
111
|
+
Object {},
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
testID="animatedFABIcon"
|
|
115
|
+
themeIntent="text"
|
|
116
|
+
themeSize="medium"
|
|
117
|
+
/>
|
|
118
|
+
</View>
|
|
119
|
+
</View>
|
|
120
|
+
`;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import FAB from '..';
|
|
5
|
+
|
|
6
|
+
describe('FAB', () => {
|
|
7
|
+
describe('when animated is true', () => {
|
|
8
|
+
it('renders animatedFABIcon', () => {
|
|
9
|
+
const { queryAllByTestId, toJSON } = render(
|
|
10
|
+
<ThemeProvider theme={theme}>
|
|
11
|
+
<FAB
|
|
12
|
+
icon="add"
|
|
13
|
+
animated
|
|
14
|
+
style={{ backgroundColor: theme.colors.backgroundDark }}
|
|
15
|
+
/>
|
|
16
|
+
</ThemeProvider>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(toJSON()).toMatchSnapshot();
|
|
20
|
+
expect(queryAllByTestId('animatedFABIcon')).toHaveLength(1);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('when animated is false', () => {
|
|
25
|
+
it('renders styledFABIcon', () => {
|
|
26
|
+
const { queryAllByTestId, toJSON } = render(
|
|
27
|
+
<ThemeProvider theme={theme}>
|
|
28
|
+
<FAB
|
|
29
|
+
icon="add"
|
|
30
|
+
style={{ backgroundColor: theme.colors.backgroundDark }}
|
|
31
|
+
/>
|
|
32
|
+
</ThemeProvider>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(toJSON()).toMatchSnapshot();
|
|
36
|
+
expect(queryAllByTestId('styledFABIcon')).toHaveLength(1);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('when onPress', () => {
|
|
41
|
+
it('triggers onPress', () => {
|
|
42
|
+
const onPressSpy = jest.fn();
|
|
43
|
+
const { getByTestId } = render(
|
|
44
|
+
<ThemeProvider theme={theme}>
|
|
45
|
+
<FAB
|
|
46
|
+
onPress={onPressSpy}
|
|
47
|
+
icon="add"
|
|
48
|
+
style={{ backgroundColor: theme.colors.backgroundDark }}
|
|
49
|
+
testID="FAB"
|
|
50
|
+
/>
|
|
51
|
+
</ThemeProvider>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
fireEvent(getByTestId('FAB'), 'press');
|
|
55
|
+
expect(onPressSpy).toBeCalledTimes(1);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { IconProps } from '../Icon';
|
|
4
|
+
import { AnimatedFABIcon } from './AnimatedFABIcon';
|
|
5
|
+
import { StyledFABContainer } from './StyledFABContainer';
|
|
6
|
+
import { StyledFABIcon } from './StyledFABIcon';
|
|
7
|
+
|
|
8
|
+
interface FABProps {
|
|
9
|
+
/**
|
|
10
|
+
* Name of the Icon.
|
|
11
|
+
*/
|
|
12
|
+
icon: IconProps['icon'];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This function is called on pressing the button.
|
|
16
|
+
* */
|
|
17
|
+
onPress?: () => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Specify if the button is animated.
|
|
21
|
+
*/
|
|
22
|
+
animated?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Specify if the button is in active state. It only works if animated is true.
|
|
26
|
+
*/
|
|
27
|
+
active?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Addditional style.
|
|
30
|
+
*/
|
|
31
|
+
style?: StyleProp<ViewStyle>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Testing id of the component.
|
|
35
|
+
*/
|
|
36
|
+
testID?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const FAB = ({ onPress, icon, animated, testID, active, style }: FABProps) => (
|
|
40
|
+
<StyledFABContainer
|
|
41
|
+
testID={testID}
|
|
42
|
+
onPress={() => {
|
|
43
|
+
onPress?.();
|
|
44
|
+
}}
|
|
45
|
+
activeOpacity={0.6}
|
|
46
|
+
style={style}
|
|
47
|
+
>
|
|
48
|
+
{animated ? (
|
|
49
|
+
<AnimatedFABIcon active={active} icon={icon} testID="animatedFABIcon" />
|
|
50
|
+
) : (
|
|
51
|
+
<StyledFABIcon icon={icon} testID="styledFABIcon" />
|
|
52
|
+
)}
|
|
53
|
+
</StyledFABContainer>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export default FAB;
|
|
@@ -4,7 +4,7 @@ import styled, { css } from '../../../styled-components';
|
|
|
4
4
|
const StyledText = styled(Text)<{
|
|
5
5
|
themeFontSize: 'small' | 'medium' | 'large' | 'xlarge';
|
|
6
6
|
themeFontWeight: 'light' | 'regular' | 'semi-bold';
|
|
7
|
-
themeIntent: 'body' | 'subdued';
|
|
7
|
+
themeIntent: 'body' | 'subdued' | 'primary';
|
|
8
8
|
}>`
|
|
9
9
|
${({ themeFontSize, theme }) => {
|
|
10
10
|
switch (themeFontSize) {
|
|
@@ -62,6 +62,10 @@ const StyledText = styled(Text)<{
|
|
|
62
62
|
return css`
|
|
63
63
|
color: ${theme.__hd__.typography.colors.subdued};
|
|
64
64
|
`;
|
|
65
|
+
case 'primary':
|
|
66
|
+
return css`
|
|
67
|
+
color: ${theme.__hd__.typography.colors.primary};
|
|
68
|
+
`;
|
|
65
69
|
}
|
|
66
70
|
}}
|
|
67
71
|
`;
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { ThemeProvider, useTheme } from 'styled-components-native';
|
|
2
2
|
import theme, { getTheme } from './theme';
|
|
3
|
+
import { scale } from './utils/scale';
|
|
3
4
|
|
|
4
5
|
import Badge from './components/Badge';
|
|
6
|
+
import BottomNavigation from './components/BottomNavigation';
|
|
5
7
|
import Card from './components/Card';
|
|
6
8
|
import Divider from './components/Divider';
|
|
7
9
|
import Icon from './components/Icon';
|
|
8
10
|
import Typography from './components/Typography';
|
|
11
|
+
import FAB from './components/FAB';
|
|
9
12
|
|
|
10
13
|
export {
|
|
11
14
|
theme,
|
|
12
15
|
getTheme,
|
|
13
16
|
useTheme,
|
|
17
|
+
scale,
|
|
14
18
|
ThemeProvider,
|
|
15
19
|
Badge,
|
|
20
|
+
BottomNavigation,
|
|
16
21
|
Card,
|
|
17
22
|
Divider,
|
|
18
23
|
Icon,
|
|
19
24
|
Typography,
|
|
25
|
+
FAB,
|
|
20
26
|
};
|
|
@@ -30,9 +30,24 @@ Object {
|
|
|
30
30
|
"default": "4px",
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
|
+
"bottomNavigation": Object {
|
|
34
|
+
"colors": Object {
|
|
35
|
+
"background": "#ffffff",
|
|
36
|
+
"shadow": "#292a2b",
|
|
37
|
+
},
|
|
38
|
+
"shadows": Object {
|
|
39
|
+
"elevation": 10,
|
|
40
|
+
"offset": "0px 3px",
|
|
41
|
+
"opacity": 0.27,
|
|
42
|
+
"radius": "4.65px",
|
|
43
|
+
},
|
|
44
|
+
"sizes": Object {
|
|
45
|
+
"height": 72,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
33
48
|
"card": Object {
|
|
34
49
|
"padding": Object {
|
|
35
|
-
"default": "
|
|
50
|
+
"default": "8px",
|
|
36
51
|
},
|
|
37
52
|
"radii": Object {
|
|
38
53
|
"default": "12px",
|
|
@@ -53,6 +68,19 @@ Object {
|
|
|
53
68
|
"xsmall": "4px",
|
|
54
69
|
},
|
|
55
70
|
},
|
|
71
|
+
"fab": Object {
|
|
72
|
+
"colors": Object {
|
|
73
|
+
"buttonBackground": "#292a2b",
|
|
74
|
+
"icon": "#ffffff",
|
|
75
|
+
},
|
|
76
|
+
"fontSizes": Object {
|
|
77
|
+
"default": "28px",
|
|
78
|
+
},
|
|
79
|
+
"sizes": Object {
|
|
80
|
+
"height": "64px",
|
|
81
|
+
"width": "64px",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
56
84
|
"icon": Object {
|
|
57
85
|
"colors": Object {
|
|
58
86
|
"danger": "#de350b",
|
|
@@ -73,6 +101,7 @@ Object {
|
|
|
73
101
|
"typography": Object {
|
|
74
102
|
"colors": Object {
|
|
75
103
|
"body": "#292a2b",
|
|
104
|
+
"primary": "#7622d7",
|
|
76
105
|
"subdued": "#8b8d92",
|
|
77
106
|
},
|
|
78
107
|
"fontSizes": Object {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getBottomNavigationTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const colors = {
|
|
5
|
+
shadow: theme.colors.backgroundDark,
|
|
6
|
+
background: theme.colors.platformBackground,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const sizes = {
|
|
10
|
+
height: 72,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const shadows = {
|
|
14
|
+
offset: `0px 3px`,
|
|
15
|
+
opacity: 0.27,
|
|
16
|
+
radius: `4.65px`,
|
|
17
|
+
elevation: 10,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return { colors, shadows, sizes };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default getBottomNavigationTheme;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getFABTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const colors = {
|
|
5
|
+
buttonBackground: theme.colors.backgroundDark,
|
|
6
|
+
icon: theme.colors.invertedText,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const sizes = {
|
|
10
|
+
width: '64px',
|
|
11
|
+
height: '64px',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const fontSizes = {
|
|
15
|
+
default: `${theme.fontSizes.xxxxlarge}px`,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return { fontSizes, colors, sizes };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default getFABTheme;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { scale } from '../../utils/scale';
|
|
2
|
+
|
|
1
3
|
const BASE = 8;
|
|
2
4
|
|
|
3
5
|
const space = {
|
|
4
|
-
xxsmall: BASE * 0.25,
|
|
5
|
-
xsmall: BASE * 0.5,
|
|
6
|
-
small: BASE,
|
|
7
|
-
medium: BASE * 2,
|
|
8
|
-
large: BASE * 3,
|
|
9
|
-
xlarge: BASE * 4,
|
|
10
|
-
xxlarge: BASE * 5,
|
|
11
|
-
xxxlarge: BASE * 6,
|
|
12
|
-
xxxxlarge: BASE * 7,
|
|
6
|
+
xxsmall: scale(BASE * 0.25),
|
|
7
|
+
xsmall: scale(BASE * 0.5),
|
|
8
|
+
small: scale(BASE),
|
|
9
|
+
medium: scale(BASE * 2),
|
|
10
|
+
large: scale(BASE * 3),
|
|
11
|
+
xlarge: scale(BASE * 4),
|
|
12
|
+
xxlarge: scale(BASE * 5),
|
|
13
|
+
xxxlarge: scale(BASE * 6),
|
|
14
|
+
xxxxlarge: scale(BASE * 7),
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export { space };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { scale } from '../../utils/scale';
|
|
2
|
+
|
|
1
3
|
const BASE = 16;
|
|
2
4
|
|
|
3
5
|
const fontSizes = {
|
|
4
|
-
xxxxxlarge: BASE * 2, //
|
|
5
|
-
xxxxlarge: BASE * 1.75, //
|
|
6
|
-
xxxlarge: BASE * 1.5, //
|
|
7
|
-
xxlarge: BASE * 1.25, //
|
|
8
|
-
xlarge: BASE * 1.125, //
|
|
9
|
-
large: BASE, //
|
|
10
|
-
medium: BASE * 0.875, //
|
|
11
|
-
small: BASE * 0.75, //
|
|
12
|
-
xsmall: BASE * 0.625, //
|
|
6
|
+
xxxxxlarge: scale(BASE * 2), // 32
|
|
7
|
+
xxxxlarge: scale(BASE * 1.75), // 28
|
|
8
|
+
xxxlarge: scale(BASE * 1.5), // 24
|
|
9
|
+
xxlarge: scale(BASE * 1.25), // 20
|
|
10
|
+
xlarge: scale(BASE * 1.125), // 18
|
|
11
|
+
large: scale(BASE), // 16
|
|
12
|
+
medium: scale(BASE * 0.875), // 14
|
|
13
|
+
small: scale(BASE * 0.75), // 12
|
|
14
|
+
xsmall: scale(BASE * 0.625), // 10
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
const fontWeights = {
|