@lumx/react 2.2.0 → 2.2.2

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 (29) hide show
  1. package/esm/_internal/Avatar2.js +5 -1
  2. package/esm/_internal/Avatar2.js.map +1 -1
  3. package/esm/_internal/Thumbnail2.js +2 -0
  4. package/esm/_internal/Thumbnail2.js.map +1 -1
  5. package/esm/_internal/Tooltip2.js +0 -5
  6. package/esm/_internal/Tooltip2.js.map +1 -1
  7. package/esm/_internal/UserBlock.js +42 -17
  8. package/esm/_internal/UserBlock.js.map +1 -1
  9. package/esm/_internal/user-block.js +2 -0
  10. package/esm/_internal/user-block.js.map +1 -1
  11. package/package.json +4 -4
  12. package/src/components/avatar/Avatar.stories.tsx +30 -53
  13. package/src/components/avatar/Avatar.tsx +8 -0
  14. package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +193 -330
  15. package/src/components/thumbnail/Thumbnail.stories.tsx +8 -7
  16. package/src/components/thumbnail/Thumbnail.test.tsx +1 -7
  17. package/src/components/thumbnail/Thumbnail.tsx +2 -0
  18. package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +4 -2
  19. package/src/components/tooltip/Tooltip.stories.tsx +7 -4
  20. package/src/components/tooltip/useInjectTooltipRef.tsx +1 -3
  21. package/src/components/user-block/UserBlock.stories.tsx +65 -105
  22. package/src/components/user-block/UserBlock.test.tsx +6 -0
  23. package/src/components/user-block/UserBlock.tsx +51 -25
  24. package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +113 -143
  25. package/src/stories/generated/Badge/Demos.stories.tsx +1 -0
  26. package/src/stories/generated/Flag/Demos.stories.tsx +6 -0
  27. package/src/stories/generated/Thumbnail/Demos.stories.tsx +1 -0
  28. package/src/stories/utils/CustomLink.tsx +7 -0
  29. package/types.d.ts +14 -4
@@ -1,43 +1,28 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`<UserBlock> Snapshots and structure should render story 'InList' 1`] = `
3
+ exports[`<UserBlock> Snapshots and structure should render story 'Clickable' 1`] = `
4
4
  Array [
5
5
  <div
6
- className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light"
7
- onMouseEnter={[Function]}
8
- onMouseLeave={[Function]}
6
+ className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light lumx-user-block--is-clickable"
9
7
  >
10
- <div
8
+ <Avatar
9
+ alt="Avatar"
11
10
  className="lumx-user-block__avatar"
12
- >
13
- <Avatar
14
- alt="Avatar"
15
- badge={
16
- <Badge
17
- color="blue"
18
- >
19
- <Icon
20
- icon="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"
21
- />
22
- </Badge>
23
- }
24
- image="/demo-assets/avatar1.jpg"
25
- onClick={[Function]}
26
- size="m"
27
- tabIndex={0}
28
- theme="light"
29
- />
30
- </div>
11
+ image="/demo-assets/avatar1.jpg"
12
+ onClick={[Function]}
13
+ size="m"
14
+ theme="light"
15
+ />
31
16
  <div
32
17
  className="lumx-user-block__wrapper"
33
18
  >
34
- <span
19
+ <Link
35
20
  className="lumx-user-block__name"
21
+ color="dark"
36
22
  onClick={[Function]}
37
- tabIndex={0}
38
23
  >
39
24
  Emmitt O. Lum
40
- </span>
25
+ </Link>
41
26
  <div
42
27
  className="lumx-user-block__fields"
43
28
  >
@@ -57,41 +42,30 @@ Array [
57
42
  </div>
58
43
  </div>,
59
44
  <div
60
- className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light"
61
- onMouseEnter={[Function]}
62
- onMouseLeave={[Function]}
45
+ className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light lumx-user-block--is-clickable"
63
46
  >
64
- <div
47
+ <Avatar
48
+ alt="Avatar"
65
49
  className="lumx-user-block__avatar"
66
- >
67
- <Avatar
68
- alt="Avatar"
69
- badge={
70
- <Badge
71
- color="blue"
72
- >
73
- <Icon
74
- icon="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"
75
- />
76
- </Badge>
50
+ image="/demo-assets/avatar1.jpg"
51
+ linkProps={
52
+ Object {
53
+ "href": "https://example.com",
77
54
  }
78
- image="/demo-assets/avatar2.jpg"
79
- onClick={[Function]}
80
- size="m"
81
- tabIndex={0}
82
- theme="light"
83
- />
84
- </div>
55
+ }
56
+ size="m"
57
+ theme="light"
58
+ />
85
59
  <div
86
60
  className="lumx-user-block__wrapper"
87
61
  >
88
- <span
62
+ <Link
89
63
  className="lumx-user-block__name"
90
- onClick={[Function]}
91
- tabIndex={0}
64
+ color="dark"
65
+ href="https://example.com"
92
66
  >
93
67
  Emmitt O. Lum
94
- </span>
68
+ </Link>
95
69
  <div
96
70
  className="lumx-user-block__fields"
97
71
  >
@@ -111,41 +85,26 @@ Array [
111
85
  </div>
112
86
  </div>,
113
87
  <div
114
- className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light"
115
- onMouseEnter={[Function]}
116
- onMouseLeave={[Function]}
88
+ className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light lumx-user-block--is-clickable"
117
89
  >
118
- <div
90
+ <Avatar
91
+ alt="Avatar"
119
92
  className="lumx-user-block__avatar"
120
- >
121
- <Avatar
122
- alt="Avatar"
123
- badge={
124
- <Badge
125
- color="blue"
126
- >
127
- <Icon
128
- icon="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"
129
- />
130
- </Badge>
131
- }
132
- image="/demo-assets/avatar3.jpg"
133
- onClick={[Function]}
134
- size="m"
135
- tabIndex={0}
136
- theme="light"
137
- />
138
- </div>
93
+ image="/demo-assets/avatar1.jpg"
94
+ linkAs={[Function]}
95
+ size="m"
96
+ theme="light"
97
+ />
139
98
  <div
140
99
  className="lumx-user-block__wrapper"
141
100
  >
142
- <span
101
+ <Link
143
102
  className="lumx-user-block__name"
144
- onClick={[Function]}
145
- tabIndex={0}
103
+ color="dark"
104
+ linkAs={[Function]}
146
105
  >
147
106
  Emmitt O. Lum
148
- </span>
107
+ </Link>
149
108
  <div
150
109
  className="lumx-user-block__fields"
151
110
  >
@@ -167,6 +126,47 @@ Array [
167
126
  ]
168
127
  `;
169
128
 
129
+ exports[`<UserBlock> Snapshots and structure should render story 'Default' 1`] = `
130
+ <div
131
+ className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light"
132
+ onMouseEnter={[Function]}
133
+ onMouseLeave={[Function]}
134
+ >
135
+ <Avatar
136
+ alt="Avatar"
137
+ className="lumx-user-block__avatar"
138
+ image="/demo-assets/avatar1.jpg"
139
+ size="m"
140
+ theme="light"
141
+ />
142
+ <div
143
+ className="lumx-user-block__wrapper"
144
+ >
145
+ <span
146
+ className="lumx-user-block__name"
147
+ >
148
+ Emmitt O. Lum
149
+ </span>
150
+ <div
151
+ className="lumx-user-block__fields"
152
+ >
153
+ <span
154
+ className="lumx-user-block__field"
155
+ key="0"
156
+ >
157
+ Creative developer
158
+ </span>
159
+ <span
160
+ className="lumx-user-block__field"
161
+ key="1"
162
+ >
163
+ Denpasar
164
+ </span>
165
+ </div>
166
+ </div>
167
+ </div>
168
+ `;
169
+
170
170
  exports[`<UserBlock> Snapshots and structure should render story 'Sizes' 1`] = `
171
171
  Array [
172
172
  <div
@@ -174,25 +174,18 @@ Array [
174
174
  onMouseEnter={[Function]}
175
175
  onMouseLeave={[Function]}
176
176
  >
177
- <div
177
+ <Avatar
178
+ alt="Avatar"
178
179
  className="lumx-user-block__avatar"
179
- >
180
- <Avatar
181
- alt="Avatar"
182
- image="/demo-assets/avatar1.jpg"
183
- onClick={[Function]}
184
- size="s"
185
- tabIndex={0}
186
- theme="light"
187
- />
188
- </div>
180
+ image="/demo-assets/avatar1.jpg"
181
+ size="s"
182
+ theme="light"
183
+ />
189
184
  <div
190
185
  className="lumx-user-block__wrapper"
191
186
  >
192
187
  <span
193
188
  className="lumx-user-block__name"
194
- onClick={[Function]}
195
- tabIndex={0}
196
189
  >
197
190
  Emmitt O. Lum
198
191
  </span>
@@ -203,25 +196,18 @@ Array [
203
196
  onMouseEnter={[Function]}
204
197
  onMouseLeave={[Function]}
205
198
  >
206
- <div
199
+ <Avatar
200
+ alt="Avatar"
207
201
  className="lumx-user-block__avatar"
208
- >
209
- <Avatar
210
- alt="Avatar"
211
- image="/demo-assets/avatar1.jpg"
212
- onClick={[Function]}
213
- size="m"
214
- tabIndex={0}
215
- theme="light"
216
- />
217
- </div>
202
+ image="/demo-assets/avatar1.jpg"
203
+ size="m"
204
+ theme="light"
205
+ />
218
206
  <div
219
207
  className="lumx-user-block__wrapper"
220
208
  >
221
209
  <span
222
210
  className="lumx-user-block__name"
223
- onClick={[Function]}
224
- tabIndex={0}
225
211
  >
226
212
  Emmitt O. Lum
227
213
  </span>
@@ -248,25 +234,18 @@ Array [
248
234
  onMouseEnter={[Function]}
249
235
  onMouseLeave={[Function]}
250
236
  >
251
- <div
237
+ <Avatar
238
+ alt="Avatar"
252
239
  className="lumx-user-block__avatar"
253
- >
254
- <Avatar
255
- alt="Avatar"
256
- image="/demo-assets/avatar1.jpg"
257
- onClick={[Function]}
258
- size="l"
259
- tabIndex={0}
260
- theme="light"
261
- />
262
- </div>
240
+ image="/demo-assets/avatar1.jpg"
241
+ size="l"
242
+ theme="light"
243
+ />
263
244
  <div
264
245
  className="lumx-user-block__wrapper"
265
246
  >
266
247
  <span
267
248
  className="lumx-user-block__name"
268
- onClick={[Function]}
269
- tabIndex={0}
270
249
  >
271
250
  Emmitt O. Lum
272
251
  </span>
@@ -294,37 +273,28 @@ Array [
294
273
  exports[`<UserBlock> Snapshots and structure should render story 'WithBadge' 1`] = `
295
274
  <div
296
275
  className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light"
297
- onMouseEnter={[Function]}
298
- onMouseLeave={[Function]}
299
276
  >
300
- <div
277
+ <Avatar
278
+ alt="Avatar"
279
+ badge={
280
+ <Badge
281
+ color="blue"
282
+ >
283
+ <Icon
284
+ icon="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"
285
+ />
286
+ </Badge>
287
+ }
301
288
  className="lumx-user-block__avatar"
302
- >
303
- <Avatar
304
- alt="Avatar"
305
- badge={
306
- <Badge
307
- color="blue"
308
- >
309
- <Icon
310
- icon="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"
311
- />
312
- </Badge>
313
- }
314
- image="/demo-assets/avatar1.jpg"
315
- onClick={[Function]}
316
- size="m"
317
- tabIndex={0}
318
- theme="light"
319
- />
320
- </div>
289
+ image="/demo-assets/avatar1.jpg"
290
+ size="m"
291
+ theme="light"
292
+ />
321
293
  <div
322
294
  className="lumx-user-block__wrapper"
323
295
  >
324
296
  <span
325
297
  className="lumx-user-block__name"
326
- onClick={[Function]}
327
- tabIndex={0}
328
298
  >
329
299
  Emmitt O. Lum
330
300
  </span>
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export default { title: 'LumX components/badge/Badge Demos' };
5
5
 
6
+ export { App as Colors } from './colors';
6
7
  export { App as Icon } from './icon';
7
8
  export { App as Label } from './label';
8
9
  export { App as Thumbnail } from './thumbnail';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * File generated when storybook is started. Do not edit directly!
3
+ */
4
+ export default { title: 'LumX components/flag/Flag Demos' };
5
+
6
+ export { App as Flag } from './flag';
@@ -4,6 +4,7 @@
4
4
  export default { title: 'LumX components/thumbnail/Thumbnail Demos' };
5
5
 
6
6
  export { App as Combined } from './combined';
7
+ export { App as LoadingError } from './loading-error';
7
8
  export { App as Ratios } from './ratios';
8
9
  export { App as Sizes } from './sizes';
9
10
  export { App as Variants } from './variants';
@@ -0,0 +1,7 @@
1
+ /* eslint-disable jsx-a11y/anchor-has-content,jsx-a11y/anchor-is-valid */
2
+ import React from 'react';
3
+
4
+ /**
5
+ * Example custom link that can be used in linkAs props.
6
+ */
7
+ export const CustomLink: any = ({ ...props }) => <a href="#" data-custom-link {...props} />;
package/types.d.ts CHANGED
@@ -430,6 +430,10 @@ export interface AvatarProps extends GenericProps {
430
430
  badge?: ReactElement;
431
431
  /** Image URL. */
432
432
  image: string;
433
+ /** Props to pass to the link wrapping the thumbnail. */
434
+ linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
435
+ /** Custom react component for the link (can be used to inject react router Link). */
436
+ linkAs?: "a" | any;
433
437
  /** On click callback. */
434
438
  onClick?: MouseEventHandler<HTMLDivElement>;
435
439
  /** On key press callback. */
@@ -2528,16 +2532,22 @@ export declare type UserBlockSize = Extract<Size, "s" | "m" | "l">;
2528
2532
  export interface UserBlockProps extends GenericProps {
2529
2533
  /** Props to pass to the avatar. */
2530
2534
  avatarProps?: AvatarProps;
2531
- /** Simple action toolbar content. */
2532
- simpleAction?: ReactNode;
2533
- /** Multiple action toolbar content. */
2534
- multipleActions?: ReactNode;
2535
2535
  /** Additional fields used to describe the user. */
2536
2536
  fields?: string[];
2537
+ /** Props to pass to the link wrapping the avatar thumbnail. */
2538
+ linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
2539
+ /** Custom react component for the link (can be used to inject react router Link). */
2540
+ linkAs?: "a" | any;
2541
+ /** Multiple action toolbar content. */
2542
+ multipleActions?: ReactNode;
2537
2543
  /** User name. */
2538
2544
  name?: string;
2545
+ /** Props to pass to the name block. */
2546
+ nameProps?: GenericProps;
2539
2547
  /** Orientation. */
2540
2548
  orientation?: Orientation;
2549
+ /** Simple action toolbar content. */
2550
+ simpleAction?: ReactNode;
2541
2551
  /** Size variant. */
2542
2552
  size?: UserBlockSize;
2543
2553
  /** Theme adapting the component to light or dark background. */