x-star-design 0.0.11 → 0.0.13
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.
|
@@ -31,4 +31,8 @@ export interface AcAnimationProps {
|
|
|
31
31
|
* @default offsetX: 0, offsetY: 0, fontSize: 36, fontFamily: 'Arial', shadowColor: 'rgba(2,38,121,0.2)', color: '#022679' 相对canvas水平垂直居中
|
|
32
32
|
*/
|
|
33
33
|
titleStyle?: titleShowProps;
|
|
34
|
+
/**
|
|
35
|
+
* @description canvas卸载时的回调
|
|
36
|
+
*/
|
|
37
|
+
onFinish?: () => void;
|
|
34
38
|
}
|
|
@@ -8,7 +8,8 @@ var AcAnimation = function AcAnimation(_ref) {
|
|
|
8
8
|
offsetX: 0,
|
|
9
9
|
offsetY: 0
|
|
10
10
|
} : _ref$imgSizeAndPositi,
|
|
11
|
-
titleStyle = _ref.titleStyle
|
|
11
|
+
titleStyle = _ref.titleStyle,
|
|
12
|
+
onFinish = _ref.onFinish;
|
|
12
13
|
var canvas = document.createElement('canvas');
|
|
13
14
|
var ctx = canvas.getContext('2d');
|
|
14
15
|
var AnimationID = -1;
|
|
@@ -107,6 +108,11 @@ var AcAnimation = function AcAnimation(_ref) {
|
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
110
|
};
|
|
111
|
+
var shutDownCanvas = function shutDownCanvas() {
|
|
112
|
+
canvas.remove();
|
|
113
|
+
window.cancelAnimationFrame(AnimationID);
|
|
114
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish();
|
|
115
|
+
};
|
|
110
116
|
|
|
111
117
|
//---------Render-----------
|
|
112
118
|
var render = function render() {
|
|
@@ -152,8 +158,7 @@ var AcAnimation = function AcAnimation(_ref) {
|
|
|
152
158
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
153
159
|
});
|
|
154
160
|
if (confetti.length <= 10) {
|
|
155
|
-
|
|
156
|
-
window.cancelAnimationFrame(AnimationID);
|
|
161
|
+
shutDownCanvas();
|
|
157
162
|
return;
|
|
158
163
|
}
|
|
159
164
|
AnimationID = window.requestAnimationFrame(render);
|
|
@@ -172,8 +177,7 @@ var AcAnimation = function AcAnimation(_ref) {
|
|
|
172
177
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
173
178
|
id: "ac-canvas",
|
|
174
179
|
onClick: function onClick() {
|
|
175
|
-
|
|
176
|
-
window.cancelAnimationFrame(AnimationID);
|
|
180
|
+
shutDownCanvas();
|
|
177
181
|
}
|
|
178
182
|
}));
|
|
179
183
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export { default as RainbowCat } from './rainbow-cat';
|
|
|
9
9
|
export { default as StatusTag } from './status-tag';
|
|
10
10
|
export type { StatusTagProps, StatusTagShape, StatusTagStyle, StatusTagType, } from './status-tag/define';
|
|
11
11
|
export { default as TitleWithIcon } from './title-with-icon';
|
|
12
|
+
export { default as UserAvatar } from './user-avatar';
|
package/dist/index.js
CHANGED
|
@@ -6,4 +6,5 @@ export { default as ErrorBoundary } from "./error-boundary";
|
|
|
6
6
|
export { default as LoadingMask } from "./loading-mask";
|
|
7
7
|
export { default as RainbowCat } from "./rainbow-cat";
|
|
8
8
|
export { default as StatusTag } from "./status-tag";
|
|
9
|
-
export { default as TitleWithIcon } from "./title-with-icon";
|
|
9
|
+
export { default as TitleWithIcon } from "./title-with-icon";
|
|
10
|
+
export { default as UserAvatar } from "./user-avatar";
|
package/dist/types/svg.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AvatarProps } from 'antd/lib/avatar';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type UserAvatarProps = AvatarProps & {
|
|
4
|
+
user: {
|
|
5
|
+
realName?: string;
|
|
6
|
+
userName?: string;
|
|
7
|
+
} | null | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const UserAvatar: React.FC<UserAvatarProps>;
|
|
10
|
+
export default UserAvatar;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["user", "style"];
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
|
+
import { Avatar, Tooltip } from 'antd';
|
|
12
|
+
import randomColor from 'randomcolor';
|
|
13
|
+
import React, { useMemo } from 'react';
|
|
14
|
+
var UserAvatar = function UserAvatar(_ref) {
|
|
15
|
+
var _ref2, _ref2$filter;
|
|
16
|
+
var user = _ref.user,
|
|
17
|
+
style = _ref.style,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
var name = ((_ref2 = [user === null || user === void 0 ? void 0 : user.realName, user === null || user === void 0 ? void 0 : user.userName]) === null || _ref2 === void 0 ? void 0 : (_ref2$filter = _ref2.filter(Boolean)) === null || _ref2$filter === void 0 ? void 0 : _ref2$filter.join(' | ')) || 'Unknown';
|
|
20
|
+
var background = useMemo(function () {
|
|
21
|
+
return randomColor({
|
|
22
|
+
luminosity: 'bright',
|
|
23
|
+
seed: name,
|
|
24
|
+
format: 'rgb'
|
|
25
|
+
});
|
|
26
|
+
}, [name]);
|
|
27
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
28
|
+
title: name
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Avatar, _extends({
|
|
30
|
+
style: _objectSpread({
|
|
31
|
+
background: background
|
|
32
|
+
}, style)
|
|
33
|
+
}, props), name[0].toUpperCase()));
|
|
34
|
+
};
|
|
35
|
+
export default UserAvatar;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-star-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "A react component library developed by turingstar",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -57,14 +57,17 @@
|
|
|
57
57
|
"@uiw/react-codemirror": "^4.21.9",
|
|
58
58
|
"ahooks": "^3.7.8",
|
|
59
59
|
"classnames": "^2.3.2",
|
|
60
|
+
"randomcolor": "^0.6.2",
|
|
60
61
|
"x-star-utils": "^0.0.4"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
64
|
+
"@ant-design/icons": "4.7.0",
|
|
63
65
|
"@commitlint/cli": "^17.1.2",
|
|
64
66
|
"@commitlint/config-conventional": "^17.1.0",
|
|
65
67
|
"@types/react": "^18.0.0",
|
|
66
68
|
"@types/react-dom": "^18.0.0",
|
|
67
69
|
"@umijs/lint": "^4.0.0",
|
|
70
|
+
"antd": "5.2.2",
|
|
68
71
|
"dumi": "^2.2.0",
|
|
69
72
|
"eslint": "^8.23.0",
|
|
70
73
|
"father": "^4.1.0",
|
|
@@ -79,6 +82,8 @@
|
|
|
79
82
|
"stylelint-config-standard-scss": "^6.1.0"
|
|
80
83
|
},
|
|
81
84
|
"peerDependencies": {
|
|
85
|
+
"@ant-design/icons": ">=4.7.0",
|
|
86
|
+
"antd": ">=4.23",
|
|
82
87
|
"react": ">=16.9.0",
|
|
83
88
|
"react-dom": ">=16.9.0"
|
|
84
89
|
},
|