@hero-design/rn 7.26.0 → 7.27.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/.turbo/turbo-build.log +9 -9
- package/es/index.js +264 -201
- package/lib/index.js +264 -201
- package/package.json +4 -4
- package/src/components/Accordion/index.tsx +1 -1
- package/src/components/Avatar/AvatarStack/__tests__/StyledAvatarStack.spec.tsx +6 -3
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +9 -9
- package/src/components/Avatar/AvatarStack/__tests__/index.spec.tsx +6 -3
- package/src/components/Avatar/AvatarStack/utils.ts +3 -6
- package/src/components/Card/index.tsx +18 -7
- package/src/components/Select/MultiSelect/index.tsx +5 -2
- package/src/components/Select/SingleSelect/index.tsx +5 -2
- package/src/components/Select/types.ts +15 -6
- package/src/components/Tabs/ScrollableTabs.tsx +2 -0
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +1 -1
- package/src/components/Tabs/__tests__/index.spec.tsx +1 -1
- package/src/components/Tabs/index.tsx +7 -0
- package/src/components/Tag/StyledTag.tsx +42 -11
- package/src/components/Tag/__tests__/Tag.spec.tsx +28 -0
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +135 -0
- package/src/components/Tag/index.tsx +15 -3
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -23
- package/src/theme/components/avatar.ts +0 -23
- package/src/theme/components/tag.ts +1 -0
- package/src/theme/components/toolbar.ts +1 -1
- package/src/theme/global/colors/work.ts +4 -4
- package/src/utils/hooks.ts +18 -1
- package/types/components/Card/index.d.ts +1 -1
- package/types/components/Select/MultiSelect/index.d.ts +1 -1
- package/types/components/Select/SingleSelect/index.d.ts +1 -1
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +15 -3
- package/types/components/Tabs/ScrollableTabs.d.ts +1 -1
- package/types/components/Tabs/index.d.ts +7 -2
- package/types/components/Tag/StyledTag.d.ts +3 -0
- package/types/components/Tag/index.d.ts +7 -2
- package/types/theme/components/avatar.d.ts +0 -1
- package/types/theme/components/tag.d.ts +1 -0
- package/types/utils/hooks.d.ts +2 -0
- package/src/components/Accordion/utils.tsx +0 -11
- package/types/components/Accordion/utils.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.27.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@emotion/native": "^11.9.3",
|
|
22
22
|
"@emotion/react": "^11.9.3",
|
|
23
|
-
"@hero-design/colors": "7.
|
|
23
|
+
"@hero-design/colors": "7.27.1",
|
|
24
24
|
"date-fns": "^2.16.1",
|
|
25
25
|
"events": "^3.2.0",
|
|
26
26
|
"hero-editor": "^1.9.12"
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@types/react-native": "^0.67.7",
|
|
59
59
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
60
60
|
"babel-plugin-inline-import": "^3.0.0",
|
|
61
|
-
"eslint-config-hd": "7.
|
|
61
|
+
"eslint-config-hd": "7.27.1",
|
|
62
62
|
"jest": "^27.3.1",
|
|
63
63
|
"react": "17.0.2",
|
|
64
64
|
"react-native": "0.65.1",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"rollup-plugin-copy": "^3.4.0",
|
|
73
73
|
"rollup-plugin-flow": "^1.1.1",
|
|
74
74
|
"ts-jest": "^27.0.7",
|
|
75
|
-
"prettier-config-hd": "7.
|
|
75
|
+
"prettier-config-hd": "7.27.1",
|
|
76
76
|
"rn-7-23-0": "npm:@hero-design/rn@7.23.0"
|
|
77
77
|
},
|
|
78
78
|
"prettier": "prettier-config-hd"
|
|
@@ -3,7 +3,7 @@ import type { Key, ReactElement } from 'react';
|
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
4
4
|
import AccordionItem from './AccordionItem';
|
|
5
5
|
import { Spacer, StyledWrapper } from './StyledAccordion';
|
|
6
|
-
import { usePropsOrInternalState } from '
|
|
6
|
+
import { usePropsOrInternalState } from '../../utils/hooks';
|
|
7
7
|
|
|
8
8
|
export interface AccordionProps<K extends Key> {
|
|
9
9
|
/**
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderWithTheme from '../../../../testHelpers/renderWithTheme';
|
|
3
3
|
import { StyledWrapper, StyledAvatar } from '../StyledAvatarStack';
|
|
4
|
-
import theme from '../../../../theme';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
jest.spyOn(Math, 'random').mockReturnValue(0.123);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
jest.spyOn(Math, 'random').mockRestore();
|
|
8
11
|
});
|
|
9
12
|
|
|
10
13
|
describe('StyledWrapper', () => {
|
|
@@ -30,7 +30,7 @@ exports[`AvatarStack renders correctly by default 1`] = `
|
|
|
30
30
|
onStartShouldSetResponder={[Function]}
|
|
31
31
|
style={
|
|
32
32
|
Object {
|
|
33
|
-
"backgroundColor": "#
|
|
33
|
+
"backgroundColor": "#48000a",
|
|
34
34
|
"borderRadius": 999,
|
|
35
35
|
"height": 32,
|
|
36
36
|
"left": 0,
|
|
@@ -87,7 +87,7 @@ exports[`AvatarStack renders correctly by default 1`] = `
|
|
|
87
87
|
onStartShouldSetResponder={[Function]}
|
|
88
88
|
style={
|
|
89
89
|
Object {
|
|
90
|
-
"backgroundColor": "#
|
|
90
|
+
"backgroundColor": "#737479",
|
|
91
91
|
"borderRadius": 999,
|
|
92
92
|
"height": 32,
|
|
93
93
|
"left": 22.4,
|
|
@@ -144,7 +144,7 @@ exports[`AvatarStack renders correctly by default 1`] = `
|
|
|
144
144
|
onStartShouldSetResponder={[Function]}
|
|
145
145
|
style={
|
|
146
146
|
Object {
|
|
147
|
-
"backgroundColor": "#
|
|
147
|
+
"backgroundColor": "#001f23",
|
|
148
148
|
"borderRadius": 999,
|
|
149
149
|
"height": 32,
|
|
150
150
|
"left": 44.8,
|
|
@@ -201,7 +201,7 @@ exports[`AvatarStack renders correctly by default 1`] = `
|
|
|
201
201
|
onStartShouldSetResponder={[Function]}
|
|
202
202
|
style={
|
|
203
203
|
Object {
|
|
204
|
-
"backgroundColor": "#
|
|
204
|
+
"backgroundColor": "#353957",
|
|
205
205
|
"borderRadius": 999,
|
|
206
206
|
"height": 32,
|
|
207
207
|
"left": 67.19999999999999,
|
|
@@ -258,7 +258,7 @@ exports[`AvatarStack renders correctly by default 1`] = `
|
|
|
258
258
|
onStartShouldSetResponder={[Function]}
|
|
259
259
|
style={
|
|
260
260
|
Object {
|
|
261
|
-
"backgroundColor": "#
|
|
261
|
+
"backgroundColor": "#25006e",
|
|
262
262
|
"borderRadius": 999,
|
|
263
263
|
"height": 32,
|
|
264
264
|
"left": 89.6,
|
|
@@ -334,7 +334,7 @@ exports[`AvatarStack renders correctly with custom props 1`] = `
|
|
|
334
334
|
onStartShouldSetResponder={[Function]}
|
|
335
335
|
style={
|
|
336
336
|
Object {
|
|
337
|
-
"backgroundColor": "#
|
|
337
|
+
"backgroundColor": "#48000a",
|
|
338
338
|
"borderRadius": 999,
|
|
339
339
|
"height": 40,
|
|
340
340
|
"left": 0,
|
|
@@ -391,7 +391,7 @@ exports[`AvatarStack renders correctly with custom props 1`] = `
|
|
|
391
391
|
onStartShouldSetResponder={[Function]}
|
|
392
392
|
style={
|
|
393
393
|
Object {
|
|
394
|
-
"backgroundColor": "#
|
|
394
|
+
"backgroundColor": "#737479",
|
|
395
395
|
"borderRadius": 999,
|
|
396
396
|
"height": 40,
|
|
397
397
|
"left": 28,
|
|
@@ -448,7 +448,7 @@ exports[`AvatarStack renders correctly with custom props 1`] = `
|
|
|
448
448
|
onStartShouldSetResponder={[Function]}
|
|
449
449
|
style={
|
|
450
450
|
Object {
|
|
451
|
-
"backgroundColor": "#
|
|
451
|
+
"backgroundColor": "#001f23",
|
|
452
452
|
"borderRadius": 999,
|
|
453
453
|
"height": 40,
|
|
454
454
|
"left": 56,
|
|
@@ -505,7 +505,7 @@ exports[`AvatarStack renders correctly with custom props 1`] = `
|
|
|
505
505
|
onStartShouldSetResponder={[Function]}
|
|
506
506
|
style={
|
|
507
507
|
Object {
|
|
508
|
-
"backgroundColor": "#
|
|
508
|
+
"backgroundColor": "#353957",
|
|
509
509
|
"borderRadius": 999,
|
|
510
510
|
"height": 40,
|
|
511
511
|
"left": 84,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderWithTheme from '../../../../testHelpers/renderWithTheme';
|
|
3
3
|
import Avatar from '../..';
|
|
4
|
-
import theme from '../../../../theme';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
jest.spyOn(Math, 'random').mockReturnValue(0.123);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
jest.spyOn(Math, 'random').mockRestore();
|
|
8
11
|
});
|
|
9
12
|
|
|
10
13
|
describe('AvatarStack', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { mobileVisualisationPalette } from '@hero-design/colors';
|
|
3
3
|
|
|
4
4
|
const shuffleArray = <T>(array: Array<T>): Array<T> =>
|
|
5
5
|
array
|
|
@@ -11,12 +11,9 @@ const shuffleArray = <T>(array: Array<T>): Array<T> =>
|
|
|
11
11
|
* Hook that returns a memoized and shuffled array of visualisation colors for Avatar.
|
|
12
12
|
*/
|
|
13
13
|
export const useAvatarColors = () => {
|
|
14
|
-
const theme = useTheme();
|
|
15
|
-
const visualisationColors = theme.__hd__.avatar.colors.visualisation;
|
|
16
14
|
const shuffledColors = useMemo(
|
|
17
|
-
() => shuffleArray(
|
|
18
|
-
[
|
|
15
|
+
() => shuffleArray(Object.values(mobileVisualisationPalette)),
|
|
16
|
+
[]
|
|
19
17
|
);
|
|
20
|
-
|
|
21
18
|
return shuffledColors;
|
|
22
19
|
};
|
|
@@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
|
|
|
3
3
|
import type { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
4
4
|
import DataCard from './DataCard';
|
|
5
5
|
import { StyledCard, LeftDataCard } from './StyledCard';
|
|
6
|
+
import { useDeprecation } from '../../utils/hooks';
|
|
6
7
|
|
|
7
8
|
interface CardProps extends ViewProps {
|
|
8
9
|
/**
|
|
@@ -30,16 +31,26 @@ interface CardProps extends ViewProps {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
const Card = ({
|
|
33
|
-
variant
|
|
34
|
+
variant: _variant,
|
|
34
35
|
intent,
|
|
35
36
|
children,
|
|
36
37
|
...nativeProps
|
|
37
|
-
}: CardProps): JSX.Element =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
}: CardProps): JSX.Element => {
|
|
39
|
+
const variant: CardProps['variant'] =
|
|
40
|
+
_variant === undefined ? 'basic' : _variant;
|
|
41
|
+
|
|
42
|
+
useDeprecation(
|
|
43
|
+
"Card's variant prop is deprecated and will be removed in the next major release.\nPlease remove it or use Card.Data instead.",
|
|
44
|
+
_variant !== undefined
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<StyledCard {...nativeProps} themeVariant={variant} themeIntent={intent}>
|
|
49
|
+
{variant === 'data' && <LeftDataCard testID="data-card-indicator" />}
|
|
50
|
+
{children}
|
|
51
|
+
</StyledCard>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
43
54
|
|
|
44
55
|
export default Object.assign(Card, {
|
|
45
56
|
Data: DataCard,
|
|
@@ -56,6 +56,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
56
56
|
inputProps,
|
|
57
57
|
onConfirm,
|
|
58
58
|
onDimiss,
|
|
59
|
+
onDismiss,
|
|
59
60
|
onEndReached,
|
|
60
61
|
onQueryChange,
|
|
61
62
|
options,
|
|
@@ -65,6 +66,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
65
66
|
error,
|
|
66
67
|
editable = true,
|
|
67
68
|
disabled = false,
|
|
69
|
+
required,
|
|
68
70
|
numberOfLines,
|
|
69
71
|
style,
|
|
70
72
|
testID,
|
|
@@ -98,6 +100,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
98
100
|
}
|
|
99
101
|
<View pointerEvents="none">
|
|
100
102
|
<TextInput
|
|
103
|
+
numberOfLines={numberOfLines}
|
|
101
104
|
{...inputProps}
|
|
102
105
|
label={label}
|
|
103
106
|
value={displayedValue}
|
|
@@ -106,7 +109,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
106
109
|
error={error}
|
|
107
110
|
editable={editable}
|
|
108
111
|
disabled={disabled}
|
|
109
|
-
|
|
112
|
+
required={required}
|
|
110
113
|
pointerEvents="none"
|
|
111
114
|
style={style}
|
|
112
115
|
testID={testID}
|
|
@@ -122,7 +125,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
122
125
|
<BottomSheet
|
|
123
126
|
open={open}
|
|
124
127
|
onRequestClose={() => setOpen(false)}
|
|
125
|
-
onDismiss={onDimiss}
|
|
128
|
+
onDismiss={onDismiss || onDimiss}
|
|
126
129
|
header={label}
|
|
127
130
|
style={{
|
|
128
131
|
paddingBottom: isKeyboardVisible ? keyboardHeight : 0,
|
|
@@ -41,6 +41,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
41
41
|
inputProps,
|
|
42
42
|
onConfirm,
|
|
43
43
|
onDimiss,
|
|
44
|
+
onDismiss,
|
|
44
45
|
onEndReached,
|
|
45
46
|
onQueryChange,
|
|
46
47
|
options,
|
|
@@ -50,6 +51,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
50
51
|
error,
|
|
51
52
|
editable = true,
|
|
52
53
|
disabled = false,
|
|
54
|
+
required,
|
|
53
55
|
numberOfLines,
|
|
54
56
|
style,
|
|
55
57
|
testID,
|
|
@@ -75,6 +77,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
75
77
|
}
|
|
76
78
|
<View pointerEvents="none">
|
|
77
79
|
<TextInput
|
|
80
|
+
numberOfLines={numberOfLines}
|
|
78
81
|
{...inputProps}
|
|
79
82
|
label={label}
|
|
80
83
|
value={displayedValue}
|
|
@@ -83,7 +86,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
83
86
|
error={error}
|
|
84
87
|
editable={editable}
|
|
85
88
|
disabled={disabled}
|
|
86
|
-
|
|
89
|
+
required={required}
|
|
87
90
|
pointerEvents="none"
|
|
88
91
|
style={style}
|
|
89
92
|
testID={testID}
|
|
@@ -99,7 +102,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
99
102
|
<BottomSheet
|
|
100
103
|
open={open}
|
|
101
104
|
onRequestClose={() => setOpen(false)}
|
|
102
|
-
onDismiss={onDimiss}
|
|
105
|
+
onDismiss={onDismiss || onDimiss}
|
|
103
106
|
header={label}
|
|
104
107
|
style={{
|
|
105
108
|
paddingBottom: isKeyboardVisible ? keyboardHeight : 0,
|
|
@@ -39,10 +39,7 @@ export type SectionListRenderOptionInfo<
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export interface SelectProps<V, T extends OptionType<V>>
|
|
42
|
-
extends Pick<
|
|
43
|
-
TextInputProps,
|
|
44
|
-
'editable' | 'disabled' | 'numberOfLines' | 'error'
|
|
45
|
-
> {
|
|
42
|
+
extends Pick<TextInputProps, 'editable' | 'disabled' | 'error' | 'required'> {
|
|
46
43
|
/**
|
|
47
44
|
* An array of options to be selected.
|
|
48
45
|
*/
|
|
@@ -67,9 +64,14 @@ export interface SelectProps<V, T extends OptionType<V>>
|
|
|
67
64
|
*/
|
|
68
65
|
onQueryChange?: (value: string) => void;
|
|
69
66
|
/**
|
|
70
|
-
*
|
|
67
|
+
* @deprecated due to typo.
|
|
68
|
+
* Please use onDismiss instead.
|
|
71
69
|
*/
|
|
72
70
|
onDimiss?: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Event handler when selection dismiss
|
|
73
|
+
*/
|
|
74
|
+
onDismiss?: () => void;
|
|
73
75
|
/**
|
|
74
76
|
* Event handler when end of the list reached
|
|
75
77
|
*/
|
|
@@ -80,8 +82,10 @@ export interface SelectProps<V, T extends OptionType<V>>
|
|
|
80
82
|
loading?: boolean;
|
|
81
83
|
/**
|
|
82
84
|
* Props that are passed to TextInput.
|
|
85
|
+
* Required is deprecated and will be removed in the next major release.
|
|
86
|
+
* Please use the outer required instead.
|
|
83
87
|
*/
|
|
84
|
-
inputProps?: Pick<TextInputProps, 'loading' | 'required'>;
|
|
88
|
+
inputProps?: Pick<TextInputProps, 'loading' | 'required' | 'numberOfLines'>;
|
|
85
89
|
/**
|
|
86
90
|
* Field label.
|
|
87
91
|
*/
|
|
@@ -94,4 +98,9 @@ export interface SelectProps<V, T extends OptionType<V>>
|
|
|
94
98
|
* Testing id of the component.
|
|
95
99
|
*/
|
|
96
100
|
testID?: string;
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated
|
|
103
|
+
* Please use inputProps.numberOfLines instead.
|
|
104
|
+
*/
|
|
105
|
+
numberOfLines?: number;
|
|
97
106
|
}
|
|
@@ -63,6 +63,7 @@ const ScrollableTab = ({
|
|
|
63
63
|
barStyle,
|
|
64
64
|
lazy = false,
|
|
65
65
|
lazyPreloadDistance = 1,
|
|
66
|
+
swipeEnabled = true,
|
|
66
67
|
testID: componentTestID,
|
|
67
68
|
}: TabsProps) => {
|
|
68
69
|
const flatListRef = React.useRef<FlatList>(null);
|
|
@@ -195,6 +196,7 @@ const ScrollableTab = ({
|
|
|
195
196
|
onTabPress(selectedItem.key);
|
|
196
197
|
}
|
|
197
198
|
}}
|
|
199
|
+
scrollEnabled={swipeEnabled}
|
|
198
200
|
>
|
|
199
201
|
{tabs.map((tab, index) => {
|
|
200
202
|
const { key, component, testID } = tab;
|
|
@@ -92,7 +92,7 @@ describe('Tabs.Scroll', () => {
|
|
|
92
92
|
|
|
93
93
|
it('renders correctly with lazy preloaded', () => {
|
|
94
94
|
const { getByText, queryByText, getByTestId } = renderWithTheme(
|
|
95
|
-
<TestTabsComponent lazy lazyPreloadDistance={1} />
|
|
95
|
+
<TestTabsComponent lazy lazyPreloadDistance={1} swipeEnabled={false} />
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
expect(getByText('Work Screen')).toBeDefined();
|
|
@@ -87,7 +87,7 @@ describe('Tabs', () => {
|
|
|
87
87
|
|
|
88
88
|
it('renders correctly with lazy preloaded', () => {
|
|
89
89
|
const { getByText, queryByText } = renderWithTheme(
|
|
90
|
-
<TestTabsComponent lazy lazyPreloadDistance={1} />
|
|
90
|
+
<TestTabsComponent lazy lazyPreloadDistance={1} swipeEnabled={false} />
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
expect(getByText('Work Screen')).toBeDefined();
|
|
@@ -67,6 +67,11 @@ export interface TabsProps extends ViewProps {
|
|
|
67
67
|
* Defaults value is `1`.
|
|
68
68
|
*/
|
|
69
69
|
lazyPreloadDistance?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Boolean indicating whether to enable swipe gestures. Passing `false` will disable swipe gestures, but the user can still switch tabs by pressing the tab bar.
|
|
72
|
+
* Defaults value is `true`.
|
|
73
|
+
*/
|
|
74
|
+
swipeEnabled?: boolean;
|
|
70
75
|
/**
|
|
71
76
|
* Testing id of the component.
|
|
72
77
|
*/
|
|
@@ -105,6 +110,7 @@ const Tabs = ({
|
|
|
105
110
|
barStyle,
|
|
106
111
|
lazy = false,
|
|
107
112
|
lazyPreloadDistance = 1,
|
|
113
|
+
swipeEnabled = true,
|
|
108
114
|
testID: componentTestID,
|
|
109
115
|
}: TabsProps): JSX.Element => {
|
|
110
116
|
const theme = useTheme();
|
|
@@ -207,6 +213,7 @@ const Tabs = ({
|
|
|
207
213
|
useNativeDriver: true,
|
|
208
214
|
}
|
|
209
215
|
)}
|
|
216
|
+
scrollEnabled={swipeEnabled}
|
|
210
217
|
>
|
|
211
218
|
{tabs.map((tab, index) => {
|
|
212
219
|
const { key, component, testID } = tab;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { View, Text } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
|
+
import { Theme } from '../../theme';
|
|
3
4
|
|
|
4
5
|
type ThemeIntent =
|
|
5
6
|
| 'default'
|
|
@@ -10,26 +11,56 @@ type ThemeIntent =
|
|
|
10
11
|
| 'danger'
|
|
11
12
|
| 'archived';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
type ThemeVariant = 'filled' | 'outlined';
|
|
15
|
+
|
|
16
|
+
const getFilledStyles = (themeIntent: ThemeIntent, theme: Theme) => ({
|
|
17
|
+
textColor: theme.__hd__.tag.colors.text,
|
|
18
|
+
borderColor: theme.__hd__.tag.colors[`${themeIntent}Background`],
|
|
19
|
+
backgroundColor: theme.__hd__.tag.colors[`${themeIntent}Background`],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const getOutlinedStyles = (themeIntent: ThemeIntent, theme: Theme) => ({
|
|
23
|
+
textColor: theme.__hd__.tag.colors[themeIntent],
|
|
24
|
+
borderColor: theme.__hd__.tag.colors[themeIntent],
|
|
25
|
+
backgroundColor: theme.__hd__.tag.colors[`${themeIntent}Background`],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const StyledView = styled(View)<{
|
|
29
|
+
themeIntent: ThemeIntent;
|
|
30
|
+
themeVariant: ThemeVariant;
|
|
31
|
+
}>(({ themeIntent, themeVariant, theme }) => {
|
|
32
|
+
const { borderColor, backgroundColor } =
|
|
33
|
+
themeVariant === 'filled'
|
|
34
|
+
? getFilledStyles(themeIntent, theme)
|
|
35
|
+
: getOutlinedStyles(themeIntent, theme);
|
|
36
|
+
|
|
37
|
+
return {
|
|
15
38
|
borderWidth: theme.__hd__.tag.borderWidths.default,
|
|
16
39
|
borderRadius: theme.__hd__.tag.radii.default,
|
|
17
40
|
paddingVertical: theme.__hd__.tag.space.verticalPadding,
|
|
18
41
|
paddingHorizontal: theme.__hd__.tag.space.horizontalPadding,
|
|
19
|
-
borderColor
|
|
20
|
-
backgroundColor
|
|
21
|
-
}
|
|
22
|
-
);
|
|
42
|
+
borderColor,
|
|
43
|
+
backgroundColor,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const StyledText = styled(Text)<{
|
|
48
|
+
themeIntent: ThemeIntent;
|
|
49
|
+
themeVariant: ThemeVariant;
|
|
50
|
+
}>(({ themeIntent, themeVariant, theme }) => {
|
|
51
|
+
const { textColor } =
|
|
52
|
+
themeVariant === 'filled'
|
|
53
|
+
? getFilledStyles(themeIntent, theme)
|
|
54
|
+
: getOutlinedStyles(themeIntent, theme);
|
|
23
55
|
|
|
24
|
-
|
|
25
|
-
({ themeIntent, theme }) => ({
|
|
56
|
+
return {
|
|
26
57
|
fontFamily: theme.__hd__.tag.fonts.default,
|
|
27
58
|
fontSize: theme.__hd__.tag.fontSizes.default,
|
|
28
|
-
color:
|
|
59
|
+
color: textColor,
|
|
29
60
|
includeFontPadding: false,
|
|
30
61
|
textAlignVertical: 'center',
|
|
31
62
|
textAlign: 'center',
|
|
32
|
-
}
|
|
33
|
-
);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
34
65
|
|
|
35
66
|
export { StyledView, StyledText };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
3
|
import Tag from '..';
|
|
4
|
+
import Typography from '../../Typography';
|
|
4
5
|
|
|
5
6
|
describe('Tag', () => {
|
|
6
7
|
it('has success style when intent is success', () => {
|
|
@@ -65,4 +66,31 @@ describe('Tag', () => {
|
|
|
65
66
|
expect(toJSON()).toMatchSnapshot();
|
|
66
67
|
expect(getByText('PRIMARY')).toBeDefined();
|
|
67
68
|
});
|
|
69
|
+
|
|
70
|
+
it('renders correctly when variant is filled and intent is warning', () => {
|
|
71
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
72
|
+
<Tag content="WARNING" intent="warning" variant="filled" />
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
expect(toJSON()).toMatchSnapshot();
|
|
76
|
+
expect(getByText('WARNING')).toBeDefined();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('renders correctly when variant is filled and intent is danger', () => {
|
|
80
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
81
|
+
<Tag content="DANGER" intent="danger" variant="filled" />
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(toJSON()).toMatchSnapshot();
|
|
85
|
+
expect(getByText('DANGER')).toBeDefined();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('renders correctly with custom content', () => {
|
|
89
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
90
|
+
<Tag content={<Typography.Text>Custom Content</Typography.Text>} />
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
expect(toJSON()).toMatchSnapshot();
|
|
94
|
+
expect(getByText('Custom Content')).toBeDefined();
|
|
95
|
+
});
|
|
68
96
|
});
|