@hero-design/rn 8.92.2 → 8.93.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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +28 -0
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +689 -752
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +690 -752
- package/package.json +4 -2
- package/rollup.config.mjs +1 -0
- package/src/components/Badge/Count.tsx +60 -0
- package/src/components/Badge/StyledBadge.tsx +33 -2
- package/src/components/Badge/__tests__/Count.spec.tsx +38 -0
- package/src/components/Badge/__tests__/__snapshots__/Count.spec.tsx.snap +310 -0
- package/src/components/Badge/constants.ts +1 -0
- package/src/components/Badge/index.tsx +3 -2
- package/src/components/Button/StyledButton.tsx +15 -8
- package/src/components/Button/UtilityButton/StyledUtilityButton.tsx +5 -3
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +61 -4
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +26 -0
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +6 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -0
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +2 -0
- package/src/components/MapPin/StyledMapPin.tsx +1 -9
- package/src/components/Progress/ProgressCircle.tsx +53 -109
- package/src/components/Progress/StyledProgressBar.tsx +4 -1
- package/src/components/Progress/StyledProgressCircle.tsx +1 -57
- package/src/components/Progress/StyledStep.tsx +1 -1
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +299 -647
- package/src/components/Search/SearchOneLine.tsx +2 -2
- package/src/components/Search/SearchTwoLine.tsx +1 -1
- package/src/components/Search/StyledSearch.tsx +20 -35
- package/src/components/Search/__tests__/__snapshots__/SearchOneLine.spec.tsx.snap +51 -51
- package/src/components/Search/__tests__/__snapshots__/SearchSuffixIcon.spec.tsx.snap +2 -2
- package/src/components/Search/__tests__/__snapshots__/SearchTwoLine.spec.tsx.snap +13 -15
- package/src/components/Search/__tests__/__snapshots__/utils.spec.tsx.snap +4 -4
- package/src/components/Search/utils.tsx +2 -2
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/Tabs/TabWithBadge.tsx +1 -1
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +15 -9
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +6 -6
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +3 -3
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +15 -9
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -0
- package/src/components/Toolbar/StyledToolbar.tsx +1 -0
- package/src/components/Toolbar/ToolbarMessage.tsx +3 -0
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarMessage.spec.tsx.snap +8 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +31 -23
- package/src/theme/components/badge.ts +26 -1
- package/src/theme/components/button.ts +10 -0
- package/src/theme/components/progress.ts +21 -26
- package/src/theme/components/search.ts +2 -10
- package/src/theme/components/toolbar.ts +2 -0
- package/src/utils/helpers.ts +9 -0
- package/stats/8.92.3/rn-stats.html +4842 -0
- package/types/components/Badge/Count.d.ts +27 -0
- package/types/components/Badge/StyledBadge.d.ts +14 -4
- package/types/components/Badge/constants.d.ts +1 -0
- package/types/components/Badge/index.d.ts +1 -0
- package/types/components/Button/StyledButton.d.ts +2 -2
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +1 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Progress/StyledProgressCircle.d.ts +1 -32
- package/types/components/Search/StyledSearch.d.ts +0 -1
- package/types/components/TextInput/index.d.ts +1 -1
- package/types/theme/components/badge.d.ts +11 -0
- package/types/theme/components/button.d.ts +3 -0
- package/types/theme/components/progress.d.ts +6 -6
- package/types/theme/components/search.d.ts +2 -10
- package/types/theme/components/toolbar.d.ts +2 -0
- package/types/utils/helpers.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.93.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"react-native-linear-gradient": "^2.8.3",
|
|
39
39
|
"react-native-pager-view": "^6.2.1",
|
|
40
40
|
"react-native-safe-area-context": "^4.7.0",
|
|
41
|
+
"react-native-svg": "^15.11.2",
|
|
41
42
|
"react-native-vector-icons": "^9.1.0",
|
|
42
43
|
"react-native-webview": "^13.10.2"
|
|
43
44
|
},
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"@babel/preset-env": "^7.20.0",
|
|
47
48
|
"@babel/preset-react": "^7.20.0",
|
|
48
49
|
"@babel/preset-typescript": "^7.20.0",
|
|
49
|
-
"@babel/runtime": "^7.
|
|
50
|
+
"@babel/runtime": "^7.26.10",
|
|
50
51
|
"@emotion/jest": "^11.11.0",
|
|
51
52
|
"@eslint/compat": "^1.1.1",
|
|
52
53
|
"@eslint/eslintrc": "^3.1.0",
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
"react-native-linear-gradient": "2.8.3",
|
|
86
87
|
"react-native-pager-view": "^6.2.1",
|
|
87
88
|
"react-native-safe-area-context": "^4.7.0",
|
|
89
|
+
"react-native-svg": "^15.11.2",
|
|
88
90
|
"react-native-vector-icons": "^9.1.0",
|
|
89
91
|
"react-native-webview": "13.10.3",
|
|
90
92
|
"react-test-renderer": "18.2.0",
|
package/rollup.config.mjs
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import type { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import { StyledCount, StyledCountText } from './StyledBadge';
|
|
6
|
+
import { DEFAULT_MAX_NUMBER } from './constants';
|
|
7
|
+
|
|
8
|
+
export interface CountProps extends ViewProps {
|
|
9
|
+
/*
|
|
10
|
+
* The Status Badge's content.
|
|
11
|
+
*/
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the Status Badge is visible.
|
|
15
|
+
*/
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Additional style.
|
|
19
|
+
*/
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
/**
|
|
22
|
+
* Testing id of the component.
|
|
23
|
+
*/
|
|
24
|
+
testID?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The content will be displayed in the badge.
|
|
27
|
+
*/
|
|
28
|
+
content: number;
|
|
29
|
+
/**
|
|
30
|
+
* The maximum number displayed on the badge. If number exceeds this value, `${max}+` are displayed instead. (Only applied when content is number.)
|
|
31
|
+
*/
|
|
32
|
+
max?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const Status = ({
|
|
36
|
+
children,
|
|
37
|
+
visible = true,
|
|
38
|
+
style,
|
|
39
|
+
max = DEFAULT_MAX_NUMBER,
|
|
40
|
+
testID,
|
|
41
|
+
content: originalContent,
|
|
42
|
+
...nativeProps
|
|
43
|
+
}: CountProps): JSX.Element => {
|
|
44
|
+
const content = useMemo(() => {
|
|
45
|
+
return originalContent > max ? `${max}+` : String(originalContent);
|
|
46
|
+
}, [originalContent, max]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View {...nativeProps} style={style} testID={testID}>
|
|
50
|
+
{children}
|
|
51
|
+
{visible && (
|
|
52
|
+
<StyledCount testID="count-badge">
|
|
53
|
+
<StyledCountText>{content}</StyledCountText>
|
|
54
|
+
</StyledCount>
|
|
55
|
+
)}
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default Status;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Animated } from 'react-native';
|
|
1
|
+
import { Animated, View } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
import Typography from '../Typography';
|
|
4
4
|
import Icon from '../Icon';
|
|
@@ -64,10 +64,41 @@ const StyledStatus = styled(Animated.View)<{
|
|
|
64
64
|
borderRadius: theme.radii.rounded,
|
|
65
65
|
}));
|
|
66
66
|
|
|
67
|
+
const StyledCount = styled(View)(({ theme }) => ({
|
|
68
|
+
backgroundColor: theme.__hd__.badge.colors.danger,
|
|
69
|
+
borderRadius: theme.__hd__.badge.radii.count,
|
|
70
|
+
minWidth: theme.__hd__.badge.sizes.count.width,
|
|
71
|
+
height: theme.__hd__.badge.sizes.count.height,
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
textAlign: 'center',
|
|
75
|
+
textAlignVertical: 'center',
|
|
76
|
+
color: theme.__hd__.badge.colors.text,
|
|
77
|
+
display: 'flex',
|
|
78
|
+
paddingHorizontal: theme.__hd__.badge.space.countPaddingHorizontal,
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
top: theme.__hd__.badge.space.statusPositionTop,
|
|
81
|
+
right: theme.__hd__.badge.space.statusPositionRight,
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
const StyledCountText = styled(Typography.Text)(({ theme }) => ({
|
|
85
|
+
height: theme.__hd__.badge.sizes.count.height,
|
|
86
|
+
lineHeight: theme.__hd__.badge.lineHeights.count,
|
|
87
|
+
color: theme.__hd__.badge.colors.text,
|
|
88
|
+
fontSize: theme.__hd__.badge.fontSizes.count,
|
|
89
|
+
}));
|
|
90
|
+
|
|
67
91
|
const StyledIcon = styled(Icon)<{
|
|
68
92
|
themeSize: ThemeSize;
|
|
69
93
|
}>(({ themeSize, theme }) => ({
|
|
70
94
|
fontSize: theme.__hd__.badge.fontSizes[themeSize],
|
|
71
95
|
}));
|
|
72
96
|
|
|
73
|
-
export {
|
|
97
|
+
export {
|
|
98
|
+
StyledCountText,
|
|
99
|
+
StyledView,
|
|
100
|
+
StyledText,
|
|
101
|
+
StyledStatus,
|
|
102
|
+
StyledIcon,
|
|
103
|
+
StyledCount,
|
|
104
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import BadgeCount from '../Count';
|
|
4
|
+
import Icon from '../../Icon';
|
|
5
|
+
|
|
6
|
+
describe('BadgeCount', () => {
|
|
7
|
+
it.each`
|
|
8
|
+
content | expectedContent
|
|
9
|
+
${1} | ${'1'}
|
|
10
|
+
${12} | ${'12'}
|
|
11
|
+
${999} | ${'99+'}
|
|
12
|
+
`(
|
|
13
|
+
'displays $expectedContent for content $content',
|
|
14
|
+
({ content, expectedContent }) => {
|
|
15
|
+
const { getByText, getByTestId, toJSON } = renderWithTheme(
|
|
16
|
+
<BadgeCount content={content} testID="wrapper">
|
|
17
|
+
<Icon icon="bell-outlined" size="small" />
|
|
18
|
+
</BadgeCount>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
expect(toJSON()).toMatchSnapshot();
|
|
22
|
+
expect(getByText(expectedContent)).toBeDefined();
|
|
23
|
+
expect(getByTestId('count-badge')).toHaveStyle({
|
|
24
|
+
backgroundColor: '#cb300a',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
it('should hide if visible is false', () => {
|
|
30
|
+
const { queryByTestId } = renderWithTheme(
|
|
31
|
+
<BadgeCount content={1} visible={false} testID="wrapper">
|
|
32
|
+
<Icon icon="bell-outlined" size="small" />
|
|
33
|
+
</BadgeCount>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(queryByTestId('count-badge')).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`BadgeCount displays 1 for content 1 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
{
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
>
|
|
11
|
+
<View
|
|
12
|
+
testID="wrapper"
|
|
13
|
+
>
|
|
14
|
+
<HeroIcon
|
|
15
|
+
name="bell-outlined"
|
|
16
|
+
style={
|
|
17
|
+
[
|
|
18
|
+
{
|
|
19
|
+
"color": "#001f23",
|
|
20
|
+
"fontSize": 20,
|
|
21
|
+
},
|
|
22
|
+
undefined,
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
themeIntent="text"
|
|
26
|
+
themeSize="small"
|
|
27
|
+
/>
|
|
28
|
+
<View
|
|
29
|
+
style={
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
"alignItems": "center",
|
|
33
|
+
"backgroundColor": "#cb300a",
|
|
34
|
+
"borderRadius": 999,
|
|
35
|
+
"color": "#ffffff",
|
|
36
|
+
"display": "flex",
|
|
37
|
+
"height": 12,
|
|
38
|
+
"justifyContent": "center",
|
|
39
|
+
"minWidth": 12,
|
|
40
|
+
"paddingHorizontal": 2,
|
|
41
|
+
"position": "absolute",
|
|
42
|
+
"right": -2,
|
|
43
|
+
"textAlign": "center",
|
|
44
|
+
"textAlignVertical": "center",
|
|
45
|
+
"top": -2,
|
|
46
|
+
},
|
|
47
|
+
undefined,
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
testID="count-badge"
|
|
51
|
+
>
|
|
52
|
+
<Text
|
|
53
|
+
allowFontScaling={false}
|
|
54
|
+
style={
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
"color": "#001f23",
|
|
58
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
59
|
+
"fontSize": 14,
|
|
60
|
+
"letterSpacing": 0.42,
|
|
61
|
+
"lineHeight": 22,
|
|
62
|
+
},
|
|
63
|
+
[
|
|
64
|
+
{
|
|
65
|
+
"color": "#ffffff",
|
|
66
|
+
"fontSize": 6,
|
|
67
|
+
"height": 12,
|
|
68
|
+
"lineHeight": 12,
|
|
69
|
+
},
|
|
70
|
+
undefined,
|
|
71
|
+
],
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
themeFontSize="medium"
|
|
75
|
+
themeFontWeight="regular"
|
|
76
|
+
themeIntent="body"
|
|
77
|
+
themeTypeface="neutral"
|
|
78
|
+
>
|
|
79
|
+
1
|
|
80
|
+
</Text>
|
|
81
|
+
</View>
|
|
82
|
+
</View>
|
|
83
|
+
<View
|
|
84
|
+
pointerEvents="box-none"
|
|
85
|
+
position="bottom"
|
|
86
|
+
style={
|
|
87
|
+
[
|
|
88
|
+
{
|
|
89
|
+
"bottom": 0,
|
|
90
|
+
"elevation": 9999,
|
|
91
|
+
"flexDirection": "column-reverse",
|
|
92
|
+
"left": 0,
|
|
93
|
+
"paddingHorizontal": 24,
|
|
94
|
+
"paddingVertical": 16,
|
|
95
|
+
"position": "absolute",
|
|
96
|
+
"right": 0,
|
|
97
|
+
"top": 0,
|
|
98
|
+
},
|
|
99
|
+
undefined,
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
</View>
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
exports[`BadgeCount displays 12 for content 12 1`] = `
|
|
107
|
+
<View
|
|
108
|
+
style={
|
|
109
|
+
{
|
|
110
|
+
"flex": 1,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
>
|
|
114
|
+
<View
|
|
115
|
+
testID="wrapper"
|
|
116
|
+
>
|
|
117
|
+
<HeroIcon
|
|
118
|
+
name="bell-outlined"
|
|
119
|
+
style={
|
|
120
|
+
[
|
|
121
|
+
{
|
|
122
|
+
"color": "#001f23",
|
|
123
|
+
"fontSize": 20,
|
|
124
|
+
},
|
|
125
|
+
undefined,
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
themeIntent="text"
|
|
129
|
+
themeSize="small"
|
|
130
|
+
/>
|
|
131
|
+
<View
|
|
132
|
+
style={
|
|
133
|
+
[
|
|
134
|
+
{
|
|
135
|
+
"alignItems": "center",
|
|
136
|
+
"backgroundColor": "#cb300a",
|
|
137
|
+
"borderRadius": 999,
|
|
138
|
+
"color": "#ffffff",
|
|
139
|
+
"display": "flex",
|
|
140
|
+
"height": 12,
|
|
141
|
+
"justifyContent": "center",
|
|
142
|
+
"minWidth": 12,
|
|
143
|
+
"paddingHorizontal": 2,
|
|
144
|
+
"position": "absolute",
|
|
145
|
+
"right": -2,
|
|
146
|
+
"textAlign": "center",
|
|
147
|
+
"textAlignVertical": "center",
|
|
148
|
+
"top": -2,
|
|
149
|
+
},
|
|
150
|
+
undefined,
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
testID="count-badge"
|
|
154
|
+
>
|
|
155
|
+
<Text
|
|
156
|
+
allowFontScaling={false}
|
|
157
|
+
style={
|
|
158
|
+
[
|
|
159
|
+
{
|
|
160
|
+
"color": "#001f23",
|
|
161
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
162
|
+
"fontSize": 14,
|
|
163
|
+
"letterSpacing": 0.42,
|
|
164
|
+
"lineHeight": 22,
|
|
165
|
+
},
|
|
166
|
+
[
|
|
167
|
+
{
|
|
168
|
+
"color": "#ffffff",
|
|
169
|
+
"fontSize": 6,
|
|
170
|
+
"height": 12,
|
|
171
|
+
"lineHeight": 12,
|
|
172
|
+
},
|
|
173
|
+
undefined,
|
|
174
|
+
],
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
themeFontSize="medium"
|
|
178
|
+
themeFontWeight="regular"
|
|
179
|
+
themeIntent="body"
|
|
180
|
+
themeTypeface="neutral"
|
|
181
|
+
>
|
|
182
|
+
12
|
|
183
|
+
</Text>
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
<View
|
|
187
|
+
pointerEvents="box-none"
|
|
188
|
+
position="bottom"
|
|
189
|
+
style={
|
|
190
|
+
[
|
|
191
|
+
{
|
|
192
|
+
"bottom": 0,
|
|
193
|
+
"elevation": 9999,
|
|
194
|
+
"flexDirection": "column-reverse",
|
|
195
|
+
"left": 0,
|
|
196
|
+
"paddingHorizontal": 24,
|
|
197
|
+
"paddingVertical": 16,
|
|
198
|
+
"position": "absolute",
|
|
199
|
+
"right": 0,
|
|
200
|
+
"top": 0,
|
|
201
|
+
},
|
|
202
|
+
undefined,
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
/>
|
|
206
|
+
</View>
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
exports[`BadgeCount displays 99+ for content 999 1`] = `
|
|
210
|
+
<View
|
|
211
|
+
style={
|
|
212
|
+
{
|
|
213
|
+
"flex": 1,
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
>
|
|
217
|
+
<View
|
|
218
|
+
testID="wrapper"
|
|
219
|
+
>
|
|
220
|
+
<HeroIcon
|
|
221
|
+
name="bell-outlined"
|
|
222
|
+
style={
|
|
223
|
+
[
|
|
224
|
+
{
|
|
225
|
+
"color": "#001f23",
|
|
226
|
+
"fontSize": 20,
|
|
227
|
+
},
|
|
228
|
+
undefined,
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
themeIntent="text"
|
|
232
|
+
themeSize="small"
|
|
233
|
+
/>
|
|
234
|
+
<View
|
|
235
|
+
style={
|
|
236
|
+
[
|
|
237
|
+
{
|
|
238
|
+
"alignItems": "center",
|
|
239
|
+
"backgroundColor": "#cb300a",
|
|
240
|
+
"borderRadius": 999,
|
|
241
|
+
"color": "#ffffff",
|
|
242
|
+
"display": "flex",
|
|
243
|
+
"height": 12,
|
|
244
|
+
"justifyContent": "center",
|
|
245
|
+
"minWidth": 12,
|
|
246
|
+
"paddingHorizontal": 2,
|
|
247
|
+
"position": "absolute",
|
|
248
|
+
"right": -2,
|
|
249
|
+
"textAlign": "center",
|
|
250
|
+
"textAlignVertical": "center",
|
|
251
|
+
"top": -2,
|
|
252
|
+
},
|
|
253
|
+
undefined,
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
testID="count-badge"
|
|
257
|
+
>
|
|
258
|
+
<Text
|
|
259
|
+
allowFontScaling={false}
|
|
260
|
+
style={
|
|
261
|
+
[
|
|
262
|
+
{
|
|
263
|
+
"color": "#001f23",
|
|
264
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
265
|
+
"fontSize": 14,
|
|
266
|
+
"letterSpacing": 0.42,
|
|
267
|
+
"lineHeight": 22,
|
|
268
|
+
},
|
|
269
|
+
[
|
|
270
|
+
{
|
|
271
|
+
"color": "#ffffff",
|
|
272
|
+
"fontSize": 6,
|
|
273
|
+
"height": 12,
|
|
274
|
+
"lineHeight": 12,
|
|
275
|
+
},
|
|
276
|
+
undefined,
|
|
277
|
+
],
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
themeFontSize="medium"
|
|
281
|
+
themeFontWeight="regular"
|
|
282
|
+
themeIntent="body"
|
|
283
|
+
themeTypeface="neutral"
|
|
284
|
+
>
|
|
285
|
+
99+
|
|
286
|
+
</Text>
|
|
287
|
+
</View>
|
|
288
|
+
</View>
|
|
289
|
+
<View
|
|
290
|
+
pointerEvents="box-none"
|
|
291
|
+
position="bottom"
|
|
292
|
+
style={
|
|
293
|
+
[
|
|
294
|
+
{
|
|
295
|
+
"bottom": 0,
|
|
296
|
+
"elevation": 9999,
|
|
297
|
+
"flexDirection": "column-reverse",
|
|
298
|
+
"left": 0,
|
|
299
|
+
"paddingHorizontal": 24,
|
|
300
|
+
"paddingVertical": 16,
|
|
301
|
+
"position": "absolute",
|
|
302
|
+
"right": 0,
|
|
303
|
+
"top": 0,
|
|
304
|
+
},
|
|
305
|
+
undefined,
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
/>
|
|
309
|
+
</View>
|
|
310
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_MAX_NUMBER = 99;
|
|
@@ -2,12 +2,12 @@ import { Animated } from 'react-native';
|
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { StyledView, StyledText, StyledIcon } from './StyledBadge';
|
|
4
4
|
import BadgeStatus from './Status';
|
|
5
|
+
import BadgeCount from './Count';
|
|
5
6
|
import { BasicBadgeProps, IconBadgeProps } from './types';
|
|
7
|
+
import { DEFAULT_MAX_NUMBER } from './constants';
|
|
6
8
|
|
|
7
9
|
export type BadgeProps = BasicBadgeProps | IconBadgeProps;
|
|
8
10
|
|
|
9
|
-
const DEFAULT_MAX_NUMBER = 99;
|
|
10
|
-
|
|
11
11
|
const getPaddingState = (content: string): 'narrowContent' | 'wideContent' =>
|
|
12
12
|
content.length > 1 ? 'wideContent' : 'narrowContent';
|
|
13
13
|
|
|
@@ -87,4 +87,5 @@ const Badge = ({
|
|
|
87
87
|
|
|
88
88
|
export default Object.assign(Badge, {
|
|
89
89
|
Status: BadgeStatus,
|
|
90
|
+
Count: BadgeCount,
|
|
90
91
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { TouchableHighlight, View } from 'react-native';
|
|
2
|
-
import styled from '@emotion/native';
|
|
3
1
|
import type { ReactNativeStyle } from '@emotion/native';
|
|
2
|
+
import styled from '@emotion/native';
|
|
4
3
|
import type { Theme } from '@emotion/react';
|
|
4
|
+
import { TouchableHighlight, View } from 'react-native';
|
|
5
|
+
import { scale } from '../../utils/scale';
|
|
5
6
|
import Icon from '../Icon';
|
|
6
7
|
import Typography from '../Typography';
|
|
7
|
-
import { scale } from '../../utils/scale';
|
|
8
8
|
|
|
9
9
|
type Intent = 'primary' | 'secondary' | 'danger' | 'white';
|
|
10
10
|
|
|
@@ -319,11 +319,17 @@ const StyledButtonText = styled(Typography.Title)<{
|
|
|
319
319
|
return {
|
|
320
320
|
flexShrink: 1,
|
|
321
321
|
textAlign: 'center',
|
|
322
|
+
textAlignVertical: 'center',
|
|
323
|
+
lineHeight: theme.__hd__.button.lineHeights.buttonText,
|
|
322
324
|
...themeStyling(),
|
|
323
325
|
};
|
|
324
326
|
});
|
|
325
327
|
|
|
326
|
-
const StyledSmallButtonText =
|
|
328
|
+
const StyledSmallButtonText = styled(
|
|
329
|
+
StyledButtonText.withComponent(Typography.Body)
|
|
330
|
+
)(({ theme }) => ({
|
|
331
|
+
lineHeight: theme.__hd__.button.lineHeights.utilityButtonText,
|
|
332
|
+
}));
|
|
327
333
|
|
|
328
334
|
const StyledButtonTitleOfVariantText = styled(Typography.Body)<{
|
|
329
335
|
disabled?: boolean;
|
|
@@ -352,8 +358,9 @@ const StyledButtonTitleOfVariantText = styled(Typography.Body)<{
|
|
|
352
358
|
};
|
|
353
359
|
return {
|
|
354
360
|
flexShrink: 1,
|
|
355
|
-
lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant,
|
|
361
|
+
lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant,
|
|
356
362
|
textAlign: 'center',
|
|
363
|
+
textAlignVertical: 'center',
|
|
357
364
|
...themeStyling(),
|
|
358
365
|
};
|
|
359
366
|
});
|
|
@@ -427,10 +434,10 @@ const StyledButtonIcon = styled(Icon)<{
|
|
|
427
434
|
|
|
428
435
|
export {
|
|
429
436
|
StyledButtonContainer,
|
|
430
|
-
StyledButtonText,
|
|
431
|
-
StyledSmallButtonText,
|
|
432
|
-
StyledButtonIconWrapper,
|
|
433
437
|
StyledButtonIcon,
|
|
438
|
+
StyledButtonIconWrapper,
|
|
439
|
+
StyledButtonText,
|
|
434
440
|
StyledButtonTitleOfVariantText,
|
|
441
|
+
StyledSmallButtonText,
|
|
435
442
|
};
|
|
436
443
|
export type { Intent, ThemeVariant };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { View, TouchableOpacity } from 'react-native';
|
|
2
1
|
import styled from '@emotion/native';
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import Typography from '../../Typography';
|
|
5
5
|
|
|
@@ -17,7 +17,9 @@ export const IconWrapper = styled(View)(({ theme }) => ({
|
|
|
17
17
|
paddingRight: theme.__hd__.button.space.default.iconPadding,
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
|
-
export const ButtonText = styled(Typography.Body)({
|
|
20
|
+
export const ButtonText = styled(Typography.Body)(({ theme }) => ({
|
|
21
21
|
flexShrink: 1,
|
|
22
22
|
textAlign: 'center',
|
|
23
|
-
|
|
23
|
+
textAlignVertical: 'center',
|
|
24
|
+
lineHeight: theme.__hd__.button.lineHeights.utilityButtonText,
|
|
25
|
+
}));
|
|
@@ -90,7 +90,9 @@ exports[`UtilityButton snapshot has intent primary style 1`] = `
|
|
|
90
90
|
[
|
|
91
91
|
{
|
|
92
92
|
"flexShrink": 1,
|
|
93
|
+
"lineHeight": undefined,
|
|
93
94
|
"textAlign": "center",
|
|
95
|
+
"textAlignVertical": "center",
|
|
94
96
|
},
|
|
95
97
|
undefined,
|
|
96
98
|
],
|
|
@@ -216,7 +218,9 @@ exports[`UtilityButton snapshot has intent text style 1`] = `
|
|
|
216
218
|
[
|
|
217
219
|
{
|
|
218
220
|
"flexShrink": 1,
|
|
221
|
+
"lineHeight": undefined,
|
|
219
222
|
"textAlign": "center",
|
|
223
|
+
"textAlignVertical": "center",
|
|
220
224
|
},
|
|
221
225
|
undefined,
|
|
222
226
|
],
|