@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.
- package/esm/_internal/Avatar2.js +5 -1
- package/esm/_internal/Avatar2.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +2 -0
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/Tooltip2.js +0 -5
- package/esm/_internal/Tooltip2.js.map +1 -1
- package/esm/_internal/UserBlock.js +42 -17
- package/esm/_internal/UserBlock.js.map +1 -1
- package/esm/_internal/user-block.js +2 -0
- package/esm/_internal/user-block.js.map +1 -1
- package/package.json +4 -4
- package/src/components/avatar/Avatar.stories.tsx +30 -53
- package/src/components/avatar/Avatar.tsx +8 -0
- package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +193 -330
- package/src/components/thumbnail/Thumbnail.stories.tsx +8 -7
- package/src/components/thumbnail/Thumbnail.test.tsx +1 -7
- package/src/components/thumbnail/Thumbnail.tsx +2 -0
- package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +4 -2
- package/src/components/tooltip/Tooltip.stories.tsx +7 -4
- package/src/components/tooltip/useInjectTooltipRef.tsx +1 -3
- package/src/components/user-block/UserBlock.stories.tsx +65 -105
- package/src/components/user-block/UserBlock.test.tsx +6 -0
- package/src/components/user-block/UserBlock.tsx +51 -25
- package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +113 -143
- package/src/stories/generated/Badge/Demos.stories.tsx +1 -0
- package/src/stories/generated/Flag/Demos.stories.tsx +6 -0
- package/src/stories/generated/Thumbnail/Demos.stories.tsx +1 -0
- package/src/stories/utils/CustomLink.tsx +7 -0
- package/types.d.ts +14 -4
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { select } from '@storybook/addon-knobs';
|
|
3
|
+
|
|
1
4
|
import { mdiDelete, mdiEye, mdiPencil, mdiStar } from '@lumx/icons';
|
|
2
|
-
import {
|
|
5
|
+
import { Badge, ColorPalette, FlexBox, Icon, IconButton, Size } from '@lumx/react';
|
|
3
6
|
import { AVATAR_IMAGES, avatarImageKnob, PORTRAIT_IMAGES } from '@lumx/react/stories/knobs/image';
|
|
4
|
-
import {
|
|
5
|
-
import React from 'react';
|
|
7
|
+
import { CustomLink } from '@lumx/react/stories/utils/CustomLink';
|
|
6
8
|
|
|
7
9
|
import { Avatar } from './Avatar';
|
|
8
10
|
|
|
9
11
|
export default { title: 'LumX components/avatar/Avatar' };
|
|
10
12
|
|
|
11
|
-
const AVATAR_SIZES
|
|
13
|
+
const AVATAR_SIZES = [Size.xs, Size.s, Size.m, Size.l, Size.xl, Size.xxl];
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Avatar stories showing a simple Avatar with different sizes.
|
|
15
17
|
* @return component with different sizes.
|
|
16
18
|
*/
|
|
17
|
-
export const
|
|
19
|
+
export const Sizes = () =>
|
|
18
20
|
AVATAR_SIZES.map((size) => (
|
|
19
21
|
<Avatar
|
|
20
22
|
key={size}
|
|
@@ -29,7 +31,7 @@ export const AvatarSizes = () =>
|
|
|
29
31
|
* Avatar story showing a simple avatar with different actions.
|
|
30
32
|
* @return component with different actions.
|
|
31
33
|
*/
|
|
32
|
-
export const
|
|
34
|
+
export const WithActions = () =>
|
|
33
35
|
AVATAR_SIZES.map((size) => (
|
|
34
36
|
<Avatar
|
|
35
37
|
key={size}
|
|
@@ -37,45 +39,16 @@ export const AvatarWithActions = () =>
|
|
|
37
39
|
alt={size}
|
|
38
40
|
size={size}
|
|
39
41
|
actions={
|
|
40
|
-
<
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
emphasis={Emphasis.low}
|
|
46
|
-
hasBackground
|
|
47
|
-
icon={mdiPencil}
|
|
48
|
-
size={Size.s}
|
|
49
|
-
/>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<div className="lumx-spacing-margin-right-regular">
|
|
53
|
-
<IconButton
|
|
54
|
-
label="See"
|
|
55
|
-
color="dark"
|
|
56
|
-
emphasis={Emphasis.low}
|
|
57
|
-
hasBackground
|
|
58
|
-
icon={mdiEye}
|
|
59
|
-
size={Size.s}
|
|
60
|
-
/>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<div>
|
|
64
|
-
<IconButton
|
|
65
|
-
label="Delete"
|
|
66
|
-
color="dark"
|
|
67
|
-
emphasis={Emphasis.low}
|
|
68
|
-
hasBackground
|
|
69
|
-
icon={mdiDelete}
|
|
70
|
-
size={Size.s}
|
|
71
|
-
/>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
42
|
+
<FlexBox orientation="horizontal" gap="regular" vAlign="center">
|
|
43
|
+
<IconButton label="Edit" emphasis="low" hasBackground icon={mdiPencil} size="s" />
|
|
44
|
+
<IconButton label="See" emphasis="low" hasBackground icon={mdiEye} size="s" />
|
|
45
|
+
<IconButton label="Delete" emphasis="low" hasBackground icon={mdiDelete} size="s" />
|
|
46
|
+
</FlexBox>
|
|
74
47
|
}
|
|
75
48
|
/>
|
|
76
49
|
));
|
|
77
50
|
|
|
78
|
-
export const
|
|
51
|
+
export const WithBadge = () =>
|
|
79
52
|
AVATAR_SIZES.map((size) => (
|
|
80
53
|
<Avatar
|
|
81
54
|
key={size}
|
|
@@ -91,7 +64,7 @@ export const AvatarWithBadge = () =>
|
|
|
91
64
|
/>
|
|
92
65
|
));
|
|
93
66
|
|
|
94
|
-
export const
|
|
67
|
+
export const WithRectangularImage = () =>
|
|
95
68
|
AVATAR_SIZES.map((size) => (
|
|
96
69
|
<Avatar
|
|
97
70
|
key={size}
|
|
@@ -102,14 +75,18 @@ export const AvatarWithRectangularImage = () =>
|
|
|
102
75
|
/>
|
|
103
76
|
));
|
|
104
77
|
|
|
105
|
-
export const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
78
|
+
export const Clickable = () => {
|
|
79
|
+
const baseProps = { size: 'l', image: AVATAR_IMAGES.avatar2, alt: 'avatar2' } as any;
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
<p>As a button</p>
|
|
83
|
+
<Avatar {...baseProps} onClick={() => alert('clicked on avatar')} />
|
|
84
|
+
|
|
85
|
+
<p>As a link</p>
|
|
86
|
+
<Avatar {...baseProps} linkProps={{ href: 'https://example.com' }} />
|
|
87
|
+
|
|
88
|
+
<p>As a custom link component</p>
|
|
89
|
+
<Avatar {...baseProps} linkAs={CustomLink} />
|
|
90
|
+
</>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
@@ -23,6 +23,10 @@ export interface AvatarProps extends GenericProps {
|
|
|
23
23
|
badge?: ReactElement;
|
|
24
24
|
/** Image URL. */
|
|
25
25
|
image: string;
|
|
26
|
+
/** Props to pass to the link wrapping the thumbnail. */
|
|
27
|
+
linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
28
|
+
/** Custom react component for the link (can be used to inject react router Link). */
|
|
29
|
+
linkAs?: 'a' | any;
|
|
26
30
|
/** On click callback. */
|
|
27
31
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
28
32
|
/** On key press callback. */
|
|
@@ -70,6 +74,8 @@ export const Avatar: Comp<AvatarProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
70
74
|
badge,
|
|
71
75
|
className,
|
|
72
76
|
image,
|
|
77
|
+
linkProps,
|
|
78
|
+
linkAs,
|
|
73
79
|
onClick,
|
|
74
80
|
onKeyPress,
|
|
75
81
|
size,
|
|
@@ -85,6 +91,8 @@ export const Avatar: Comp<AvatarProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
85
91
|
className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, size, theme }))}
|
|
86
92
|
>
|
|
87
93
|
<Thumbnail
|
|
94
|
+
linkProps={linkProps}
|
|
95
|
+
linkAs={linkAs}
|
|
88
96
|
className={`${CLASSNAME}__thumbnail`}
|
|
89
97
|
onClick={onClick}
|
|
90
98
|
onKeyPress={onKeyPress}
|