@soul-refiner/design-system 0.2.97 → 0.2.98
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.
|
@@ -14,13 +14,14 @@ export interface AvatarProps extends NativeProps {
|
|
|
14
14
|
sx?: string;
|
|
15
15
|
textPosition?: 'left' | 'right';
|
|
16
16
|
title?: React.ReactNode;
|
|
17
|
+
tooltipContent?: React.ReactElement;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
*
|
|
20
21
|
* Avatar
|
|
21
22
|
*/
|
|
22
23
|
declare const Avatar: {
|
|
23
|
-
({ as, href, image, size, status, subtitle, sx, textPosition, title, ...rest }: AvatarProps): React.JSX.Element;
|
|
24
|
+
({ as, href, image, size, status, subtitle, sx, textPosition, title, tooltipContent, ...rest }: AvatarProps): React.JSX.Element;
|
|
24
25
|
displayName: string;
|
|
25
26
|
Group: {
|
|
26
27
|
({ children, numDisplayed, total }: AvatarGroupProps): React.JSX.Element;
|
|
@@ -57,10 +57,16 @@ const iconOffsetY = {
|
|
|
57
57
|
*
|
|
58
58
|
* Avatar
|
|
59
59
|
*/
|
|
60
|
-
const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, textPosition = 'left', title, ...rest }) => {
|
|
60
|
+
const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, textPosition = 'left', title, tooltipContent, ...rest }) => {
|
|
61
61
|
const [displayDefault, setDisplayDefault] = React.useState(false);
|
|
62
62
|
const Icon = iconReference?.[status ?? 'none'];
|
|
63
|
-
return (React.createElement(Box, { "$align": "center", "$gap": 18,
|
|
63
|
+
return (React.createElement(Box, { "$align": "center", "$gap": 18, sx: `
|
|
64
|
+
position: relative;
|
|
65
|
+
&:hover > div:nth-of-type(2) {
|
|
66
|
+
display: flex;
|
|
67
|
+
}
|
|
68
|
+
${sx}
|
|
69
|
+
`, ...rest },
|
|
64
70
|
React.createElement(Container, { as: as, "$size": size, href: href },
|
|
65
71
|
!displayDefault && (React.createElement("img", { src: image ?? '', onError: () => setDisplayDefault(true) })),
|
|
66
72
|
displayDefault && React.createElement(Default, null),
|
|
@@ -68,7 +74,8 @@ const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, t
|
|
|
68
74
|
React.createElement(Icon, null))),
|
|
69
75
|
(title || subtitle) && (React.createElement(TextContainer, { "$textPosition": textPosition },
|
|
70
76
|
title && (React.createElement(H, { as: "h3", "$bold": true, "$color": "grey-2", "$textClampLines": 1, sx: "font-size: 26px;" }, title)),
|
|
71
|
-
subtitle && (React.createElement(P, { "$color": "grey-4", "$textClampLines": 1 }, subtitle))))
|
|
77
|
+
subtitle && (React.createElement(P, { "$color": "grey-4", "$textClampLines": 1 }, subtitle)))),
|
|
78
|
+
tooltipContent && React.createElement(TooltipContainer, null, tooltipContent)));
|
|
72
79
|
};
|
|
73
80
|
Avatar.displayName = 'Avatar';
|
|
74
81
|
const Container = styled.div `
|
|
@@ -107,6 +114,15 @@ const TextContainer = styled.div `
|
|
|
107
114
|
gap: 4px;
|
|
108
115
|
order: ${({ $textPosition }) => ($textPosition === 'left' ? -1 : 1)};
|
|
109
116
|
`;
|
|
117
|
+
const TooltipContainer = styled.div `
|
|
118
|
+
display: none;
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 100%;
|
|
121
|
+
left: -50%;
|
|
122
|
+
background-color: var(--color-white);
|
|
123
|
+
border-radius: 24px;
|
|
124
|
+
box-shadow: var(--elevation-2);
|
|
125
|
+
`;
|
|
110
126
|
const Group = ({ children, numDisplayed, total }) => {
|
|
111
127
|
let size = 0;
|
|
112
128
|
// filter out ReactNodes and ReactElements that are not Avatars
|