@hero-design/rn 8.69.0 → 8.70.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 +3 -3
- package/CHANGELOG.md +17 -0
- package/es/index.js +67 -80
- package/lib/index.js +67 -80
- package/package.json +2 -2
- package/src/components/Card/StyledCard.tsx +6 -2
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +1 -1
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +7 -0
- package/src/components/Card/__tests__/index.spec.tsx +12 -0
- package/src/components/Card/index.tsx +8 -2
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +4 -0
- package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +1 -0
- package/src/components/Chip/StyledChip.tsx +15 -45
- package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +145 -389
- package/src/components/Chip/__tests__/index.spec.tsx +6 -26
- package/src/components/Chip/index.tsx +26 -33
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +9 -6
- package/src/theme/components/card.ts +1 -0
- package/src/theme/components/chip.ts +8 -6
- package/src/theme/global/colors/__tests__/__snapshots__/swagLight.spec.ts.snap +5 -5
- package/src/theme/global/colors/__tests__/__snapshots__/swagLightGlobal.spec.ts.snap +39 -0
- package/src/theme/global/colors/__tests__/__snapshots__/swagLightJobs.spec.ts.snap +5 -5
- package/src/theme/global/colors/__tests__/swagLightGlobal.spec.ts +7 -0
- package/src/theme/global/colors/swagLight.ts +2 -2
- package/src/theme/global/colors/swagLightGlobal.ts +14 -0
- package/stats/8.70.0/rn-stats.html +4842 -0
- package/types/components/Card/StyledCard.d.ts +1 -0
- package/types/components/Card/index.d.ts +2 -1
- package/types/components/Chip/StyledChip.d.ts +1 -19
- package/types/components/Chip/index.d.ts +6 -2
- package/types/theme/components/card.d.ts +1 -0
- package/types/theme/components/chip.d.ts +8 -6
- package/types/theme/global/colors/swagLightGlobal.d.ts +3 -0
|
@@ -35,41 +35,21 @@ describe('Chip', () => {
|
|
|
35
35
|
<ChipWithoutIcon />
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
expect(queryByTestId('chip-icon-
|
|
38
|
+
expect(queryByTestId('selected-chip-icon-cancel')).toBeFalsy();
|
|
39
39
|
expect(toJSON()).toMatchSnapshot();
|
|
40
40
|
|
|
41
41
|
fireEvent.press(getByTestId('chip'));
|
|
42
42
|
|
|
43
|
-
expect(getByTestId('chip-icon-
|
|
43
|
+
expect(getByTestId('selected-chip-icon-cancel')).toBeTruthy();
|
|
44
44
|
expect(toJSON()).toMatchSnapshot();
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it('does not render icon when
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Chip
|
|
53
|
-
label="Cover my bills"
|
|
54
|
-
testID="chip"
|
|
55
|
-
icon="charging-station-outlined"
|
|
56
|
-
selected={selected}
|
|
57
|
-
variant="outlined"
|
|
58
|
-
onPress={() => setSelected(!selected)}
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const { getByTestId, toJSON, queryByTestId } = renderWithTheme(
|
|
64
|
-
<ChipWithIcon />
|
|
47
|
+
it('does not render selected icon when showSelectedIcon is false', () => {
|
|
48
|
+
const { toJSON, queryByTestId } = renderWithTheme(
|
|
49
|
+
<Chip label="Chip" showSelectedIcon={false} selected />
|
|
65
50
|
);
|
|
66
51
|
|
|
67
|
-
expect(queryByTestId('chip-icon-
|
|
68
|
-
expect(toJSON()).toMatchSnapshot();
|
|
69
|
-
|
|
70
|
-
fireEvent.press(getByTestId('chip'));
|
|
71
|
-
|
|
72
|
-
expect(queryByTestId('chip-icon-charging-station-outlined')).toBeFalsy();
|
|
52
|
+
expect(queryByTestId('chip-icon-checkmark')).toBeFalsy();
|
|
73
53
|
expect(toJSON()).toMatchSnapshot();
|
|
74
54
|
});
|
|
75
55
|
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
StyledIconWrapper,
|
|
8
|
-
StyledLabel,
|
|
9
|
-
} from './StyledChip';
|
|
3
|
+
import Box from '../Box';
|
|
4
|
+
import Icon, { IconName } from '../Icon';
|
|
5
|
+
import Typography from '../Typography';
|
|
6
|
+
import { StyledChipWrapper } from './StyledChip';
|
|
10
7
|
|
|
11
8
|
export interface ChipProps extends ViewProps {
|
|
12
9
|
/**
|
|
@@ -22,13 +19,17 @@ export interface ChipProps extends ViewProps {
|
|
|
22
19
|
*/
|
|
23
20
|
selected?: boolean;
|
|
24
21
|
/**
|
|
25
|
-
* Icon of the chip.
|
|
22
|
+
* Icon of the chip.
|
|
26
23
|
*/
|
|
27
24
|
icon?: IconName;
|
|
28
25
|
/**
|
|
29
26
|
* Callback when the chip is pressed.
|
|
30
27
|
*/
|
|
31
28
|
onPress?: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to show the selected icon when using outlined variant.
|
|
31
|
+
*/
|
|
32
|
+
showSelectedIcon?: boolean;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const Chip = ({
|
|
@@ -37,17 +38,11 @@ const Chip = ({
|
|
|
37
38
|
selected = false,
|
|
38
39
|
icon,
|
|
39
40
|
onPress,
|
|
41
|
+
showSelectedIcon = true,
|
|
40
42
|
...otherProps
|
|
41
43
|
}: ChipProps) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
return icon;
|
|
45
|
-
}
|
|
46
|
-
if (selected) {
|
|
47
|
-
return 'checkmark';
|
|
48
|
-
}
|
|
49
|
-
return undefined;
|
|
50
|
-
}, [icon, selected, variant]);
|
|
44
|
+
const shouldShowSelectedIcon =
|
|
45
|
+
variant === 'outlined' && selected && showSelectedIcon;
|
|
51
46
|
|
|
52
47
|
return (
|
|
53
48
|
<StyledChipWrapper
|
|
@@ -56,25 +51,23 @@ const Chip = ({
|
|
|
56
51
|
themeSelected={selected}
|
|
57
52
|
{...otherProps}
|
|
58
53
|
>
|
|
59
|
-
{
|
|
60
|
-
<
|
|
61
|
-
<
|
|
54
|
+
{icon && (
|
|
55
|
+
<Box marginRight="small">
|
|
56
|
+
<Icon size="xsmall" icon={icon} testID={`chip-icon-${icon}`} />
|
|
57
|
+
</Box>
|
|
58
|
+
)}
|
|
59
|
+
|
|
60
|
+
<Typography.Body>{label}</Typography.Body>
|
|
61
|
+
|
|
62
|
+
{shouldShowSelectedIcon && (
|
|
63
|
+
<Box marginLeft="small">
|
|
64
|
+
<Icon
|
|
62
65
|
size="xsmall"
|
|
63
|
-
icon=
|
|
64
|
-
|
|
65
|
-
themeVariant={variant}
|
|
66
|
-
testID={`chip-icon-${internalIcon}`}
|
|
66
|
+
icon="cancel"
|
|
67
|
+
testID="selected-chip-icon-cancel"
|
|
67
68
|
/>
|
|
68
|
-
</
|
|
69
|
+
</Box>
|
|
69
70
|
)}
|
|
70
|
-
|
|
71
|
-
<StyledLabel
|
|
72
|
-
variant="small"
|
|
73
|
-
themeVariant={variant}
|
|
74
|
-
themeSelected={selected}
|
|
75
|
-
>
|
|
76
|
-
{label}
|
|
77
|
-
</StyledLabel>
|
|
78
71
|
</StyledChipWrapper>
|
|
79
72
|
);
|
|
80
73
|
};
|
|
@@ -310,6 +310,7 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
310
310
|
},
|
|
311
311
|
"radii": {
|
|
312
312
|
"default": 12,
|
|
313
|
+
"superRound": 24,
|
|
313
314
|
},
|
|
314
315
|
"sizes": {
|
|
315
316
|
"indicatorWidth": 16,
|
|
@@ -379,11 +380,11 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
379
380
|
},
|
|
380
381
|
"colors": {
|
|
381
382
|
"filledBackground": "#ffffff",
|
|
382
|
-
"
|
|
383
|
-
"
|
|
383
|
+
"outlinedDefaultBackground": "#ffffff",
|
|
384
|
+
"outlinedDefaultBorder": "#bfc1c5",
|
|
385
|
+
"outlinedSelectedBackground": "#e8e9ea",
|
|
386
|
+
"outlinedSelectedBorder": "#001f23",
|
|
384
387
|
"secondaryBackground": "#ece8ef",
|
|
385
|
-
"selectedPrimaryText": "#ffffff",
|
|
386
|
-
"wrapperBorder": "#001f23",
|
|
387
388
|
"wrapperSelectedBorder": "transparent",
|
|
388
389
|
},
|
|
389
390
|
"radii": {
|
|
@@ -402,10 +403,12 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
402
403
|
},
|
|
403
404
|
},
|
|
404
405
|
"sizes": {
|
|
405
|
-
"
|
|
406
|
+
"outlinedDefaultBorder": 1,
|
|
407
|
+
"outlinedSelectedBorder": 2,
|
|
406
408
|
},
|
|
407
409
|
"space": {
|
|
408
|
-
"
|
|
410
|
+
"iconWrapperHorizontalMargin": 8,
|
|
411
|
+
"outlinedSelectedMarginTop": -2,
|
|
409
412
|
"wrapperHorizontalPadding": 12,
|
|
410
413
|
"wrapperVerticalPadding": 8,
|
|
411
414
|
},
|
|
@@ -2,23 +2,25 @@ import type { GlobalTheme } from '../global';
|
|
|
2
2
|
|
|
3
3
|
const getChipTheme = (theme: GlobalTheme) => {
|
|
4
4
|
const colors = {
|
|
5
|
-
primaryBackground: theme.colors.darkGlobalSurface,
|
|
6
5
|
secondaryBackground: theme.colors.highlightedSurface,
|
|
7
6
|
filledBackground: theme.colors.defaultGlobalSurface,
|
|
8
|
-
outlinedBackground: 'transparent',
|
|
9
|
-
wrapperBorder: theme.colors.primaryOutline,
|
|
10
7
|
wrapperSelectedBorder: 'transparent',
|
|
11
|
-
|
|
8
|
+
outlinedDefaultBackground: theme.colors.defaultGlobalSurface,
|
|
9
|
+
outlinedSelectedBackground: theme.colors.secondaryOutline,
|
|
10
|
+
outlinedSelectedBorder: theme.colors.primaryOutline,
|
|
11
|
+
outlinedDefaultBorder: theme.colors.disabledOnDefaultGlobalSurface,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const space = {
|
|
15
15
|
wrapperHorizontalPadding: theme.space.smallMedium,
|
|
16
16
|
wrapperVerticalPadding: theme.space.small,
|
|
17
|
-
|
|
17
|
+
iconWrapperHorizontalMargin: theme.space.small,
|
|
18
|
+
outlinedSelectedMarginTop: -theme.space.xxsmall,
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
const sizes = {
|
|
21
|
-
|
|
22
|
+
outlinedDefaultBorder: theme.borderWidths.base,
|
|
23
|
+
outlinedSelectedBorder: theme.borderWidths.medium,
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const radii = {
|
|
@@ -14,20 +14,20 @@ exports[`swagDark returns correct theme object 1`] = `
|
|
|
14
14
|
"error": "#f46363",
|
|
15
15
|
"errorSurface": "#fcebe7",
|
|
16
16
|
"highlightedSurface": "#f1e9fb",
|
|
17
|
-
"inactiveOnDefaultGlobalSurface": "#
|
|
18
|
-
"inactiveOutline": "#
|
|
17
|
+
"inactiveOnDefaultGlobalSurface": "#89898a",
|
|
18
|
+
"inactiveOutline": "#89898a",
|
|
19
19
|
"info": "#b5c3fd",
|
|
20
20
|
"infoSurface": "#ecf0ff",
|
|
21
21
|
"mutedArchived": "#bcbdbf",
|
|
22
22
|
"mutedError": "#f68282",
|
|
23
23
|
"mutedInfo": "#c4cffd",
|
|
24
|
-
"mutedOnDefaultGlobalSurface": "#
|
|
24
|
+
"mutedOnDefaultGlobalSurface": "#59595b",
|
|
25
25
|
"mutedSuccess": "#7bd897",
|
|
26
26
|
"mutedWarning": "#ffcb8d",
|
|
27
27
|
"neutralGlobalSurface": "#f6f6f7",
|
|
28
28
|
"onArchivedSurface": "#606065",
|
|
29
29
|
"onDarkGlobalSurface": "#ffffff",
|
|
30
|
-
"onDefaultGlobalSurface": "#
|
|
30
|
+
"onDefaultGlobalSurface": "#121214",
|
|
31
31
|
"onErrorSurface": "#cb300a",
|
|
32
32
|
"onInfoSurface": "#355bfb",
|
|
33
33
|
"onPrimary": "#fdfbff",
|
|
@@ -37,7 +37,7 @@ exports[`swagDark returns correct theme object 1`] = `
|
|
|
37
37
|
"overlayGlobalSurface": "#000000",
|
|
38
38
|
"pressedSurface": "#380060",
|
|
39
39
|
"primary": "#460078",
|
|
40
|
-
"primaryOutline": "#
|
|
40
|
+
"primaryOutline": "#121214",
|
|
41
41
|
"secondary": "#b382fd",
|
|
42
42
|
"secondaryOutline": "#e8e9ea",
|
|
43
43
|
"success": "#5ace7d",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`swagLightGlobal returns correct theme object 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"archived": "#abacaf",
|
|
6
|
+
"archivedSurface": "#dadbde",
|
|
7
|
+
"darkGlobalSurface": "#001f23",
|
|
8
|
+
"defaultGlobalSurface": "#ffffff",
|
|
9
|
+
"disabledOnDefaultGlobalSurface": "#bfc1c5",
|
|
10
|
+
"disabledOutline": "#bfc1c5",
|
|
11
|
+
"error": "#f46363",
|
|
12
|
+
"errorSurface": "#fcebe7",
|
|
13
|
+
"inactiveOnDefaultGlobalSurface": "#89898a",
|
|
14
|
+
"inactiveOutline": "#89898a",
|
|
15
|
+
"info": "#b5c3fd",
|
|
16
|
+
"infoSurface": "#ecf0ff",
|
|
17
|
+
"mutedArchived": "#bcbdbf",
|
|
18
|
+
"mutedError": "#f68282",
|
|
19
|
+
"mutedInfo": "#c4cffd",
|
|
20
|
+
"mutedOnDefaultGlobalSurface": "#59595b",
|
|
21
|
+
"mutedSuccess": "#7bd897",
|
|
22
|
+
"mutedWarning": "#ffcb8d",
|
|
23
|
+
"neutralGlobalSurface": "#f6f6f7",
|
|
24
|
+
"onArchivedSurface": "#606065",
|
|
25
|
+
"onDarkGlobalSurface": "#ffffff",
|
|
26
|
+
"onDefaultGlobalSurface": "#121214",
|
|
27
|
+
"onErrorSurface": "#cb300a",
|
|
28
|
+
"onInfoSurface": "#355bfb",
|
|
29
|
+
"onSuccessSurface": "#017d6d",
|
|
30
|
+
"onWarningSurface": "#ac5d00",
|
|
31
|
+
"overlayGlobalSurface": "#000000",
|
|
32
|
+
"primaryOutline": "#121214",
|
|
33
|
+
"secondaryOutline": "#e8e9ea",
|
|
34
|
+
"success": "#5ace7d",
|
|
35
|
+
"successSurface": "#f0fef4",
|
|
36
|
+
"warning": "#ffbe71",
|
|
37
|
+
"warningSurface": "#fff6eb",
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
@@ -16,20 +16,20 @@ exports[`swagLightJobs returns correct theme object 1`] = `
|
|
|
16
16
|
"error": "#f46363",
|
|
17
17
|
"errorSurface": "#fcebe7",
|
|
18
18
|
"highlightedSurface": "#f1e9fb",
|
|
19
|
-
"inactiveOnDefaultGlobalSurface": "#
|
|
20
|
-
"inactiveOutline": "#
|
|
19
|
+
"inactiveOnDefaultGlobalSurface": "#89898a",
|
|
20
|
+
"inactiveOutline": "#89898a",
|
|
21
21
|
"info": "#b5c3fd",
|
|
22
22
|
"infoSurface": "#ecf0ff",
|
|
23
23
|
"mutedArchived": "#bcbdbf",
|
|
24
24
|
"mutedError": "#f68282",
|
|
25
25
|
"mutedInfo": "#c4cffd",
|
|
26
|
-
"mutedOnDefaultGlobalSurface": "#
|
|
26
|
+
"mutedOnDefaultGlobalSurface": "#59595b",
|
|
27
27
|
"mutedSuccess": "#7bd897",
|
|
28
28
|
"mutedWarning": "#ffcb8d",
|
|
29
29
|
"neutralGlobalSurface": "#f6f6f7",
|
|
30
30
|
"onArchivedSurface": "#606065",
|
|
31
31
|
"onDarkGlobalSurface": "#ffffff",
|
|
32
|
-
"onDefaultGlobalSurface": "#
|
|
32
|
+
"onDefaultGlobalSurface": "#121214",
|
|
33
33
|
"onErrorSurface": "#cb300a",
|
|
34
34
|
"onInfoSurface": "#355bfb",
|
|
35
35
|
"onPrimary": "#fdfbff",
|
|
@@ -39,7 +39,7 @@ exports[`swagLightJobs returns correct theme object 1`] = `
|
|
|
39
39
|
"overlayGlobalSurface": "#000000",
|
|
40
40
|
"pressedSurface": "#380060",
|
|
41
41
|
"primary": "#460078",
|
|
42
|
-
"primaryOutline": "#
|
|
42
|
+
"primaryOutline": "#121214",
|
|
43
43
|
"secondary": "#40d1ff",
|
|
44
44
|
"secondaryOutline": "#e8e9ea",
|
|
45
45
|
"success": "#5ace7d",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { swagLightPalette as palette } from '@hero-design/colors';
|
|
2
2
|
import type { SystemPalette, BrandSystemPalette } from './types';
|
|
3
|
-
import
|
|
3
|
+
import swagLightGlobalPalette from './swagLightGlobal';
|
|
4
4
|
|
|
5
5
|
const swagBrandSystemPallete: BrandSystemPalette = {
|
|
6
6
|
primary: '#460078',
|
|
@@ -16,7 +16,7 @@ const swagBrandSystemPallete: BrandSystemPalette = {
|
|
|
16
16
|
|
|
17
17
|
const swagSystemPalette: SystemPalette = {
|
|
18
18
|
// Global
|
|
19
|
-
...
|
|
19
|
+
...swagLightGlobalPalette,
|
|
20
20
|
// Brand
|
|
21
21
|
...swagBrandSystemPallete,
|
|
22
22
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { swagLightPalette as palette } from '@hero-design/colors';
|
|
2
|
+
import type { GlobalSystemPalette } from './types';
|
|
3
|
+
import globalPalette from './global';
|
|
4
|
+
|
|
5
|
+
const swagLightGlobalPalette: GlobalSystemPalette = {
|
|
6
|
+
...globalPalette,
|
|
7
|
+
onDefaultGlobalSurface: palette.offBlack,
|
|
8
|
+
mutedOnDefaultGlobalSurface: palette.offBlackLight30,
|
|
9
|
+
inactiveOnDefaultGlobalSurface: palette.offBlackLight50,
|
|
10
|
+
primaryOutline: palette.offBlack,
|
|
11
|
+
inactiveOutline: palette.offBlackLight50,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default swagLightGlobalPalette;
|