@nutui/nutui-react-taro 3.0.0-beta.7 → 3.0.0-beta.8

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.
Files changed (43) hide show
  1. package/dist/cjs/packages/animatingnumbers/style/style.css +1 -1
  2. package/dist/cjs/packages/backtop/backtop.d.ts +3 -4
  3. package/dist/cjs/packages/backtop/backtop.js +16 -34
  4. package/dist/cjs/packages/backtop/style/backtop.scss +8 -17
  5. package/dist/cjs/packages/backtop/style/style.css +8 -14
  6. package/dist/cjs/packages/badge/badge.d.ts +2 -12
  7. package/dist/cjs/packages/badge/badge.js +16 -54
  8. package/dist/cjs/packages/badge/index.d.ts +1 -1
  9. package/dist/cjs/packages/badge/style/badge.scss +61 -34
  10. package/dist/cjs/packages/badge/style/style.css +63 -40
  11. package/dist/cjs/packages/badge/types.d.ts +12 -0
  12. package/dist/cjs/packages/badge/types.js +4 -0
  13. package/dist/cjs/packages/configprovider/types.d.ts +1 -1
  14. package/dist/cjs/packages/countup/style/countup.scss +1 -1
  15. package/dist/cjs/packages/countup/style/style.css +1 -1
  16. package/dist/cjs/packages/hoverbutton/style/style.css +3 -3
  17. package/dist/cjs/packages/hoverbuttonitem/style/hoverbuttonitem.scss +3 -3
  18. package/dist/cjs/packages/hoverbuttonitem/style/style.css +3 -3
  19. package/dist/cjs/packages/tabbar/style/style.css +63 -40
  20. package/dist/cjs/packages/tabbaritem/style/style.css +63 -40
  21. package/dist/es/packages/animatingnumbers/style/style.css +1 -1
  22. package/dist/es/packages/backtop/backtop.d.ts +3 -4
  23. package/dist/es/packages/backtop/backtop.js +18 -36
  24. package/dist/es/packages/backtop/style/backtop.scss +8 -17
  25. package/dist/es/packages/backtop/style/style.css +8 -14
  26. package/dist/es/packages/badge/badge.d.ts +2 -12
  27. package/dist/es/packages/badge/badge.js +17 -55
  28. package/dist/es/packages/badge/index.d.ts +1 -1
  29. package/dist/es/packages/badge/style/badge.scss +61 -34
  30. package/dist/es/packages/badge/style/style.css +63 -40
  31. package/dist/es/packages/badge/types.d.ts +12 -0
  32. package/dist/es/packages/badge/types.js +1 -0
  33. package/dist/es/packages/configprovider/types.d.ts +1 -1
  34. package/dist/es/packages/countup/style/countup.scss +1 -1
  35. package/dist/es/packages/countup/style/style.css +1 -1
  36. package/dist/es/packages/hoverbutton/style/style.css +3 -3
  37. package/dist/es/packages/hoverbuttonitem/style/hoverbuttonitem.scss +3 -3
  38. package/dist/es/packages/hoverbuttonitem/style/style.css +3 -3
  39. package/dist/es/packages/tabbar/style/style.css +63 -40
  40. package/dist/es/packages/tabbaritem/style/style.css +63 -40
  41. package/dist/nutui.react.umd.js +124 -178
  42. package/dist/styles/variables.scss +22 -16
  43. package/package.json +1 -1
@@ -24,7 +24,7 @@
24
24
  display: flex;
25
25
  height: 80%;
26
26
  align-items: flex-end;
27
- color: var(--nutui-countup-bg-color, inherit);
27
+ color: var(--nutui-countup-separator-color, var(--nutui-color-title, #1a1a1a));
28
28
  font-size: var(--nutui-countup-base-size, 18px);
29
29
  font-weight: var(--nutui-font-weight-bold, 600);
30
30
  }
@@ -1,9 +1,8 @@
1
1
  import React, { FunctionComponent } from 'react';
2
- import type { MouseEvent } from 'react';
3
2
  import { PageScrollObject } from '@tarojs/taro';
4
3
  import { ITouchEvent } from '@tarojs/components';
5
- import { BasicComponent } from "../../utils/typings";
6
- export interface BackTopProps extends BasicComponent {
4
+ import { HoverButtonProps } from "../hoverbutton/index";
5
+ export interface BackTopProps extends HoverButtonProps {
7
6
  threshold: number;
8
7
  zIndex: number;
9
8
  duration: number;
@@ -11,6 +10,6 @@ export interface BackTopProps extends BasicComponent {
11
10
  * 容器滚动时的回调参数,主要用于 rn、鸿蒙端
12
11
  */
13
12
  scrollRes?: PageScrollObject;
14
- onClick?: (event: React.MouseEvent<Element, MouseEvent> | ITouchEvent) => void;
13
+ onClick?: (event: React.MouseEvent<HTMLDivElement> | ITouchEvent) => void;
15
14
  }
16
15
  export declare const BackTop: FunctionComponent<Partial<BackTopProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'>>;
@@ -17,38 +17,28 @@ var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
17
17
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
18
18
  var _taro = require("@tarojs/taro");
19
19
  var _components = require("@tarojs/components");
20
- var _iconsreacttaro = require("@nutui/icons-react-taro");
21
20
  var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
21
+ var _iconsreacttaro = require("@nutui/icons-react-taro");
22
22
  var _typings = require("../../utils/typings");
23
- var _index = require("../configprovider/index");
23
+ var _index = /*#__PURE__*/ _interop_require_default._(require("../hoverbutton/index"));
24
24
  var _platformtaro = require("../../utils/platform-taro");
25
- var _pxtransform = /*#__PURE__*/ _interop_require_default._(require("../../utils/px-transform"));
26
25
  var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
27
26
  threshold: 200,
28
27
  zIndex: 900,
29
28
  duration: 1000
30
29
  });
31
- var isNative = (0, _platformtaro.harmonyAndRn)();
32
30
  var BackTop = function BackTop(props) {
33
- var rtl = (0, _index.useRtl)();
34
- var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), children = _$_object_spread.children, threshold = _$_object_spread.threshold, zIndex = _$_object_spread.zIndex, className = _$_object_spread.className, duration = _$_object_spread.duration, style = _$_object_spread.style, scrollRes = _$_object_spread.scrollRes, onClick = _$_object_spread.onClick;
31
+ var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), children = _$_object_spread.children, threshold = _$_object_spread.threshold, zIndex = _$_object_spread.zIndex, className = _$_object_spread.className, duration = _$_object_spread.duration, icon = _$_object_spread.icon, style = _$_object_spread.style, scrollRes = _$_object_spread.scrollRes, onClick = _$_object_spread.onClick;
35
32
  var classPrefix = 'nut-backtop';
36
33
  var _useState = (0, _sliced_to_array._)((0, _react.useState)(false), 2), backTop = _useState[0], setBackTop = _useState[1];
37
- var _useState1 = (0, _sliced_to_array._)((0, _react.useState)(false), 2), isTouchStart = _useState1[0], setTouchStart = _useState1[1];
38
34
  var _obj;
39
- var cls = (0, _classnames.default)(classPrefix, (_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-show"), backTop), (0, _define_property._)(_obj, "".concat(classPrefix, "-show-active"), isNative && isTouchStart), (0, _define_property._)(_obj, "".concat(classPrefix, "-rn"), (0, _platformtaro.rn)()), _obj), className);
35
+ var cls = (0, _classnames.default)(classPrefix, (_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-show"), backTop), (0, _define_property._)(_obj, "".concat(classPrefix, "-rn"), (0, _platformtaro.rn)()), _obj), className);
40
36
  var systemInfo = (0, _react.useRef)({});
41
37
  (0, _react.useEffect)(function() {
42
38
  (0, _taro.getSystemInfo)().then(function(res) {
43
39
  systemInfo.current = res;
44
40
  });
45
41
  }, []);
46
- var handleActiveStart = (0, _react.useCallback)(function() {
47
- isNative && setTouchStart(true);
48
- }, []);
49
- var handleActiveEnd = (0, _react.useCallback)(function() {
50
- isNative && setTouchStart(false);
51
- }, []);
52
42
  var onScroll = (0, _react.useCallback)(function(res) {
53
43
  var scrollTop = res.scrollTop;
54
44
  setBackTop(scrollTop >= threshold);
@@ -75,28 +65,20 @@ var BackTop = function BackTop(props) {
75
65
  duration,
76
66
  onClick
77
67
  ]);
78
- var styles = (0, _react.useMemo)(function() {
79
- var _obj;
80
- return Object.keys(style || {}).length !== 0 ? (0, _object_spread._)({
81
- zIndex: zIndex
82
- }, style) : (_obj = {}, (0, _define_property._)(_obj, rtl ? 'left' : 'right', (0, _pxtransform.default)(10)), (0, _define_property._)(_obj, "bottom", (0, _pxtransform.default)(20)), (0, _define_property._)(_obj, "zIndex", zIndex), _obj);
83
- }, [
84
- rtl,
85
- style,
86
- zIndex
87
- ]);
88
- return /*#__PURE__*/ _react.default.createElement(_components.View, {
68
+ return /*#__PURE__*/ _react.default.createElement(_index.default, {
89
69
  className: cls,
90
- style: styles,
70
+ style: (0, _object_spread._)({
71
+ zIndex: zIndex
72
+ }, style),
73
+ icon: !children && (icon || /*#__PURE__*/ _react.default.createElement(_iconsreacttaro.Top, null)),
74
+ onClick: function onClick(e) {
75
+ goTop(e);
76
+ }
77
+ }, children && /*#__PURE__*/ _react.default.createElement(_components.View, {
78
+ className: "nut-hoverbutton-item-container",
91
79
  onClick: function onClick(e) {
92
80
  goTop(e);
93
- },
94
- onTouchStart: handleActiveStart,
95
- onTouchEnd: handleActiveEnd,
96
- onTouchCancel: handleActiveEnd
97
- }, children || /*#__PURE__*/ _react.default.createElement(_iconsreacttaro.Top, {
98
- size: 19,
99
- className: "nut-backtop-main"
100
- }));
81
+ }
82
+ }, children));
101
83
  };
102
84
  BackTop.displayName = 'NutBackTop';
@@ -1,31 +1,22 @@
1
1
  .nut-backtop {
2
2
  display: none;
3
- position: fixed;
4
3
 
5
4
  &-rn {
6
5
  position: absolute;
7
6
  }
8
7
 
9
8
  &-show {
10
- width: 40px;
11
- height: 40px;
12
9
  display: flex;
13
10
  align-items: center;
14
11
  justify-content: center;
15
- background: $color-background-overlay;
16
- color: $color-title;
17
- border: 1px solid $backtop-border-color;
18
- border-radius: 21px;
19
- z-index: 100;
20
-
21
- &:active,
22
- &-active {
23
- background: $color-background;
24
- }
25
- }
26
-
27
- &-main {
12
+ width: $hoverbutton-item-size;
13
+ height: $hoverbutton-item-size;
28
14
  transition: all 0.2s ease-in-out;
29
- color: $color-title;
15
+ .nut-hoverbutton-item-container {
16
+ display: flex;
17
+ flex-direction: column;
18
+ justify-content: center;
19
+ align-items: center;
20
+ }
30
21
  }
31
22
  }
@@ -4,27 +4,21 @@
4
4
  /* #endif */
5
5
  .nut-backtop {
6
6
  display: none;
7
- position: fixed;
8
7
  }
9
8
  .nut-backtop-rn {
10
9
  position: absolute;
11
10
  }
12
11
  .nut-backtop-show {
13
- width: 40px;
14
- height: 40px;
15
12
  display: flex;
16
13
  align-items: center;
17
14
  justify-content: center;
18
- background: var(--nutui-color-background-overlay, #ffffff);
19
- color: var(--nutui-color-title, #1a1a1a);
20
- border: 1px solid var(--nutui-backtop-border-color, var(--nutui-color-border, rgba(0, 0, 0, 0.06)));
21
- border-radius: 21px;
22
- z-index: 100;
23
- }
24
- .nut-backtop-show:active, .nut-backtop-show-active {
25
- background: var(--nutui-color-background, #f5f6fa);
26
- }
27
- .nut-backtop-main {
15
+ width: var(--nutui-hoverbutton-item-size, 40px);
16
+ height: var(--nutui-hoverbutton-item-size, 40px);
28
17
  transition: all 0.2s ease-in-out;
29
- color: var(--nutui-color-title, #1a1a1a);
18
+ }
19
+ .nut-backtop-show .nut-hoverbutton-item-container {
20
+ display: flex;
21
+ flex-direction: column;
22
+ justify-content: center;
23
+ align-items: center;
30
24
  }
@@ -1,13 +1,3 @@
1
- import { FunctionComponent, ReactNode } from 'react';
2
- import { BasicComponent } from "../../utils/typings";
3
- export type BadgeFill = 'solid' | 'outline';
4
- export interface BadgeProps extends BasicComponent {
5
- value: ReactNode;
6
- dot: boolean;
7
- max: number;
8
- top: string | number;
9
- right: string | number;
10
- color: string;
11
- fill: BadgeFill;
12
- }
1
+ import { FunctionComponent } from 'react';
2
+ import { BadgeProps } from './types';
13
3
  export declare const Badge: FunctionComponent<Partial<BadgeProps>>;
@@ -23,16 +23,15 @@ var _components = require("@tarojs/components");
23
23
  var _typings = require("../../utils/typings");
24
24
  var _index = require("../configprovider/index");
25
25
  var _pxtransform = /*#__PURE__*/ _interop_require_default._(require("../../utils/px-transform"));
26
- var _getrectbytaro = require("../../utils/get-rect-by-taro");
27
26
  var _platformtaro = require("../../utils/platform-taro");
28
27
  var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
29
28
  value: '',
30
29
  dot: false,
31
30
  max: 99,
32
- top: '4',
33
- right: '8',
34
- color: '',
35
- fill: 'solid'
31
+ top: 0,
32
+ right: 0,
33
+ fill: 'solid',
34
+ size: 'large'
36
35
  });
37
36
  var Badge = function Badge(props) {
38
37
  var content = function content() {
@@ -53,14 +52,14 @@ var Badge = function Badge(props) {
53
52
  };
54
53
  var _this;
55
54
  var rtl = (0, _index.useRtl)();
56
- var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, value = _$_object_spread.value, max = _$_object_spread.max, children = _$_object_spread.children, dot = _$_object_spread.dot, top = _$_object_spread.top, right = _$_object_spread.right, color = _$_object_spread.color, fill = _$_object_spread.fill;
55
+ var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, value = _$_object_spread.value, max = _$_object_spread.max, children = _$_object_spread.children, dot = _$_object_spread.dot, top = _$_object_spread.top, right = _$_object_spread.right, fill = _$_object_spread.fill, size = _$_object_spread.size;
57
56
  var classPrefix = 'nut-badge';
58
57
  var isHarmony = (0, _platformtaro.harmony)();
59
58
  var classes = (0, _classnames.default)(classPrefix, className);
60
59
  var badgeRef = (0, _react.useRef)(null);
61
60
  var _useState = (0, _sliced_to_array._)((0, _react.useState)({}), 2), contentStyle = _useState[0], setContentStyle = _useState[1];
62
61
  var _obj;
63
- var contentClasses = (0, _classnames.default)("".concat(classPrefix, "-content"), (_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-sup"), isNumber() || isString() || dot), (0, _define_property._)(_obj, "".concat(classPrefix, "-one"), typeof content() === 'string' && ((_this = "".concat(content())) === null || _this === void 0 ? void 0 : _this.length) === 1), (0, _define_property._)(_obj, "".concat(classPrefix, "-dot"), dot), (0, _define_property._)(_obj, "".concat(classPrefix, "-").concat(fill), fill === 'outline'), _obj));
62
+ var contentClasses = (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-sup"), isNumber() || isString() || dot), (0, _define_property._)(_obj, "".concat(classPrefix, "-number"), isNumber()), (0, _define_property._)(_obj, "".concat(classPrefix, "-one"), typeof content() === 'string' && ((_this = "".concat(content())) === null || _this === void 0 ? void 0 : _this.length) === 1), (0, _define_property._)(_obj, "".concat(classPrefix, "-dot"), dot), (0, _define_property._)(_obj, "".concat(classPrefix, "-dot-").concat(size), dot), (0, _define_property._)(_obj, "".concat(classPrefix, "-").concat(fill), fill === 'outline'), (0, _define_property._)(_obj, "".concat(classPrefix, "-content"), children), _obj));
64
63
  (0, _react.useEffect)(function() {
65
64
  if (badgeRef.current) {
66
65
  getPositionStyle();
@@ -68,59 +67,22 @@ var Badge = function Badge(props) {
68
67
  }, []);
69
68
  var getPositionStyle = /*#__PURE__*/ function() {
70
69
  var _ref = (0, _async_to_generator._)(function() {
71
- var style, reacts, dir;
70
+ var style, dir;
72
71
  return (0, _ts_generator._)(this, function(_state) {
73
- switch(_state.label){
74
- case 0:
75
- style = {};
76
- style.top = (0, _pxtransform.default)(-Number(top) || 0);
77
- if (!(0, _platformtaro.rn)()) return [
78
- 3,
79
- 2
80
- ];
81
- return [
82
- 4,
83
- (0, _getrectbytaro.getRectByTaro)(badgeRef.current)
84
- ];
85
- case 1:
86
- reacts = _state.sent();
87
- style.left = (reacts === null || reacts === void 0 ? void 0 : reacts.width) && (reacts === null || reacts === void 0 ? void 0 : reacts.width) > Number(right) ? (0, _pxtransform.default)(reacts.width - Number(right)) : 0;
88
- return [
89
- 3,
90
- 3
91
- ];
92
- case 2:
93
- dir = rtl ? 'left' : 'right';
94
- style[dir] = isHarmony ? (0, _pxtransform.default)(Number(right)) : "".concat(Number(right) || parseFloat(String(right)) || 0, "px");
95
- _state.label = 3;
96
- case 3:
97
- setContentStyle(style);
98
- return [
99
- 2
100
- ];
101
- }
72
+ style = {};
73
+ style.top = (0, _pxtransform.default)(Number(top) || 0);
74
+ dir = rtl ? 'left' : 'right';
75
+ style[dir] = isHarmony ? (0, _pxtransform.default)(Number(right)) : "".concat(Number(right) || 0, "px");
76
+ setContentStyle(style);
77
+ return [
78
+ 2
79
+ ];
102
80
  });
103
81
  });
104
82
  return function getPositionStyle() {
105
83
  return _ref.apply(this, arguments);
106
84
  };
107
85
  }();
108
- var getStyle = function getStyle() {
109
- var style = {};
110
- if (color) {
111
- if (fill === 'outline') {
112
- style.color = color;
113
- isHarmony ? style.backgroundColor = '#fff' : style.background = '#fff';
114
- if (!(color === null || color === void 0 ? void 0 : color.includes('gradient'))) {
115
- style.borderColor = color;
116
- }
117
- } else {
118
- style.color = '#fff';
119
- isHarmony ? style.backgroundColor = color : style.background = color;
120
- }
121
- }
122
- return style;
123
- };
124
86
  var _obj1;
125
87
  return /*#__PURE__*/ _react.default.createElement(_components.View, {
126
88
  className: classes,
@@ -131,7 +93,7 @@ var Badge = function Badge(props) {
131
93
  style: contentStyle
132
94
  }, value), children, !isIcon() && /*#__PURE__*/ _react.default.createElement(_components.View, {
133
95
  className: contentClasses,
134
- style: (0, _object_spread._)({}, contentStyle, getStyle())
96
+ style: contentStyle
135
97
  }, content()));
136
98
  };
137
99
  Badge.displayName = 'NutBadge';
@@ -1,3 +1,3 @@
1
1
  import { Badge } from "./badge";
2
- export type { BadgeFill, BadgeProps } from "./badge";
2
+ export type { BadgeFill, BadgeDotSize, BadgeProps } from './types';
3
3
  export default Badge;
@@ -2,22 +2,14 @@
2
2
  position: relative;
3
3
  display: inline-flex;
4
4
  width: auto;
5
- /* #ifdef harmony */
6
- min-width: 1px;
7
- /* #endif */
8
- /* #ifndef harmony */
9
- min-width: auto;
10
- /* #endif */
5
+
11
6
  &-icon {
12
- position: absolute;
13
7
  display: flex;
14
8
  justify-content: center;
15
9
  align-items: center;
16
10
  background: $badge-background-color;
17
11
  padding: $badge-icon-padding;
18
12
  text-align: center;
19
- border: $badge-border;
20
- border-radius: $badge-border-radius;
21
13
  z-index: $badge-z-index;
22
14
 
23
15
  .nut-icon {
@@ -27,53 +19,88 @@
27
19
  }
28
20
  }
29
21
 
22
+ &-sup,
23
+ &-icon {
24
+ border-radius: $badge-border-radius;
25
+ &::after {
26
+ content: '';
27
+ position: absolute;
28
+ top: -50%;
29
+ bottom: -50%;
30
+ left: -50%;
31
+ right: -50%;
32
+ transform: scale(0.5);
33
+ border: $badge-border;
34
+ border-radius: $badge-border-radius;
35
+ }
36
+ }
37
+
30
38
  &-sup {
31
- height: $badge-height;
32
- position: absolute;
33
- display: flex;
39
+ display: inline-flex;
34
40
  justify-content: center;
35
- align-items: center;
36
- /* #ifdef harmony */
37
- background: $color-primary;
38
- /* #endif */
39
- /* #ifndef harmony */
40
- background: $badge-background-color;
41
- /* #endif */
42
- color: $badge-color;
41
+ height: $badge-height;
42
+ min-width: $badge-min-width;
43
43
  padding: $badge-padding;
44
+ box-sizing: border-box;
45
+ color: $badge-color;
44
46
  font-size: $badge-font-size;
45
- font-weight: normal;
46
- text-align: center;
47
- border: $badge-border;
48
- border-radius: $badge-border-radius;
49
- min-width: $badge-min-width;
47
+ line-height: 12px;
50
48
  white-space: nowrap;
49
+ font-weight: normal;
50
+ vertical-align: middle;
51
+ background: $badge-background-color;
51
52
  z-index: 1;
52
53
  }
53
54
 
55
+ &-number {
56
+ font-family: 'JD';
57
+ /* #ifdef harmony */
58
+ line-height: 12px;
59
+ /* #endif */
60
+ /* #ifndef harmony */
61
+ line-height: 13px;
62
+ /* #endif */
63
+ }
64
+
54
65
  &-one {
55
66
  height: $badge-height;
56
67
  width: $badge-height;
57
- padding: 0;
58
68
  }
59
69
 
60
70
  &-content {
61
- /* #ifndef rn */
71
+ position: absolute;
62
72
  transform: $badge-content-transform;
63
- /* #endif */
64
73
  }
65
74
 
66
75
  &-dot {
67
- width: $badge-dot-width;
68
- height: $badge-dot-width;
69
- border: $badge-dot-border;
70
- border-radius: $badge-dot-width;
71
76
  padding: 0;
77
+ border-radius: 50%;
78
+ &::after {
79
+ border: $badge-dot-border;
80
+ border-radius: 50%;
81
+ }
82
+ &-normal {
83
+ min-width: $badge-dot-width;
84
+ width: $badge-dot-width;
85
+ height: $badge-dot-width;
86
+ }
87
+ &-small {
88
+ min-width: $badge-dot-small-width;
89
+ width: $badge-dot-small-width;
90
+ height: $badge-dot-small-width;
91
+ }
92
+ &-large {
93
+ min-width: $badge-dot-large-width;
94
+ width: $badge-dot-large-width;
95
+ height: $badge-dot-large-width;
96
+ }
72
97
  }
73
98
 
74
99
  &-outline {
75
100
  background: $color-primary-text;
76
- border: 1px solid $color-primary;
77
- color: $color-primary;
101
+ color: $badge-outline-color;
102
+ &::after {
103
+ border: $badge-outline-border;
104
+ }
78
105
  }
79
106
  }
@@ -6,72 +6,95 @@
6
6
  position: relative;
7
7
  display: inline-flex;
8
8
  width: auto;
9
- /* #ifdef harmony */
10
- min-width: 1px;
11
- /* #endif */
12
- /* #ifndef harmony */
13
- min-width: auto;
14
- /* #endif */
15
9
  }
16
10
  .nut-badge-icon {
17
- position: absolute;
18
11
  display: flex;
19
12
  justify-content: center;
20
13
  align-items: center;
21
- background: var(--nutui-badge-background-color, linear-gradient(135deg, var(--nutui-color-primary-stop-1, #ff475d) 0%, var(--nutui-color-primary-stop-2, #ff0f23) 100%));
22
- padding: var(--nutui-badge-icon-padding, 3px);
14
+ background: var(--nutui-badge-background-color, var(--nutui-color-primary, #ff0f23));
15
+ padding: var(--nutui-badge-icon-padding, 2px);
23
16
  text-align: center;
24
- border: var(--nutui-badge-border, 0px solid var(--nutui-color-primary-text, #ffffff));
25
- border-radius: var(--nutui-badge-border-radius, var(--nutui-badge-height, 14px));
26
17
  z-index: var(--nutui-badge-z-index, 1);
27
18
  }
28
19
  .nut-badge-icon .nut-icon {
29
- width: var(--nutui-badge-icon-size, 12px);
30
- height: var(--nutui-badge-icon-size, 12px);
31
- font-size: var(--nutui-badge-icon-size, 12px);
20
+ width: var(--nutui-badge-icon-size, 10px);
21
+ height: var(--nutui-badge-icon-size, 10px);
22
+ font-size: var(--nutui-badge-icon-size, 10px);
32
23
  }
33
- .nut-badge-sup {
34
- height: var(--nutui-badge-height, 14px);
24
+ .nut-badge-sup, .nut-badge-icon {
25
+ border-radius: var(--nutui-badge-border-radius, var(--nutui-badge-height, 14px));
26
+ }
27
+ .nut-badge-sup::after, .nut-badge-icon::after {
28
+ content: "";
35
29
  position: absolute;
36
- display: flex;
30
+ top: -50%;
31
+ bottom: -50%;
32
+ left: -50%;
33
+ right: -50%;
34
+ transform: scale(0.5);
35
+ border: var(--nutui-badge-border, 1px solid var(--nutui-color-primary-text, #ffffff));
36
+ border-radius: var(--nutui-badge-border-radius, var(--nutui-badge-height, 14px));
37
+ }
38
+ .nut-badge-sup {
39
+ display: inline-flex;
37
40
  justify-content: center;
38
- align-items: center;
41
+ height: var(--nutui-badge-height, 14px);
42
+ min-width: var(--nutui-badge-min-width, 6px);
43
+ padding: var(--nutui-badge-padding, 1px 4px);
44
+ box-sizing: border-box;
45
+ color: var(--nutui-badge-color, var(--nutui-color-primary-text, #ffffff));
46
+ font-size: var(--nutui-badge-font-size, var(--nutui-font-size-xxs, 10px));
47
+ line-height: 12px;
48
+ white-space: nowrap;
49
+ font-weight: normal;
50
+ vertical-align: middle;
51
+ background: var(--nutui-badge-background-color, var(--nutui-color-primary, #ff0f23));
52
+ z-index: 1;
53
+ }
54
+ .nut-badge-number {
55
+ font-family: "JD";
39
56
  /* #ifdef harmony */
40
- background: var(--nutui-color-primary, #ff0f23);
57
+ line-height: 12px;
41
58
  /* #endif */
42
59
  /* #ifndef harmony */
43
- background: var(--nutui-badge-background-color, linear-gradient(135deg, var(--nutui-color-primary-stop-1, #ff475d) 0%, var(--nutui-color-primary-stop-2, #ff0f23) 100%));
60
+ line-height: 13px;
44
61
  /* #endif */
45
- color: var(--nutui-badge-color, #fff);
46
- padding: var(--nutui-badge-padding, 0 4px);
47
- font-size: var(--nutui-badge-font-size, var(--nutui-font-size-xxs, 10px));
48
- font-weight: normal;
49
- text-align: center;
50
- border: var(--nutui-badge-border, 0px solid var(--nutui-color-primary-text, #ffffff));
51
- border-radius: var(--nutui-badge-border-radius, var(--nutui-badge-height, 14px));
52
- min-width: var(--nutui-badge-min-width, 5px);
53
- white-space: nowrap;
54
- z-index: 1;
55
62
  }
56
63
  .nut-badge-one {
57
64
  height: var(--nutui-badge-height, 14px);
58
65
  width: var(--nutui-badge-height, 14px);
59
- padding: 0;
60
66
  }
61
67
  .nut-badge-content {
62
- /* #ifndef rn */
63
- transform: var(--nutui-badge-content-transform, translateX(100%));
64
- /* #endif */
68
+ position: absolute;
69
+ transform: var(--nutui-badge-content-transform, translate(50%, -50%));
65
70
  }
66
71
  .nut-badge-dot {
67
- width: var(--nutui-badge-dot-width, 7px);
68
- height: var(--nutui-badge-dot-width, 7px);
69
- border: var(--nutui-badge-dot-border, 0px solid var(--nutui-color-primary-text, #ffffff));
70
- border-radius: var(--nutui-badge-dot-width, 7px);
71
72
  padding: 0;
73
+ border-radius: 50%;
74
+ }
75
+ .nut-badge-dot::after {
76
+ border: var(--nutui-badge-dot-border, 1px solid var(--nutui-color-primary-text, #ffffff));
77
+ border-radius: 50%;
78
+ }
79
+ .nut-badge-dot-normal {
80
+ min-width: var(--nutui-badge-dot-width, 6px);
81
+ width: var(--nutui-badge-dot-width, 6px);
82
+ height: var(--nutui-badge-dot-width, 6px);
83
+ }
84
+ .nut-badge-dot-small {
85
+ min-width: var(--nutui-badge-dot-width, 4px);
86
+ width: var(--nutui-badge-dot-width, 4px);
87
+ height: var(--nutui-badge-dot-width, 4px);
88
+ }
89
+ .nut-badge-dot-large {
90
+ min-width: var(--nutui-badge-dot-width, 8px);
91
+ width: var(--nutui-badge-dot-width, 8px);
92
+ height: var(--nutui-badge-dot-width, 8px);
72
93
  }
73
94
  .nut-badge-outline {
74
95
  background: var(--nutui-color-primary-text, #ffffff);
75
- border: 1px solid var(--nutui-color-primary, #ff0f23);
76
- color: var(--nutui-color-primary, #ff0f23);
96
+ color: var(--nutui-badge-outline-color, var(--nutui-color-primary, #ff0f23));
97
+ }
98
+ .nut-badge-outline::after {
99
+ border: var(--nutui-badge-outline-border, 1px solid var(--nutui-color-primary, #ff0f23));
77
100
  }
@@ -0,0 +1,12 @@
1
+ import { BasicComponent } from "../../utils/typings";
2
+ export type BadgeFill = 'solid' | 'outline';
3
+ export type BadgeDotSize = 'small' | 'normal' | 'large';
4
+ export interface BadgeProps extends BasicComponent {
5
+ value: React.ReactNode;
6
+ dot: boolean;
7
+ max: number;
8
+ top: string | number;
9
+ right: string | number;
10
+ fill: BadgeFill;
11
+ size: BadgeDotSize;
12
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });