@arcblock/ux 1.16.3 → 1.16.7

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.
@@ -21,13 +21,15 @@ var _useMediaQuery = _interopRequireDefault(require("@material-ui/core/useMediaQ
21
21
 
22
22
  var _useTheme = _interopRequireDefault(require("@material-ui/core/styles/useTheme"));
23
23
 
24
+ var _Avatar = _interopRequireDefault(require("@arcblock/did-connect/lib/Avatar"));
25
+
24
26
  var _Icon = _interopRequireDefault(require("../Icon"));
25
27
 
26
28
  var _Button = _interopRequireDefault(require("../Button"));
27
29
 
28
30
  var _Img = _interopRequireDefault(require("../Img"));
29
31
 
30
- const _excluded = ["title", "description", "cover", "type", "size", "addons", "button", "buttonText", "buttonDisabled", "buttonLoading", "isStickyButton", "onButtonClick", "onMainClick", "onTagClick", "className", "scaleClickZone"];
32
+ const _excluded = ["title", "did", "description", "cover", "type", "size", "addons", "button", "buttonText", "buttonDisabled", "buttonLoading", "isStickyButton", "onButtonClick", "onMainClick", "onTagClick", "className", "scaleClickZone"];
31
33
 
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
35
 
@@ -78,6 +80,7 @@ function prettySize(_size) {
78
80
  function Blocklet(_ref2) {
79
81
  let {
80
82
  title,
83
+ did,
81
84
  description,
82
85
  cover,
83
86
  type,
@@ -128,10 +131,13 @@ function Blocklet(_ref2) {
128
131
 
129
132
  const theme = (0, _useTheme.default)();
130
133
  const isDownSm = (0, _useMediaQuery.default)(theme.breakpoints.down('sm'));
131
- const isDownMd = (0, _useMediaQuery.default)(theme.breakpoints.down('md')); // If size is auto, need calculate actual size according to screen size
134
+ const isDownMd = (0, _useMediaQuery.default)(theme.breakpoints.down('md'));
135
+ const isUPLg = (0, _useMediaQuery.default)(theme.breakpoints.up('lg')); // If size is auto, need calculate actual size according to screen size
132
136
  // eslint-disable-next-line no-nested-ternary
133
137
 
134
- const actualSize = size === 'auto' ? isDownSm ? 'xs' : isDownMd ? 'sm' : 'md' : size;
138
+ const actualSize = size === 'auto' ? isDownSm ? 'xs' : isDownMd ? 'sm' : 'md' : size; // eslint-disable-next-line no-nested-ternary
139
+
140
+ const didAvatarSize = size === 'auto' ? isUPLg ? 100 : 48 : size === 'md' ? 100 : 48;
135
141
  const container = (0, _react.useRef)(null);
136
142
  return /*#__PURE__*/_react.default.createElement(Div, Object.assign({}, rest, {
137
143
  scaleClickZone: scaleClickZone,
@@ -144,10 +150,15 @@ function Blocklet(_ref2) {
144
150
  ref: container
145
151
  }, /*#__PURE__*/_react.default.createElement("div", {
146
152
  className: "arcblock-blocklet__content--body"
147
- }, cover && /*#__PURE__*/_react.default.createElement("div", {
153
+ }, cover ? /*#__PURE__*/_react.default.createElement("div", {
148
154
  className: "arcblock-blocklet__cover"
149
155
  }, /*#__PURE__*/_react.default.createElement(_Img.default, {
150
156
  src: cover
157
+ })) : did && /*#__PURE__*/_react.default.createElement("div", {
158
+ className: "arcblock-blocklet__cover"
159
+ }, /*#__PURE__*/_react.default.createElement(_Avatar.default, {
160
+ did: did,
161
+ size: didAvatarSize
151
162
  })), /*#__PURE__*/_react.default.createElement("div", {
152
163
  className: "arcblock-blocklet__info"
153
164
  }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
@@ -205,6 +216,7 @@ function Blocklet(_ref2) {
205
216
 
206
217
  Blocklet.propTypes = {
207
218
  title: _propTypes.default.string.isRequired,
219
+ did: _propTypes.default.string,
208
220
  isStickyButton: _propTypes.default.bool,
209
221
  description: _propTypes.default.string,
210
222
  cover: _propTypes.default.string,
@@ -224,6 +236,7 @@ Blocklet.propTypes = {
224
236
  Blocklet.defaultProps = {
225
237
  description: null,
226
238
  cover: null,
239
+ did: null,
227
240
  isStickyButton: false,
228
241
  buttonText: 'Install',
229
242
  buttonDisabled: false,
@@ -51,6 +51,8 @@ var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
51
51
 
52
52
  var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
53
53
 
54
+ var _Colors = _interopRequireDefault(require("../Colors"));
55
+
54
56
  const _excluded = ["code", "language", "children"];
55
57
 
56
58
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -171,4 +173,4 @@ const fontFamily = 'source-code-pro, Menlo, Monaco, Consolas, Courier New, monos
171
173
  const Pre = _styledComponents.default.pre.withConfig({
172
174
  displayName: "CodeBlock__Pre",
173
175
  componentId: "sc-1bpapaq-0"
174
- })(["font-family:", ";display:block;font-size:14px;line-height:1.42857143;margin:0 0 32px;word-break:break-word;word-wrap:break-word;text-align:left;border-radius:5px;border:1px solid #dedede;background:#222;color:#fff;position:relative;.codeblock__inner{display:block;width:100%;max-height:46.25rem;overflow:scroll;}.copy-button{display:none;position:absolute;top:8px;right:24px;}&:hover{.copy-button{display:block;}}code{counter-reset:line;counter-increment:line;padding:16px;font-family:", ";color:#fff;*{font-family:", ";}}.hljs *{white-space:normal;}"], fontFamily, fontFamily, fontFamily);
176
+ })(["font-family:", ";display:block;font-size:14px;line-height:1.42857143;margin:0 0 32px;word-break:break-word;word-wrap:break-word;text-align:left;border-radius:5px;border:1px solid #dedede;background:#222;color:#fff;position:relative;.codeblock__inner{display:block;width:100%;max-height:46.25rem;overflow:scroll;}.copy-button{display:none;position:absolute;top:8px;right:24px;padding:4px;border-radius:4px;&,&:hover,&.Mui-disabled{background:", ";}}&:hover{.copy-button{display:block;}}code{counter-reset:line;counter-increment:line;padding:16px;font-family:", ";color:#fff;*{font-family:", ";}}.hljs *{white-space:normal;}"], fontFamily, _Colors.default.primary.main, fontFamily, fontFamily);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "1.16.3",
3
+ "version": "1.16.7",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -53,10 +53,10 @@
53
53
  "react": ">=16.12.0",
54
54
  "react-ga": "^2.7.0"
55
55
  },
56
- "gitHead": "84ae55baf4d6614c13ec202e12b91faf18225474",
56
+ "gitHead": "02a50de3fa9e4a2f5c88bed4a701e8ac80f305e1",
57
57
  "dependencies": {
58
- "@arcblock/icons": "^1.16.3",
59
- "@arcblock/react-hooks": "^1.16.3",
58
+ "@arcblock/icons": "^1.16.7",
59
+ "@arcblock/react-hooks": "^1.16.7",
60
60
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
61
61
  "@material-ui/core": "^4.12.3",
62
62
  "@material-ui/icons": "4.11.2",
@@ -6,6 +6,7 @@ import Typography from '@material-ui/core/Typography';
6
6
  import CircularProgress from '@material-ui/core/CircularProgress';
7
7
  import useMediaQuery from '@material-ui/core/useMediaQuery';
8
8
  import useTheme from '@material-ui/core/styles/useTheme';
9
+ import Avatar from '@arcblock/did-connect/lib/Avatar';
9
10
 
10
11
  import Icon from '../Icon';
11
12
  import Button from '../Button';
@@ -163,6 +164,7 @@ function prettySize(_size) {
163
164
 
164
165
  export default function Blocklet({
165
166
  title,
167
+ did,
166
168
  description,
167
169
  cover,
168
170
  type,
@@ -204,10 +206,13 @@ export default function Blocklet({
204
206
  const theme = useTheme();
205
207
  const isDownSm = useMediaQuery(theme.breakpoints.down('sm'));
206
208
  const isDownMd = useMediaQuery(theme.breakpoints.down('md'));
209
+ const isUPLg = useMediaQuery(theme.breakpoints.up('lg'));
207
210
 
208
211
  // If size is auto, need calculate actual size according to screen size
209
212
  // eslint-disable-next-line no-nested-ternary
210
213
  const actualSize = size === 'auto' ? (isDownSm ? 'xs' : isDownMd ? 'sm' : 'md') : size;
214
+ // eslint-disable-next-line no-nested-ternary
215
+ const didAvatarSize = size === 'auto' ? (isUPLg ? 100 : 48) : size === 'md' ? 100 : 48;
211
216
  const container = useRef(null);
212
217
 
213
218
  return (
@@ -218,10 +223,16 @@ export default function Blocklet({
218
223
  <div className="arcblock-blocklet__content">
219
224
  <div className="arcblock-blocklet__content--main" onClick={_onMainClick} ref={container}>
220
225
  <div className="arcblock-blocklet__content--body">
221
- {cover && (
226
+ {cover ? (
222
227
  <div className="arcblock-blocklet__cover">
223
228
  <Img src={cover} />
224
229
  </div>
230
+ ) : (
231
+ did && (
232
+ <div className="arcblock-blocklet__cover">
233
+ <Avatar did={did} size={didAvatarSize} />
234
+ </div>
235
+ )
225
236
  )}
226
237
  <div className="arcblock-blocklet__info">
227
238
  <Typography
@@ -299,6 +310,7 @@ export default function Blocklet({
299
310
 
300
311
  Blocklet.propTypes = {
301
312
  title: PropTypes.string.isRequired,
313
+ did: PropTypes.string,
302
314
  isStickyButton: PropTypes.bool,
303
315
  description: PropTypes.string,
304
316
  cover: PropTypes.string,
@@ -319,6 +331,7 @@ Blocklet.propTypes = {
319
331
  Blocklet.defaultProps = {
320
332
  description: null,
321
333
  cover: null,
334
+ did: null,
322
335
  isStickyButton: false,
323
336
  buttonText: 'Install',
324
337
  buttonDisabled: false,
@@ -25,6 +25,7 @@ import 'highlight.js/styles/atom-one-dark.css';
25
25
 
26
26
  import CopyIcon from '@material-ui/icons/FileCopy';
27
27
  import CheckIcon from '@material-ui/icons/Check';
28
+ import colors from '../Colors';
28
29
 
29
30
  hljs.registerLanguage('javascript', javascript);
30
31
  hljs.registerLanguage('js', javascript);
@@ -126,6 +127,14 @@ const Pre = styled.pre`
126
127
  position: absolute;
127
128
  top: 8px;
128
129
  right: 24px;
130
+ padding: 4px;
131
+ border-radius: 4px;
132
+
133
+ &,
134
+ &:hover,
135
+ &.Mui-disabled {
136
+ background: ${colors.primary.main};
137
+ }
129
138
  }
130
139
 
131
140
  &:hover {