@hero-design/rn 7.0.4 → 7.1.0
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/.expo/packager-info.json +1 -1
- package/babel.config.js +1 -1
- package/es/index.js +170 -49
- package/lib/assets/fonts/hero-icons.ttf +0 -0
- package/lib/index.js +169 -46
- package/package.json +6 -4
- package/playground/components/Card.tsx +75 -92
- package/playground/components/FAB.tsx +49 -0
- package/playground/index.tsx +3 -1
- package/rollup.config.js +11 -2
- package/src/components/Badge/index.tsx +12 -6
- package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +4 -4
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +4 -4
- package/src/components/Card/index.tsx +16 -3
- package/src/components/Divider/StyledDivider.tsx +1 -1
- package/src/components/Divider/index.tsx +20 -2
- 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 +8 -8
- package/src/components/Typography/Text/{__test__ → __tests__}/StyledText.spec.tsx +0 -0
- package/src/components/Typography/Text/{__test__ → __tests__}/__snapshots__/StyledText.spec.tsx.snap +0 -0
- package/src/components/Typography/Text/{__test__ → __tests__}/index.spec.tsx +0 -0
- package/src/components/Typography/Text/index.tsx +13 -1
- package/src/index.ts +4 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +15 -2
- package/src/theme/components/card.ts +1 -1
- package/src/theme/components/divider.ts +2 -2
- package/src/theme/components/fab.ts +21 -0
- package/src/theme/global/space.ts +11 -9
- package/src/theme/global/typography.ts +11 -9
- package/src/theme/index.ts +3 -0
- package/src/utils/__tests__/scale.spec.ts +26 -0
- package/src/utils/scale.ts +10 -0
- package/testUtils/setup.ts +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/playground/components/FAB.d.ts +2 -0
- package/types/src/components/Badge/index.d.ts +6 -6
- package/types/src/components/Card/index.d.ts +14 -1
- package/types/src/components/Divider/index.d.ts +11 -2
- 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/src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +1 -0
- package/types/src/components/FAB/__tests__/StyledFABContainer.spec.d.ts +1 -0
- package/types/src/components/FAB/__tests__/StyledFABIcon.spec.d.ts +1 -0
- package/types/src/components/FAB/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/FAB/index.d.ts +30 -0
- package/types/src/components/Icon/index.d.ts +8 -8
- package/types/src/components/Typography/Text/__tests__/StyledText.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/index.d.ts +9 -1
- package/types/src/index.d.ts +3 -1
- package/types/src/theme/components/divider.d.ts +1 -1
- package/types/src/theme/components/fab.d.ts +15 -0
- package/types/src/theme/index.d.ts +2 -0
- package/types/src/utils/__tests__/scale.spec.d.ts +1 -0
- package/types/src/utils/scale.d.ts +2 -0
- 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/types/theme/colors.d.ts +0 -24
- package/types/theme/components/demoStyle.d.ts +0 -11
- package/types/theme/space.d.ts +0 -12
- package/types/theme/typography.d.ts +0 -21
|
@@ -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;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StyleProp,
|
|
2
|
+
import { StyleProp, TextStyle } from 'react-native';
|
|
3
3
|
import IconList from './IconList';
|
|
4
4
|
import HeroIcon from './HeroIcon';
|
|
5
5
|
|
|
6
6
|
type IconName = typeof IconList[number];
|
|
7
7
|
|
|
8
|
-
interface IconProps {
|
|
8
|
+
export interface IconProps {
|
|
9
9
|
/**
|
|
10
|
-
* Name of the
|
|
10
|
+
* Name of the Icon.
|
|
11
11
|
*/
|
|
12
12
|
icon: IconName;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Intent of the Icon.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
intent?: 'text' | 'primary' | 'info' | 'danger' | 'success' | 'warning';
|
|
17
17
|
/**
|
|
18
|
-
* Size of the
|
|
18
|
+
* Size of the Icon.
|
|
19
19
|
*/
|
|
20
20
|
size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Addditional style.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
style?: StyleProp<TextStyle>;
|
|
25
25
|
/**
|
|
26
26
|
* Testing id of the component.
|
|
27
27
|
*/
|
|
File without changes
|
package/src/components/Typography/Text/{__test__ → __tests__}/__snapshots__/StyledText.spec.tsx.snap
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TextProps as NativeTextProps,
|
|
4
|
+
StyleProp,
|
|
5
|
+
TextStyle,
|
|
6
|
+
} from 'react-native';
|
|
3
7
|
import { StyledText } from './StyledText';
|
|
4
8
|
|
|
5
9
|
interface TextProps extends NativeTextProps {
|
|
@@ -19,6 +23,14 @@ interface TextProps extends NativeTextProps {
|
|
|
19
23
|
* Visual intent color to apply to the text.
|
|
20
24
|
*/
|
|
21
25
|
intent?: 'body' | 'subdued';
|
|
26
|
+
/**
|
|
27
|
+
* Addditional style.
|
|
28
|
+
*/
|
|
29
|
+
style?: StyleProp<TextStyle>;
|
|
30
|
+
/**
|
|
31
|
+
* Testing id of the component.
|
|
32
|
+
*/
|
|
33
|
+
testID?: string;
|
|
22
34
|
}
|
|
23
35
|
|
|
24
36
|
const Text = ({
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
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';
|
|
5
6
|
import Card from './components/Card';
|
|
6
7
|
import Divider from './components/Divider';
|
|
7
8
|
import Icon from './components/Icon';
|
|
8
9
|
import Typography from './components/Typography';
|
|
10
|
+
import FAB from './components/FAB';
|
|
9
11
|
|
|
10
12
|
export {
|
|
11
13
|
theme,
|
|
12
14
|
getTheme,
|
|
13
15
|
useTheme,
|
|
16
|
+
scale,
|
|
14
17
|
ThemeProvider,
|
|
15
18
|
Badge,
|
|
16
19
|
Card,
|
|
17
20
|
Divider,
|
|
18
21
|
Icon,
|
|
19
22
|
Typography,
|
|
23
|
+
FAB,
|
|
20
24
|
};
|
|
@@ -32,14 +32,14 @@ Object {
|
|
|
32
32
|
},
|
|
33
33
|
"card": Object {
|
|
34
34
|
"padding": Object {
|
|
35
|
-
"default": "
|
|
35
|
+
"default": "8px",
|
|
36
36
|
},
|
|
37
37
|
"radii": Object {
|
|
38
38
|
"default": "12px",
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
"divider": Object {
|
|
42
|
-
"
|
|
42
|
+
"borderWidths": Object {
|
|
43
43
|
"default": "1px",
|
|
44
44
|
},
|
|
45
45
|
"colors": Object {
|
|
@@ -53,6 +53,19 @@ Object {
|
|
|
53
53
|
"xsmall": "4px",
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
|
+
"fab": Object {
|
|
57
|
+
"colors": Object {
|
|
58
|
+
"buttonBackground": "#292a2b",
|
|
59
|
+
"icon": "#ffffff",
|
|
60
|
+
},
|
|
61
|
+
"fontSizes": Object {
|
|
62
|
+
"default": "28px",
|
|
63
|
+
},
|
|
64
|
+
"sizes": Object {
|
|
65
|
+
"height": "64px",
|
|
66
|
+
"width": "64px",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
56
69
|
"icon": Object {
|
|
57
70
|
"colors": Object {
|
|
58
71
|
"danger": "#de350b",
|
|
@@ -13,11 +13,11 @@ const getDividerTheme = (theme: GlobalTheme) => {
|
|
|
13
13
|
xlarge: `${theme.space.xlarge}px`,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const borderWidths = {
|
|
17
17
|
default: `${theme.borderWidths.base}px`,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
return { colors, space,
|
|
20
|
+
return { colors, space, borderWidths };
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export default getDividerTheme;
|
|
@@ -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 = {
|
package/src/theme/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import getCardTheme from './components/card';
|
|
|
5
5
|
import getDividerTheme from './components/divider';
|
|
6
6
|
import getIconTheme from './components/icon';
|
|
7
7
|
import getTypographyTheme from './components/typography';
|
|
8
|
+
import getFABTheme from './components/fab';
|
|
8
9
|
|
|
9
10
|
type Theme = GlobalTheme & {
|
|
10
11
|
__hd__: {
|
|
@@ -13,6 +14,7 @@ type Theme = GlobalTheme & {
|
|
|
13
14
|
divider: ReturnType<typeof getDividerTheme>;
|
|
14
15
|
icon: ReturnType<typeof getIconTheme>;
|
|
15
16
|
typography: ReturnType<typeof getTypographyTheme>;
|
|
17
|
+
fab: ReturnType<typeof getFABTheme>;
|
|
16
18
|
};
|
|
17
19
|
};
|
|
18
20
|
|
|
@@ -24,6 +26,7 @@ const getTheme = (theme: GlobalTheme = globalTheme): Theme => ({
|
|
|
24
26
|
divider: getDividerTheme(theme),
|
|
25
27
|
icon: getIconTheme(theme),
|
|
26
28
|
typography: getTypographyTheme(theme),
|
|
29
|
+
fab: getFABTheme(theme),
|
|
27
30
|
},
|
|
28
31
|
});
|
|
29
32
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Dimensions } from 'react-native';
|
|
2
|
+
import { scale, BASE_WIDTH } from '../scale';
|
|
3
|
+
|
|
4
|
+
jest.unmock('../scale'); // Unmock global mocking of scale for other tests
|
|
5
|
+
|
|
6
|
+
describe('scale', () => {
|
|
7
|
+
it('returns scale based on width when width < height', () => {
|
|
8
|
+
jest
|
|
9
|
+
.spyOn(Dimensions, 'get')
|
|
10
|
+
.mockReturnValue({ width: 400, height: 500, scale: 1, fontScale: 1 });
|
|
11
|
+
|
|
12
|
+
const size = 10;
|
|
13
|
+
|
|
14
|
+
expect(scale(size)).toBe((400 / BASE_WIDTH) * size);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('returns scale based on height when width > height', () => {
|
|
18
|
+
jest
|
|
19
|
+
.spyOn(Dimensions, 'get')
|
|
20
|
+
.mockReturnValue({ width: 700, height: 350, scale: 1, fontScale: 1 });
|
|
21
|
+
|
|
22
|
+
const size = 10;
|
|
23
|
+
|
|
24
|
+
expect(scale(size)).toBe((350 / BASE_WIDTH) * size);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dimensions } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const BASE_WIDTH = 390; // Based on iPhone 13's viewport size
|
|
4
|
+
|
|
5
|
+
export const scale = (size: number) => {
|
|
6
|
+
const { width, height } = Dimensions.get('window');
|
|
7
|
+
const shortDimension = width < height ? width : height;
|
|
8
|
+
|
|
9
|
+
return (shortDimension / BASE_WIDTH) * size;
|
|
10
|
+
};
|
package/testUtils/setup.ts
CHANGED