@hero-design/rn 8.119.0 → 8.119.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/CHANGELOG.md +8 -0
- package/es/index.js +31 -7
- package/lib/index.js +31 -7
- package/package.json +1 -1
- package/src/components/Badge/StyledBadge.tsx +38 -19
- package/src/components/Badge/index.tsx +9 -1
- package/src/theme/components/badge.ts +16 -0
- package/src/theme/components/tag.ts +1 -1
- package/types/components/Badge/StyledBadge.d.ts +3 -0
- package/types/theme/components/badge.d.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.119.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4871](https://github.com/Thinkei/hero-design/pull/4871) [`bc9741dbf1dcb5a8176a14bfe85c19a70c50d283`](https://github.com/Thinkei/hero-design/commit/bc9741dbf1dcb5a8176a14bfe85c19a70c50d283) Thanks [@ngvuthanhnhan-eh-hi](https://github.com/ngvuthanhnhan-eh-hi)! - [Tag] Update border-radius from 4px (`radii.base`) to 12px (`radii.large`)
|
|
8
|
+
|
|
9
|
+
- [#4872](https://github.com/Thinkei/hero-design/pull/4872) [`611662ff1d9a1ebe799a6c4a06935b51d6795da2`](https://github.com/Thinkei/hero-design/commit/611662ff1d9a1ebe799a6c4a06935b51d6795da2) Thanks [@ngvuthanhnhan-eh-hi](https://github.com/ngvuthanhnhan-eh-hi)! - [Badge] Align string-Badge intent colors with surface-based token
|
|
10
|
+
|
|
3
11
|
## 8.119.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/es/index.js
CHANGED
|
@@ -5604,7 +5604,23 @@ var getBadgeTheme = function getBadgeTheme(theme) {
|
|
|
5604
5604
|
archived: theme.colors.onArchivedSurface,
|
|
5605
5605
|
text: theme.colors.onDarkGlobalSurface,
|
|
5606
5606
|
border: theme.colors.defaultGlobalSurface,
|
|
5607
|
-
countText: theme.colors.onDarkGlobalSurface
|
|
5607
|
+
countText: theme.colors.onDarkGlobalSurface,
|
|
5608
|
+
stringBackground: {
|
|
5609
|
+
primary: theme.colors.highlightedSurface,
|
|
5610
|
+
danger: theme.colors.errorSurface,
|
|
5611
|
+
info: theme.colors.infoSurface,
|
|
5612
|
+
success: theme.colors.successSurface,
|
|
5613
|
+
warning: theme.colors.warningSurface,
|
|
5614
|
+
archived: theme.colors.archivedSurface
|
|
5615
|
+
},
|
|
5616
|
+
stringText: {
|
|
5617
|
+
primary: theme.colors.primary,
|
|
5618
|
+
danger: theme.colors.onErrorSurface,
|
|
5619
|
+
info: theme.colors.onInfoSurface,
|
|
5620
|
+
success: theme.colors.onSuccessSurface,
|
|
5621
|
+
warning: theme.colors.onWarningSurface,
|
|
5622
|
+
archived: theme.colors.onArchivedSurface
|
|
5623
|
+
}
|
|
5608
5624
|
};
|
|
5609
5625
|
var fonts = {
|
|
5610
5626
|
medium: theme.fonts.neutral.regular,
|
|
@@ -7098,7 +7114,7 @@ var getTagTheme = function getTagTheme(theme) {
|
|
|
7098
7114
|
verticalPadding: theme.space.xsmall
|
|
7099
7115
|
};
|
|
7100
7116
|
var radii = {
|
|
7101
|
-
"default": theme.radii.
|
|
7117
|
+
"default": theme.radii.large
|
|
7102
7118
|
};
|
|
7103
7119
|
return {
|
|
7104
7120
|
borderWidths: borderWidths,
|
|
@@ -10046,27 +10062,31 @@ var StyledView$2 = index$c(Animated.View)(function (_ref) {
|
|
|
10046
10062
|
themePadding = _ref.themePadding,
|
|
10047
10063
|
themeSize = _ref.themeSize,
|
|
10048
10064
|
themeVariant = _ref.themeVariant,
|
|
10065
|
+
themeIsStringBadge = _ref.themeIsStringBadge,
|
|
10049
10066
|
theme = _ref.theme;
|
|
10067
|
+
var backgroundColor = themeIsStringBadge ? theme.__hd__.badge.colors.stringBackground[themeIntent] : theme.__hd__.badge.colors[themeIntent];
|
|
10050
10068
|
return {
|
|
10051
10069
|
height: theme.__hd__.badge.sizes[themeSize].height,
|
|
10052
10070
|
minWidth: theme.__hd__.badge.sizes[themeSize].minWidth,
|
|
10053
10071
|
alignItems: 'center',
|
|
10054
10072
|
justifyContent: 'center',
|
|
10055
|
-
backgroundColor:
|
|
10073
|
+
backgroundColor: backgroundColor,
|
|
10056
10074
|
borderRadius: theme.radii.rounded,
|
|
10057
10075
|
paddingHorizontal: themePadding === 'wideContent' ? theme.__hd__.badge.space[themeSize].horizontalPadding : undefined,
|
|
10058
10076
|
borderWidth: theme.__hd__.badge.borderWidths["default"],
|
|
10059
|
-
borderColor: themeVariant === 'outlined' ? theme.__hd__.badge.colors.border :
|
|
10077
|
+
borderColor: themeVariant === 'outlined' ? theme.__hd__.badge.colors.border : backgroundColor
|
|
10060
10078
|
};
|
|
10061
10079
|
});
|
|
10062
10080
|
var StyledText$2 = index$c(Typography.Caption)(function (_ref2) {
|
|
10063
10081
|
var theme = _ref2.theme,
|
|
10064
|
-
themeSize = _ref2.themeSize
|
|
10082
|
+
themeSize = _ref2.themeSize,
|
|
10083
|
+
themeIntent = _ref2.themeIntent,
|
|
10084
|
+
themeIsStringBadge = _ref2.themeIsStringBadge;
|
|
10065
10085
|
return {
|
|
10066
10086
|
fontSize: theme.__hd__.badge.fontSizes[themeSize],
|
|
10067
10087
|
lineHeight: theme.__hd__.badge.lineHeights[themeSize],
|
|
10068
10088
|
fontFamily: theme.__hd__.badge.fonts[themeSize],
|
|
10069
|
-
color: theme.__hd__.badge.colors.text,
|
|
10089
|
+
color: themeIsStringBadge ? theme.__hd__.badge.colors.stringText[themeIntent] : theme.__hd__.badge.colors.text,
|
|
10070
10090
|
includeFontPadding: false,
|
|
10071
10091
|
textAlignVertical: 'center',
|
|
10072
10092
|
textAlign: 'center'
|
|
@@ -10224,6 +10244,7 @@ var Badge$1 = function Badge(_ref) {
|
|
|
10224
10244
|
}).start();
|
|
10225
10245
|
}, [visible, opacity]);
|
|
10226
10246
|
var isIconBadge = !!icon;
|
|
10247
|
+
var isStringBadge = !isIconBadge && typeof originalContent === 'string';
|
|
10227
10248
|
var content = useMemo(function () {
|
|
10228
10249
|
if (isIconBadge) {
|
|
10229
10250
|
return '';
|
|
@@ -10235,6 +10256,7 @@ var Badge$1 = function Badge(_ref) {
|
|
|
10235
10256
|
themePadding: getPaddingState(content),
|
|
10236
10257
|
themeSize: size,
|
|
10237
10258
|
themeVariant: variant,
|
|
10259
|
+
themeIsStringBadge: isStringBadge,
|
|
10238
10260
|
style: [{
|
|
10239
10261
|
opacity: opacity,
|
|
10240
10262
|
transform: [{
|
|
@@ -10250,7 +10272,9 @@ var Badge$1 = function Badge(_ref) {
|
|
|
10250
10272
|
themeSize: size,
|
|
10251
10273
|
intent: "text-inverted"
|
|
10252
10274
|
}) : /*#__PURE__*/React__default.createElement(StyledText$2, {
|
|
10253
|
-
themeSize: size
|
|
10275
|
+
themeSize: size,
|
|
10276
|
+
themeIntent: intent,
|
|
10277
|
+
themeIsStringBadge: isStringBadge
|
|
10254
10278
|
}, content));
|
|
10255
10279
|
};
|
|
10256
10280
|
var Badge = Object.assign(Badge$1, {
|
package/lib/index.js
CHANGED
|
@@ -5633,7 +5633,23 @@ var getBadgeTheme = function getBadgeTheme(theme) {
|
|
|
5633
5633
|
archived: theme.colors.onArchivedSurface,
|
|
5634
5634
|
text: theme.colors.onDarkGlobalSurface,
|
|
5635
5635
|
border: theme.colors.defaultGlobalSurface,
|
|
5636
|
-
countText: theme.colors.onDarkGlobalSurface
|
|
5636
|
+
countText: theme.colors.onDarkGlobalSurface,
|
|
5637
|
+
stringBackground: {
|
|
5638
|
+
primary: theme.colors.highlightedSurface,
|
|
5639
|
+
danger: theme.colors.errorSurface,
|
|
5640
|
+
info: theme.colors.infoSurface,
|
|
5641
|
+
success: theme.colors.successSurface,
|
|
5642
|
+
warning: theme.colors.warningSurface,
|
|
5643
|
+
archived: theme.colors.archivedSurface
|
|
5644
|
+
},
|
|
5645
|
+
stringText: {
|
|
5646
|
+
primary: theme.colors.primary,
|
|
5647
|
+
danger: theme.colors.onErrorSurface,
|
|
5648
|
+
info: theme.colors.onInfoSurface,
|
|
5649
|
+
success: theme.colors.onSuccessSurface,
|
|
5650
|
+
warning: theme.colors.onWarningSurface,
|
|
5651
|
+
archived: theme.colors.onArchivedSurface
|
|
5652
|
+
}
|
|
5637
5653
|
};
|
|
5638
5654
|
var fonts = {
|
|
5639
5655
|
medium: theme.fonts.neutral.regular,
|
|
@@ -7127,7 +7143,7 @@ var getTagTheme = function getTagTheme(theme) {
|
|
|
7127
7143
|
verticalPadding: theme.space.xsmall
|
|
7128
7144
|
};
|
|
7129
7145
|
var radii = {
|
|
7130
|
-
"default": theme.radii.
|
|
7146
|
+
"default": theme.radii.large
|
|
7131
7147
|
};
|
|
7132
7148
|
return {
|
|
7133
7149
|
borderWidths: borderWidths,
|
|
@@ -10075,27 +10091,31 @@ var StyledView$2 = index$c(reactNative.Animated.View)(function (_ref) {
|
|
|
10075
10091
|
themePadding = _ref.themePadding,
|
|
10076
10092
|
themeSize = _ref.themeSize,
|
|
10077
10093
|
themeVariant = _ref.themeVariant,
|
|
10094
|
+
themeIsStringBadge = _ref.themeIsStringBadge,
|
|
10078
10095
|
theme = _ref.theme;
|
|
10096
|
+
var backgroundColor = themeIsStringBadge ? theme.__hd__.badge.colors.stringBackground[themeIntent] : theme.__hd__.badge.colors[themeIntent];
|
|
10079
10097
|
return {
|
|
10080
10098
|
height: theme.__hd__.badge.sizes[themeSize].height,
|
|
10081
10099
|
minWidth: theme.__hd__.badge.sizes[themeSize].minWidth,
|
|
10082
10100
|
alignItems: 'center',
|
|
10083
10101
|
justifyContent: 'center',
|
|
10084
|
-
backgroundColor:
|
|
10102
|
+
backgroundColor: backgroundColor,
|
|
10085
10103
|
borderRadius: theme.radii.rounded,
|
|
10086
10104
|
paddingHorizontal: themePadding === 'wideContent' ? theme.__hd__.badge.space[themeSize].horizontalPadding : undefined,
|
|
10087
10105
|
borderWidth: theme.__hd__.badge.borderWidths["default"],
|
|
10088
|
-
borderColor: themeVariant === 'outlined' ? theme.__hd__.badge.colors.border :
|
|
10106
|
+
borderColor: themeVariant === 'outlined' ? theme.__hd__.badge.colors.border : backgroundColor
|
|
10089
10107
|
};
|
|
10090
10108
|
});
|
|
10091
10109
|
var StyledText$2 = index$c(Typography.Caption)(function (_ref2) {
|
|
10092
10110
|
var theme = _ref2.theme,
|
|
10093
|
-
themeSize = _ref2.themeSize
|
|
10111
|
+
themeSize = _ref2.themeSize,
|
|
10112
|
+
themeIntent = _ref2.themeIntent,
|
|
10113
|
+
themeIsStringBadge = _ref2.themeIsStringBadge;
|
|
10094
10114
|
return {
|
|
10095
10115
|
fontSize: theme.__hd__.badge.fontSizes[themeSize],
|
|
10096
10116
|
lineHeight: theme.__hd__.badge.lineHeights[themeSize],
|
|
10097
10117
|
fontFamily: theme.__hd__.badge.fonts[themeSize],
|
|
10098
|
-
color: theme.__hd__.badge.colors.text,
|
|
10118
|
+
color: themeIsStringBadge ? theme.__hd__.badge.colors.stringText[themeIntent] : theme.__hd__.badge.colors.text,
|
|
10099
10119
|
includeFontPadding: false,
|
|
10100
10120
|
textAlignVertical: 'center',
|
|
10101
10121
|
textAlign: 'center'
|
|
@@ -10253,6 +10273,7 @@ var Badge = function Badge(_ref) {
|
|
|
10253
10273
|
}).start();
|
|
10254
10274
|
}, [visible, opacity]);
|
|
10255
10275
|
var isIconBadge = !!icon;
|
|
10276
|
+
var isStringBadge = !isIconBadge && typeof originalContent === 'string';
|
|
10256
10277
|
var content = React.useMemo(function () {
|
|
10257
10278
|
if (isIconBadge) {
|
|
10258
10279
|
return '';
|
|
@@ -10264,6 +10285,7 @@ var Badge = function Badge(_ref) {
|
|
|
10264
10285
|
themePadding: getPaddingState(content),
|
|
10265
10286
|
themeSize: size,
|
|
10266
10287
|
themeVariant: variant,
|
|
10288
|
+
themeIsStringBadge: isStringBadge,
|
|
10267
10289
|
style: [{
|
|
10268
10290
|
opacity: opacity,
|
|
10269
10291
|
transform: [{
|
|
@@ -10279,7 +10301,9 @@ var Badge = function Badge(_ref) {
|
|
|
10279
10301
|
themeSize: size,
|
|
10280
10302
|
intent: "text-inverted"
|
|
10281
10303
|
}) : /*#__PURE__*/React__namespace.default.createElement(StyledText$2, {
|
|
10282
|
-
themeSize: size
|
|
10304
|
+
themeSize: size,
|
|
10305
|
+
themeIntent: intent,
|
|
10306
|
+
themeIsStringBadge: isStringBadge
|
|
10283
10307
|
}, content));
|
|
10284
10308
|
};
|
|
10285
10309
|
var Badge$1 = Object.assign(Badge, {
|
package/package.json
CHANGED
|
@@ -22,31 +22,50 @@ const StyledView = styled(Animated.View)<{
|
|
|
22
22
|
themePadding: ThemePadding;
|
|
23
23
|
themeSize: ThemeSize;
|
|
24
24
|
themeVariant: ThemeVariant;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
: theme.__hd__.badge.
|
|
41
|
-
|
|
25
|
+
themeIsStringBadge: boolean;
|
|
26
|
+
}>(
|
|
27
|
+
({
|
|
28
|
+
themeIntent,
|
|
29
|
+
themePadding,
|
|
30
|
+
themeSize,
|
|
31
|
+
themeVariant,
|
|
32
|
+
themeIsStringBadge,
|
|
33
|
+
theme,
|
|
34
|
+
}) => {
|
|
35
|
+
const backgroundColor = themeIsStringBadge
|
|
36
|
+
? theme.__hd__.badge.colors.stringBackground[themeIntent]
|
|
37
|
+
: theme.__hd__.badge.colors[themeIntent];
|
|
38
|
+
return {
|
|
39
|
+
height: theme.__hd__.badge.sizes[themeSize].height,
|
|
40
|
+
minWidth: theme.__hd__.badge.sizes[themeSize].minWidth,
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
backgroundColor,
|
|
44
|
+
borderRadius: theme.radii.rounded,
|
|
45
|
+
paddingHorizontal:
|
|
46
|
+
themePadding === 'wideContent'
|
|
47
|
+
? theme.__hd__.badge.space[themeSize].horizontalPadding
|
|
48
|
+
: undefined,
|
|
49
|
+
borderWidth: theme.__hd__.badge.borderWidths.default,
|
|
50
|
+
borderColor:
|
|
51
|
+
themeVariant === 'outlined'
|
|
52
|
+
? theme.__hd__.badge.colors.border
|
|
53
|
+
: backgroundColor,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
);
|
|
42
57
|
|
|
43
58
|
const StyledText = styled(Typography.Caption)<{
|
|
44
59
|
themeSize: ThemeSize;
|
|
45
|
-
|
|
60
|
+
themeIntent: ThemeIntent;
|
|
61
|
+
themeIsStringBadge: boolean;
|
|
62
|
+
}>(({ theme, themeSize, themeIntent, themeIsStringBadge }) => ({
|
|
46
63
|
fontSize: theme.__hd__.badge.fontSizes[themeSize],
|
|
47
64
|
lineHeight: theme.__hd__.badge.lineHeights[themeSize],
|
|
48
65
|
fontFamily: theme.__hd__.badge.fonts[themeSize],
|
|
49
|
-
color:
|
|
66
|
+
color: themeIsStringBadge
|
|
67
|
+
? theme.__hd__.badge.colors.stringText[themeIntent]
|
|
68
|
+
: theme.__hd__.badge.colors.text,
|
|
50
69
|
includeFontPadding: false,
|
|
51
70
|
textAlignVertical: 'center',
|
|
52
71
|
textAlign: 'center',
|
|
@@ -44,6 +44,7 @@ const Badge = ({
|
|
|
44
44
|
}, [visible, opacity]);
|
|
45
45
|
|
|
46
46
|
const isIconBadge = !!icon;
|
|
47
|
+
const isStringBadge = !isIconBadge && typeof originalContent === 'string';
|
|
47
48
|
|
|
48
49
|
const content = useMemo(() => {
|
|
49
50
|
if (isIconBadge) {
|
|
@@ -61,6 +62,7 @@ const Badge = ({
|
|
|
61
62
|
themePadding={getPaddingState(content)}
|
|
62
63
|
themeSize={size}
|
|
63
64
|
themeVariant={variant}
|
|
65
|
+
themeIsStringBadge={isStringBadge}
|
|
64
66
|
style={[
|
|
65
67
|
{
|
|
66
68
|
opacity,
|
|
@@ -80,7 +82,13 @@ const Badge = ({
|
|
|
80
82
|
{isIconBadge ? (
|
|
81
83
|
<StyledIcon icon={icon} themeSize={size} intent="text-inverted" />
|
|
82
84
|
) : (
|
|
83
|
-
<StyledText
|
|
85
|
+
<StyledText
|
|
86
|
+
themeSize={size}
|
|
87
|
+
themeIntent={intent}
|
|
88
|
+
themeIsStringBadge={isStringBadge}
|
|
89
|
+
>
|
|
90
|
+
{content}
|
|
91
|
+
</StyledText>
|
|
84
92
|
)}
|
|
85
93
|
</StyledView>
|
|
86
94
|
);
|
|
@@ -12,6 +12,22 @@ const getBadgeTheme = (theme: GlobalTheme) => {
|
|
|
12
12
|
text: theme.colors.onDarkGlobalSurface,
|
|
13
13
|
border: theme.colors.defaultGlobalSurface,
|
|
14
14
|
countText: theme.colors.onDarkGlobalSurface,
|
|
15
|
+
stringBackground: {
|
|
16
|
+
primary: theme.colors.highlightedSurface,
|
|
17
|
+
danger: theme.colors.errorSurface,
|
|
18
|
+
info: theme.colors.infoSurface,
|
|
19
|
+
success: theme.colors.successSurface,
|
|
20
|
+
warning: theme.colors.warningSurface,
|
|
21
|
+
archived: theme.colors.archivedSurface,
|
|
22
|
+
},
|
|
23
|
+
stringText: {
|
|
24
|
+
primary: theme.colors.primary,
|
|
25
|
+
danger: theme.colors.onErrorSurface,
|
|
26
|
+
info: theme.colors.onInfoSurface,
|
|
27
|
+
success: theme.colors.onSuccessSurface,
|
|
28
|
+
warning: theme.colors.onWarningSurface,
|
|
29
|
+
archived: theme.colors.onArchivedSurface,
|
|
30
|
+
},
|
|
15
31
|
};
|
|
16
32
|
|
|
17
33
|
const fonts = {
|
|
@@ -11,12 +11,15 @@ declare const StyledView: import("@emotion/native").StyledComponent<Animated.Ani
|
|
|
11
11
|
themePadding: ThemePadding;
|
|
12
12
|
themeSize: ThemeSize;
|
|
13
13
|
themeVariant: ThemeVariant;
|
|
14
|
+
themeIsStringBadge: boolean;
|
|
14
15
|
}, {}, {}>;
|
|
15
16
|
declare const StyledText: import("@emotion/native").StyledComponent<import("../..").CaptionProps & {
|
|
16
17
|
theme?: import("@emotion/react").Theme;
|
|
17
18
|
as?: React.ElementType;
|
|
18
19
|
} & {
|
|
19
20
|
themeSize: ThemeSize;
|
|
21
|
+
themeIntent: ThemeIntent;
|
|
22
|
+
themeIsStringBadge: boolean;
|
|
20
23
|
}, {}, {}>;
|
|
21
24
|
declare const StyledStatus: import("@emotion/native").StyledComponent<Animated.AnimatedProps<import("react-native").ViewProps & import("react").RefAttributes<View>> & {
|
|
22
25
|
theme?: import("@emotion/react").Theme;
|
|
@@ -10,6 +10,22 @@ declare const getBadgeTheme: (theme: GlobalTheme) => {
|
|
|
10
10
|
text: string;
|
|
11
11
|
border: string;
|
|
12
12
|
countText: string;
|
|
13
|
+
stringBackground: {
|
|
14
|
+
primary: string;
|
|
15
|
+
danger: string;
|
|
16
|
+
info: string;
|
|
17
|
+
success: string;
|
|
18
|
+
warning: string;
|
|
19
|
+
archived: string;
|
|
20
|
+
};
|
|
21
|
+
stringText: {
|
|
22
|
+
primary: string;
|
|
23
|
+
danger: string;
|
|
24
|
+
info: string;
|
|
25
|
+
success: string;
|
|
26
|
+
warning: string;
|
|
27
|
+
archived: string;
|
|
28
|
+
};
|
|
13
29
|
};
|
|
14
30
|
fonts: {
|
|
15
31
|
medium: string;
|