superdesk-ui-framework 3.0.50 → 3.0.53

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.
@@ -13,6 +13,7 @@ $simple-list-border-color: $neutral-border-color;
13
13
  flex-direction: row;
14
14
  align-items: center;
15
15
  gap: 0.8rem;
16
+ color: var(--color-text);
16
17
 
17
18
  [class^="icon-"], [class*=" icon-"] {
18
19
  flex-grow: 0;
@@ -16,6 +16,7 @@ $sd-ListItem-column-border: var(--sd-colour-line--x-light);
16
16
  background-color: $sd-ListItem-background;
17
17
  transition: background-color 0.2s linear;
18
18
  flex-shrink: 0;
19
+ color: var(--color-text);
19
20
 
20
21
  &:hover {
21
22
  background-color: $sd-ListItem-background-hover;
@@ -3,13 +3,17 @@ import {IPropsBase} from './interfaces';
3
3
 
4
4
  interface IPropsImageAvatar extends IPropsBase {
5
5
  imageUrl?: string | null; // defaults to a placeholder image
6
+ onClick?(): void;
6
7
  }
7
8
 
8
9
  export class AvatarContentImage extends React.PureComponent<IPropsImageAvatar> {
9
10
  render() {
10
- if (this.props.imageUrl == null) {
11
+ const {imageUrl, tooltipText, onClick} = this.props;
12
+ const role: string | undefined = onClick == null ? undefined : 'button';
13
+
14
+ if (imageUrl == null) {
11
15
  return (
12
- <span className="sd-avatar-content sd-avatar-content--dummy-img" title={this.props.tooltipText}>
16
+ <span className="sd-avatar-content sd-avatar-content--dummy-img" title={tooltipText} role={role}>
13
17
  <svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
14
18
  <circle cx="100" cy="100" r="100" fill="white" fill-opacity="0.01"/>
15
19
  <path fill-rule="evenodd" clip-rule="evenodd" d="M40 153V145.384C40 141.557 41.16 137.981 43.16 135C49.14 126.057 66.24 119.711 77.14 118C82.74 117.115 90.16 116.538 100 116.538C109.84 116.538 117.26 117.115 122.86 118C133.76 119.711 150.86 126.057 156.84 135C158.84 137.981 160 141.557 160 145.384V153C150 165 130 180 100 180C70 180 50 165 40 153ZM100 30C122.08 30 140 47.2307 140 68.4614C140 89.6922 122.08 106.923 100 106.923C77.92 106.923 60 89.6922 60 68.4614C60 47.2307 77.92 30 100 30Z" fill="var(--sd-colour-avatar-dummy)" fill-opacity="1"/>
@@ -17,8 +21,8 @@ export class AvatarContentImage extends React.PureComponent<IPropsImageAvatar> {
17
21
  </span>);
18
22
  } else {
19
23
  return (
20
- <span className="sd-avatar-content" title={this.props.tooltipText} >
21
- <img src={this.props.imageUrl} />
24
+ <span className="sd-avatar-content" title={tooltipText} role={role}>
25
+ <img src={imageUrl} />
22
26
  </span>
23
27
  );
24
28
  }
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import {AvatarWrapper} from './avatar-wrapper';
3
3
  import {AvatarContentAdd} from './avatar-action-add';
4
+ import {AvatarContentImage} from './avatar-image';
4
5
 
5
6
  export interface IPropsAvatarPlaceholder {
6
7
  // kind is used to it's easy to add
7
8
  // other types of placeholders without breaking existing usages
8
- kind: 'plus-button';
9
+ kind: 'plus-button' | 'user-icon';
9
10
  tooltip?: string | null; // nullable, but mandatory to communicate importance
10
11
 
11
12
  size: 'x-small' | 'small' | 'medium' | 'large' | 'x-large' | 'xx-large';
@@ -20,7 +21,7 @@ export interface IPropsAvatarPlaceholder {
20
21
 
21
22
  export class AvatarPlaceholder extends React.PureComponent<IPropsAvatarPlaceholder> {
22
23
  render() {
23
- const {size, tooltip, icon} = this.props;
24
+ const {size, tooltip, icon, kind, onClick} = this.props;
24
25
 
25
26
  return (
26
27
  <AvatarWrapper
@@ -28,7 +29,26 @@ export class AvatarPlaceholder extends React.PureComponent<IPropsAvatarPlacehold
28
29
  isEmpty={false}
29
30
  icon={icon}
30
31
  >
31
- <AvatarContentAdd tooltipText={tooltip ?? undefined} onClick={this.props.onClick} />
32
+ {(() => {
33
+ if (kind === 'plus-button') {
34
+ return (
35
+ <AvatarContentAdd
36
+ tooltipText={tooltip ?? undefined}
37
+ onClick={onClick}
38
+ />
39
+ );
40
+ } else if (kind === 'user-icon') {
41
+ return (
42
+ <AvatarContentImage
43
+ imageUrl={null}
44
+ tooltipText={tooltip ?? undefined}
45
+ onClick={onClick}
46
+ />
47
+ );
48
+ } else {
49
+ return null;
50
+ }
51
+ })()}
32
52
  </AvatarWrapper>
33
53
  );
34
54
  }
@@ -18,11 +18,35 @@ export interface IPropsAvatar {
18
18
  name: string;
19
19
  color?: string;
20
20
  };
21
+
22
+ /**
23
+ * displayName is shown as tooltip by default
24
+ * use this if you need to add additional information (it will be added on a new line)
25
+ */
26
+ tooltip?: string;
27
+
28
+ /**
29
+ * JSX resulting from rendering of one of the following components:
30
+ * AvatarContentText
31
+ * AvatarContentImage
32
+ */
33
+ customContent?: JSX.Element;
21
34
  }
22
35
 
23
36
  export class Avatar extends React.PureComponent<IPropsAvatar> {
24
37
  render() {
25
- const {imageUrl, initials, size, statusIndicator, administratorIndicator, icon, displayName} = this.props;
38
+ const {
39
+ imageUrl,
40
+ initials,
41
+ size,
42
+ statusIndicator,
43
+ administratorIndicator,
44
+ icon,
45
+ displayName,
46
+ customContent,
47
+ } = this.props;
48
+
49
+ const tooltipCombined = [displayName, this.props.tooltip].filter((str) => (str ?? '').trim().length > 0).join('\n');
26
50
 
27
51
  return (
28
52
  <AvatarWrapper
@@ -32,16 +56,19 @@ export class Avatar extends React.PureComponent<IPropsAvatar> {
32
56
  icon={icon}
33
57
  isEmpty={false}
34
58
  >
35
- {
36
- imageUrl != null || initials == null
37
- ? (
38
- <AvatarContentImage imageUrl={imageUrl} tooltipText={displayName} />
39
- )
40
- : (
41
- <AvatarContentText text={initials} tooltipText={displayName} />
42
- )
43
- }
44
-
59
+ {(() => {
60
+ if (customContent != null) {
61
+ return customContent;
62
+ } else if (imageUrl != null || initials == null) {
63
+ return (
64
+ <AvatarContentImage imageUrl={imageUrl} tooltipText={tooltipCombined} />
65
+ );
66
+ } else {
67
+ return (
68
+ <AvatarContentText text={initials} tooltipText={tooltipCombined} />
69
+ );
70
+ }
71
+ })()}
45
72
  </AvatarWrapper>
46
73
  );
47
74
  }