@synerise/ds-avatar 2.1.3 → 2.2.1
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/CHANGELOG.md +19 -0
- package/CLAUDE.md +31 -18
- package/README.md +22 -22
- package/dist/Avatar.d.ts +1 -1
- package/dist/Avatar.js +20 -4
- package/dist/Avatar.styles.d.ts +7 -1
- package/dist/Avatar.styles.js +10 -17
- package/dist/Avatar.types.d.ts +17 -4
- package/dist/DefaultAvatarIcon.d.ts +1 -1
- package/dist/ObjectAvatar/ObjectAvatar.d.ts +1 -1
- package/dist/ObjectAvatar/ObjectAvatar.js +5 -13
- package/dist/UserAvatar/UserAvatar.d.ts +1 -1
- package/dist/UserAvatar/UserAvatar.js +6 -17
- package/dist/defaultAvatars/index.d.ts +37 -37
- package/dist/defaultAvatars/index.js +36 -36
- package/dist/utils.d.ts +3 -2
- package/dist/utils.js +7 -13
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.2.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-avatar@2.2.0...@synerise/ds-avatar@2.2.1) (2026-11-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-avatar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.2.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-avatar@2.1.3...@synerise/ds-avatar@2.2.0) (2026-11-17)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **icon:** add object icons and draw icon avatars as a bordered tile ([d3144c0](https://github.com/synerise/synerise-design/commit/d3144c0d350dec74c3629b26cfe12e4bcb393442))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [2.1.3](https://github.com/synerise/synerise-design/compare/@synerise/ds-avatar@2.1.2...@synerise/ds-avatar@2.1.3) (2026-11-17)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-avatar
|
package/CLAUDE.md
CHANGED
|
@@ -10,7 +10,7 @@ src/
|
|
|
10
10
|
Avatar.types.ts — all shared types (AvatarProps, UserAvatarProps, ObjectAvatarProps, …)
|
|
11
11
|
Avatar.styles.tsx — AvatarBase (DOM) + StyledAvatar (size/shape/bg/font); AvatarString/AvatarImg
|
|
12
12
|
Avatar.spec.tsx — base component tests
|
|
13
|
-
utils.ts — getUserText, getObjectName,
|
|
13
|
+
utils.ts — getUserText, getObjectName, getTextBackground, getTooltipProps, …
|
|
14
14
|
DefaultAvatarIcon.tsx — renders one of 100 default SVGs by index
|
|
15
15
|
defaultAvatars/ — auto-generated SVG components (build:svgr) + index.ts
|
|
16
16
|
UserAvatar/
|
|
@@ -18,7 +18,7 @@ src/
|
|
|
18
18
|
UserAvatar.spec.tsx
|
|
19
19
|
index.ts
|
|
20
20
|
ObjectAvatar/
|
|
21
|
-
ObjectAvatar.tsx — object/entity avatar, square shape,
|
|
21
|
+
ObjectAvatar.tsx — object/entity avatar, square shape, Close2M fallback icon
|
|
22
22
|
ObjectAvatar.spec.tsx
|
|
23
23
|
index.ts
|
|
24
24
|
index.ts — public exports
|
|
@@ -30,19 +30,32 @@ src/
|
|
|
30
30
|
|
|
31
31
|
Base component. DS-native; props are explicitly declared (no antd inheritance). `data-*` attributes pass through.
|
|
32
32
|
|
|
33
|
+
**No avatar takes a background colour.** What it shows decides its background:
|
|
34
|
+
|
|
35
|
+
| Content | Background |
|
|
36
|
+
|---|---|
|
|
37
|
+
| Image (`src`) | the image |
|
|
38
|
+
| Icon (`iconComponent`) | the icon tile (Figma): base background, 1px strong border, shadow 1 |
|
|
39
|
+
| Text (string `children`, e.g. initials) | the custom colour its first letter maps to (`selectColorByLetter`), shade 500 |
|
|
40
|
+
| Anything else (e.g. a `UserAvatar` illustration) | transparent |
|
|
41
|
+
|
|
42
|
+
The **frame** — the 1px border and shadow 1 — comes with the icon tile. `hasTile` puts that frame on an **image** avatar as well, leaving the photo itself untouched. Text avatars ignore it: they already carry a colour of their own.
|
|
43
|
+
|
|
44
|
+
`backgroundColor` / `backgroundColorHue` are **deprecated and have no effect** (on `Avatar`, `UserAvatar` and `ObjectAvatar`). They stay in the types until other repos stop passing them, and they never reach the DOM. The DS itself no longer uses them.
|
|
45
|
+
|
|
33
46
|
| Prop | Type | Default | Description |
|
|
34
47
|
|------|------|---------|-------------|
|
|
35
48
|
| `size` | `'small' \| 'medium' \| 'large' \| 'extraLarge'` | `'medium'` | Avatar size |
|
|
36
|
-
| `backgroundColor` | `Color \| string` | `undefined` | Named color or hex string; combined with `backgroundColorHue` for theme token lookup |
|
|
37
|
-
| `backgroundColorHue` | `'050'–'900'` | `'500'` | Hue suffix for the background color token |
|
|
38
49
|
| `iconComponent` | `ReactNode` | `undefined` | Icon to render; auto-scaled per size unless `iconScale={false}` |
|
|
39
50
|
| `iconScale` | `boolean` | `true` | Auto-scales `iconComponent` to the ICON_SIZES map for the active size |
|
|
40
51
|
| `hasStatus` | `boolean` | `false` | Shows a `Badge` dot positioned on the avatar corner (requires a `Badge` wrapper in the parent) |
|
|
52
|
+
| `hasTile` | `boolean` | `false` | Draws the tile border and shadow around an **image** avatar. An icon always has them; text and other content ignore it. Also accepted by `UserAvatar` and `ObjectAvatar` |
|
|
41
53
|
| `disabled` | `boolean` | `false` | Applies `opacity: 0.4; pointer-events: none` |
|
|
42
54
|
| `tooltip` | `TooltipObject \| boolean` | `false` | Tooltip config; `false` disables it; object keys map to ds-tooltip props |
|
|
43
55
|
| `src` | `string` | `undefined` | Image URL; empty string `""` is treated as `undefined` |
|
|
44
56
|
| `children` | `ReactNode` | `undefined` | Text initials or other content |
|
|
45
57
|
| `shape` | `'circle' \| 'square'` | `'circle'` | Avatar shape |
|
|
58
|
+
| `backgroundColor` / `backgroundColorHue` | — | — | **Deprecated**, no effect (see above) |
|
|
46
59
|
|
|
47
60
|
Sizes in px: `small` = 24, `medium` = 40, `large` = 84, `extraLarge` = 120.
|
|
48
61
|
|
|
@@ -55,7 +68,6 @@ High-level avatar for a user/client. Circle shape, auto-tooltip from user data.
|
|
|
55
68
|
| Prop | Type | Default | Description |
|
|
56
69
|
|------|------|---------|-------------|
|
|
57
70
|
| `user` | `UserAvatar` | `{}` | `{ firstName?, lastName?, email?, avatar?, avatarId? }` |
|
|
58
|
-
| `backgroundColor` | `'auto' \| Color \| string` | `undefined` | `'auto'` picks color from first initial; dash-separated `'grey-800'` sets both color and hue |
|
|
59
71
|
| `badgeStatus` | `BadgeStatus` | `undefined` | Wraps in `<Badge status>` when set; disables when `disabled=true` |
|
|
60
72
|
| `iconComponent` | `ReactNode` | `undefined` | Replaces the default `UserM`/`UserS` fallback icon |
|
|
61
73
|
| `size` | `Size` | `undefined` | Passed through to base Avatar |
|
|
@@ -67,21 +79,22 @@ High-level avatar for a user/client. Circle shape, auto-tooltip from user data.
|
|
|
67
79
|
|
|
68
80
|
**Render priority:** `avatar`/`src` photo → text initials (name or `text`) → default SVG (when `avatarId` is set) → fallback `UserM`/`UserS` icon.
|
|
69
81
|
|
|
70
|
-
`user.avatarId` is hashed deterministically to select one of 100 default SVGs. If `avatarId` is set and there are no initials or photo, the SVG is
|
|
82
|
+
`user.avatarId` is hashed deterministically to select one of 100 default SVGs. If `avatarId` is set and there are no initials or photo, the SVG is passed as content (not as an icon), so it sits on a transparent background without the icon tile.
|
|
83
|
+
|
|
84
|
+
Without initials or a photo, the fallback icon renders as the icon tile.
|
|
71
85
|
|
|
72
86
|
Tooltip is auto-generated from user data when `tooltip` is `undefined` or `true` — no need to pass tooltip props manually.
|
|
73
87
|
|
|
74
88
|
### `ObjectAvatar`
|
|
75
89
|
|
|
76
|
-
High-level avatar for objects/entities (products, campaigns, etc.). Square shape,
|
|
90
|
+
High-level avatar for objects/entities (products, campaigns, etc.). Square shape, `Close2M` icon fallback. Pass an object icon (`Object*M` from ds-icon) as `iconComponent`.
|
|
77
91
|
|
|
78
92
|
| Prop | Type | Default | Description |
|
|
79
93
|
|------|------|---------|-------------|
|
|
80
94
|
| `object` | `ObjectAvatar` | `{}` | `{ name?, description?, status?, avatar? }` |
|
|
81
95
|
| `color` | `Color` | `undefined` | Custom colour (600 shade) for the fallback icon; unset uses `--ds-avatar-icon-icon` |
|
|
82
|
-
| `backgroundColor` | `'auto' \| Color \| string` | `undefined` | Background colour; overrides the auto colour from `object.name`. Icon-only avatars use `--ds-avatar-icon-bg-*` unless this is set (`'auto'` counts as unset) |
|
|
83
96
|
| `badgeStatus` | `BadgeStatus` | `undefined` | Same as `UserAvatar` |
|
|
84
|
-
| `iconComponent` | `ReactNode` | `undefined` | Replaces default `
|
|
97
|
+
| `iconComponent` | `ReactNode` | `undefined` | Replaces the default `Close2M` fallback icon; use an object icon (`ObjectFunnelM`, `ObjectEmailM`, …) |
|
|
85
98
|
| `tooltip` | `TooltipObject \| boolean` | auto from `object` | `undefined` → auto-builds from `object.name`/`description`/`status`; `false` disables it |
|
|
86
99
|
| `text` | `string` | `undefined` | Override initials (uppercased) |
|
|
87
100
|
| `size` | `Size` | `undefined` | Passed through |
|
|
@@ -117,17 +130,17 @@ Exported constant — `100`. The actual number of built-in SVGs in `defaultAvata
|
|
|
117
130
|
import Avatar, { UserAvatar, ObjectAvatar } from '@synerise/ds-avatar';
|
|
118
131
|
import Icon, { FileM } from '@synerise/ds-icon';
|
|
119
132
|
|
|
120
|
-
// Basic with initials
|
|
121
|
-
<Avatar
|
|
133
|
+
// Basic with initials (background from the first letter)
|
|
134
|
+
<Avatar size="medium">JD</Avatar>
|
|
122
135
|
|
|
123
136
|
// With photo
|
|
124
137
|
<Avatar src="https://example.com/photo.jpg" size="medium" />
|
|
125
138
|
|
|
126
|
-
// With icon
|
|
127
|
-
<Avatar
|
|
139
|
+
// With icon (the icon tile)
|
|
140
|
+
<Avatar size="large" iconComponent={<Icon component={<FileM />} />} />
|
|
128
141
|
|
|
129
142
|
// With tooltip (backwards-compat name/email keys)
|
|
130
|
-
<Avatar
|
|
143
|
+
<Avatar tooltip={{ name: 'John Doe', email: 'jd@example.com' }}>JD</Avatar>
|
|
131
144
|
|
|
132
145
|
// UserAvatar — auto-initials and auto-tooltip
|
|
133
146
|
<UserAvatar
|
|
@@ -149,7 +162,7 @@ import Badge from '@synerise/ds-badge';
|
|
|
149
162
|
/>
|
|
150
163
|
|
|
151
164
|
// Disabled
|
|
152
|
-
<Avatar disabled
|
|
165
|
+
<Avatar disabled>AB</Avatar>
|
|
153
166
|
```
|
|
154
167
|
|
|
155
168
|
## Tooltip API
|
|
@@ -167,7 +180,9 @@ Tooltip type is auto-determined: if exactly one of `title`, `description`, `stat
|
|
|
167
180
|
Styles in `Avatar.styles.tsx`. A DS-native `AvatarBase` renders the `ant-avatar` root + `ant-avatar-string`/`<img>` child (with `ds-avatar-*` class hooks added alongside the `ant-*` ones during the antd-removal interim); the `StyledAvatar` styled-component applies all visual styling via props and styled sub-component references (`${AvatarString}`) — no `.ant-*` class selectors, except the cross-component `& ~ .ant-badge-dot` sibling (the dot is owned by ds-badge). Key styles:
|
|
168
181
|
|
|
169
182
|
- Dimensions per size set directly in CSS: `small` 24, `medium` 40, `large` 84, `extraLarge` 120 px
|
|
170
|
-
- Background
|
|
183
|
+
- Background follows the content (`$content` on `StyledAvatar`, see the table above). A text avatar's colour comes from `getTextBackground`: `selectColorByLetter` on the first character, resolved with ds-utils `resolveCustomColor` to the flipping `var(--ds-color-custom-<family>-500)` token, so it adapts to dark mode.
|
|
184
|
+
- The **icon tile** (Figma "Object icons", `i6XNJPIUGQHOVQrZ7LZEhE` 252:4297) is `--ds-color-background-base-default` plus the `tileFrame` helper, `1px solid --ds-color-border-base-strong` and `--ds-shadows-shadow-1`. `hasTile` applies that same `tileFrame` to an image avatar. These are semantic tokens because the design binds them directly and the avatar module has no tile border or shadow token. The 1px border sits inside the box (`border-box`), so an icon gets 2px less room.
|
|
185
|
+
- The tile's icon inherits `--ds-avatar-icon-icon` (set without `!important`) in place of the white `--ds-avatar-text-text`, so a container can recolour it (ds-list-item sets `.ds-avatar.ds-avatar { color: inherit }` in its prefix). Neither `UserAvatar` nor `ObjectAvatar` forces a colour on the icon; ObjectAvatar sets one only when its `color` prop is. Object icons (`Object*M`) carry token colours and ignore it either way.
|
|
171
186
|
- Badge dot (`ds-badge-dot`) is hidden by default; shown when `hasStatus=true` with size/shape-specific positioning from `BADGE_POSITION` map
|
|
172
187
|
- Hover/active darken overlay via `::before` pseudo-element (`--ds-avatar-overlay-opacity-hover` / `-pressed`) — only applied when `onClick` or `hasTooltip` is truthy
|
|
173
188
|
- Font sizes per size via `MACRO_MAPPING` (xsAvatar, small, xlAvatar macros from ds-typography)
|
|
@@ -183,9 +198,7 @@ Styles in `Avatar.styles.tsx`. A DS-native `AvatarBase` renders the `ant-avatar`
|
|
|
183
198
|
## Implementation notes
|
|
184
199
|
|
|
185
200
|
- `src=""` (empty string) is explicitly converted to `undefined` to prevent showing a broken image.
|
|
186
|
-
- `backgroundColor` is resolved with ds-utils `resolveCustomColor` (default hue `500` with text, `100` when empty; `'050'` → the `50` token; with no text a plain family or hex `backgroundColor` is used, not ignored); a hex value is used literally (a `var()` value only on the base `Avatar` — see Styling), and an unknown family or hue falls back to a `transparent` background.
|
|
187
201
|
- The 100 default SVG components in `defaultAvatars/` are **auto-generated** by `build:svgr` — do not edit them manually; regenerate via `pnpm run build:svgr`.
|
|
188
202
|
- `getDefaultAvatarIndex` uses a simple djb2-style hash on the string form of `avatarId` — the same `avatarId` always maps to the same avatar across all environments.
|
|
189
|
-
- `getColorByText` supports a `'color-hue'` dash-separated string shorthand for `backgroundColor` (e.g. `'grey-800'`) — this bypasses the separate `backgroundColorHue` prop entirely.
|
|
190
203
|
- When `badgeStatus` is used in `UserAvatar`/`ObjectAvatar`, the `style` prop is applied to a wrapping `<span>` instead of the avatar, to avoid breaking the badge positioning.
|
|
191
204
|
- `hasStatus` on the base `Avatar` only controls CSS visibility of the `ds-badge-dot` — the actual `Badge` component must be provided by the parent (UserAvatar/ObjectAvatar handle this internally).
|
package/README.md
CHANGED
|
@@ -37,12 +37,16 @@ Avatars have 4 sizes:
|
|
|
37
37
|
|
|
38
38
|
The **S**-sized avatars contain the **S**-sized icons of the **Standard icons set**. The **M**, **L** and **XL** sizes contain the **M**-sized icons.
|
|
39
39
|
|
|
40
|
+
Avatars take no background colour; what they show decides it. An image fills the avatar. An icon is drawn as an icon tile: the base background, a 1px strong border and the level-1 shadow (this covers the `UserAvatar` and `ObjectAvatar` fallback icons). Text, such as initials, gets the custom colour its first letter maps to. Anything else, such as a default `UserAvatar` illustration (`avatarId`), sits on a transparent background. `backgroundColor` and `backgroundColorHue` are deprecated and have no effect.
|
|
41
|
+
|
|
42
|
+
Pass `hasTile` to put the tile's border and shadow on an avatar that shows a photo; an icon avatar always has them, and a text avatar ignores it because it already has a colour of its own.
|
|
43
|
+
|
|
40
44
|
```
|
|
41
45
|
<div style={{ 'display': 'flex', 'justifyContent': 'space-between' }}>
|
|
42
|
-
<Avatar size="small"
|
|
43
|
-
<Avatar size="medium"
|
|
44
|
-
<Avatar size="large"
|
|
45
|
-
<Avatar size="extraLarge"
|
|
46
|
+
<Avatar size="small">JJ</Avatar>
|
|
47
|
+
<Avatar size="medium">JJ</Avatar>
|
|
48
|
+
<Avatar size="large">JJ</Avatar>
|
|
49
|
+
<Avatar size="extraLarge">JJ</Avatar>
|
|
46
50
|
</div>
|
|
47
51
|
```
|
|
48
52
|
|
|
@@ -62,10 +66,10 @@ We divide avatars into three types. Every type has its own use case. If a custom
|
|
|
62
66
|
|
|
63
67
|
```
|
|
64
68
|
<div style={{ 'display': 'flex', 'justifyContent': 'space-between' }}>
|
|
65
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="square" size="medium"
|
|
66
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="
|
|
67
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} src="https://www.w3schools.com/howto/img_avatar.png" size="large"
|
|
68
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} src="https://www.w3schools.com/howto/img_avatar.png" shape="square" size="extraLarge"
|
|
69
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="square" size="medium">JJ</Avatar>
|
|
70
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="circle" size="medium">JJ</Avatar>
|
|
71
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} src="https://www.w3schools.com/howto/img_avatar.png" size="large">JJ</Avatar>
|
|
72
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} src="https://www.w3schools.com/howto/img_avatar.png" shape="square" size="extraLarge">JJ</Avatar>
|
|
69
73
|
</div>
|
|
70
74
|
```
|
|
71
75
|
|
|
@@ -84,10 +88,10 @@ We can present avatars as a single entity or in a group.
|
|
|
84
88
|
|
|
85
89
|
```
|
|
86
90
|
<div style={{ 'display': 'flex', 'justifyContent': 'space-between' }}>
|
|
87
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="small"
|
|
88
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="medium"
|
|
89
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="large"
|
|
90
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="extraLarge"
|
|
91
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="small">JJ</Avatar>
|
|
92
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="medium">JJ</Avatar>
|
|
93
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="large">JJ</Avatar>
|
|
94
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} size="extraLarge">JJ</Avatar>
|
|
91
95
|
</div>
|
|
92
96
|
```
|
|
93
97
|
|
|
@@ -96,10 +100,10 @@ We can present avatars as a single entity or in a group.
|
|
|
96
100
|
```
|
|
97
101
|
import Icon, { FileM } from "@synerise/ds-icon";
|
|
98
102
|
<div style={{ 'display': 'flex', 'justifyContent': 'space-between' }}>
|
|
99
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="square" size="medium"
|
|
100
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="
|
|
101
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} iconComponent={<Icon component={<FileM />}
|
|
102
|
-
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} src="https://www.w3schools.com/howto/img_avatar.png" shape="square" size="extraLarge"
|
|
103
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="square" size="medium">JJ</Avatar>
|
|
104
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} shape="circle" size="medium">JJ</Avatar>
|
|
105
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} iconComponent={<Icon component={<FileM />} />} size="large">JJ</Avatar>
|
|
106
|
+
<Avatar tooltip={{name: 'Jan Janowski', email: 'jj@example.com'}} src="https://www.w3schools.com/howto/img_avatar.png" shape="square" size="extraLarge">JJ</Avatar>
|
|
103
107
|
</div>
|
|
104
108
|
```
|
|
105
109
|
|
|
@@ -122,15 +126,13 @@ yarn add @synerise/ds-avatar
|
|
|
122
126
|
```jsx static
|
|
123
127
|
import Avatar from '@synerise/ds-avatar';
|
|
124
128
|
|
|
125
|
-
<Avatar shape={'circle'}
|
|
129
|
+
<Avatar shape={'circle'} size="medium" />;
|
|
126
130
|
```
|
|
127
131
|
|
|
128
132
|
## API
|
|
129
133
|
|
|
130
134
|
| Property | Description | Type | Default |
|
|
131
135
|
| ------------------ | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------- |
|
|
132
|
-
| backgroundColor | Background color of the avatar | `red` / `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | - |
|
|
133
|
-
| backgroundColorHue | Background color hue of the avatar | `900` / `800` / `700` / `600` / `500` / `400` / `300` / `200` / `100` / `050` | `500` |
|
|
134
136
|
| disabled | Determines if avatar is disabled | boolean | `false` |
|
|
135
137
|
| hasStatus | Aligns a badge with the avatar | boolean | `false` |
|
|
136
138
|
| iconComponent | Provides a custom component as a child. If both are provided, the prop icon has a greater priority | React.ReactNode | - |
|
|
@@ -160,7 +162,6 @@ import { UserAvatar } from '@synerise/ds-avatar';
|
|
|
160
162
|
| Property | Description | Type | Default |
|
|
161
163
|
| --------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------- |
|
|
162
164
|
| user | User information | { firstName?: string, lastName?: string, email?: string, avatar?: string, avatarId?: string / number } | - |
|
|
163
|
-
| backgroundColor | Background color of the avatar | `auto` / `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | `auto` |
|
|
164
165
|
| badgeStatus | Badge status | `active` / `error` / `warning` | - |
|
|
165
166
|
| disabled | Determines if avatar is disabled | boolean | `false` |
|
|
166
167
|
| iconComponent | Replace default user icon | React.ReactNode | - |
|
|
@@ -187,9 +188,8 @@ import { ObjectAvatar } from '@synerise/ds-avatar';
|
|
|
187
188
|
| --------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------- |
|
|
188
189
|
| object | Object information | { name?: string, description?: string, status?: string, avatar?: string } | - |
|
|
189
190
|
| color | Color for the fallback icon | `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | `grey` |
|
|
190
|
-
| backgroundColor | Background color of the avatar | `auto` / `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | - |
|
|
191
191
|
| badgeStatus | Badge status | `active` / `error` / `warning` | - |
|
|
192
192
|
| disabled | Determines if avatar is disabled | boolean | - |
|
|
193
|
-
| iconComponent | Replace default
|
|
193
|
+
| iconComponent | Replace default Close2M icon (use an object icon) | React.ReactNode | - |
|
|
194
194
|
| size | Size of the avatar | `small` / `medium` / `large` / `extraLarge` | - |
|
|
195
195
|
| tooltip | Change default tooltip text displayed on hover | `TooltipObject` / `false` | - |
|
package/dist/Avatar.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare const ICON_SIZES: {
|
|
|
7
7
|
large: number;
|
|
8
8
|
extraLarge: number;
|
|
9
9
|
};
|
|
10
|
-
declare const Avatar: ({
|
|
10
|
+
declare const Avatar: ({ children, disabled, hasStatus, hasTile, iconComponent, iconScale, tooltip, size, src, ...restProps }: AvatarProps) => React.JSX.Element;
|
|
11
11
|
export default Avatar;
|
package/dist/Avatar.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { cloneElement } from "react";
|
|
3
3
|
import Tooltip from "@synerise/ds-tooltip";
|
|
4
4
|
import { StyledAvatar } from "./Avatar.styles.js";
|
|
5
|
-
import { isIconComponent, isSmallIconVariant, getTooltipProps } from "./utils.js";
|
|
5
|
+
import { isIconComponent, isSmallIconVariant, getTooltipProps, getTextBackground } from "./utils.js";
|
|
6
6
|
const DEFAULT_SIZE = "medium";
|
|
7
7
|
const ICON_SIZES = {
|
|
8
8
|
small: 16,
|
|
@@ -10,12 +10,21 @@ const ICON_SIZES = {
|
|
|
10
10
|
large: 30,
|
|
11
11
|
extraLarge: 42
|
|
12
12
|
};
|
|
13
|
+
const isText = (children) => typeof children === "string" && children.trim() !== "" || typeof children === "number";
|
|
14
|
+
const contentOf = (imageSrc, icon, children) => {
|
|
15
|
+
if (imageSrc) {
|
|
16
|
+
return "image";
|
|
17
|
+
}
|
|
18
|
+
if (icon) {
|
|
19
|
+
return "icon";
|
|
20
|
+
}
|
|
21
|
+
return isText(children) ? "text" : "custom";
|
|
22
|
+
};
|
|
13
23
|
const Avatar = ({
|
|
14
|
-
backgroundColor,
|
|
15
|
-
backgroundColorHue = "500",
|
|
16
24
|
children,
|
|
17
25
|
disabled = false,
|
|
18
26
|
hasStatus = false,
|
|
27
|
+
hasTile = false,
|
|
19
28
|
iconComponent,
|
|
20
29
|
iconScale = true,
|
|
21
30
|
tooltip = false,
|
|
@@ -23,6 +32,11 @@ const Avatar = ({
|
|
|
23
32
|
src,
|
|
24
33
|
...restProps
|
|
25
34
|
}) => {
|
|
35
|
+
const {
|
|
36
|
+
backgroundColor: _backgroundColor,
|
|
37
|
+
backgroundColorHue: _backgroundColorHue,
|
|
38
|
+
...domProps
|
|
39
|
+
} = restProps;
|
|
26
40
|
const sizes = {
|
|
27
41
|
...ICON_SIZES
|
|
28
42
|
};
|
|
@@ -36,12 +50,14 @@ const Avatar = ({
|
|
|
36
50
|
size: iconSize
|
|
37
51
|
});
|
|
38
52
|
}
|
|
53
|
+
const imageSrc = src !== "" ? src : void 0;
|
|
54
|
+
const content = contentOf(imageSrc, iconElement, children);
|
|
39
55
|
const {
|
|
40
56
|
type,
|
|
41
57
|
...tooltipProps
|
|
42
58
|
} = getTooltipProps(tooltip);
|
|
43
59
|
const hasTooltip = Object.keys(tooltipProps).length && !!Object.values(tooltipProps).reduce((prev, next) => next || prev);
|
|
44
|
-
return /* @__PURE__ */ jsx(Tooltip, { type, ...tooltipProps, children: /* @__PURE__ */ jsx(StyledAvatar, { className: "ds-avatar", hasStatus, hasTooltip: !!hasTooltip,
|
|
60
|
+
return /* @__PURE__ */ jsx(Tooltip, { type, ...tooltipProps, children: /* @__PURE__ */ jsx(StyledAvatar, { className: "ds-avatar", hasStatus, hasTooltip: !!hasTooltip, $content: content, $hasTile: hasTile, $textBackground: content === "text" ? getTextBackground(String(children)) : void 0, disabled, size, src: imageSrc, ...domProps, children: iconElement || children }) });
|
|
45
61
|
};
|
|
46
62
|
export {
|
|
47
63
|
DEFAULT_SIZE,
|
package/dist/Avatar.styles.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { AvatarContent } from './Avatar.types';
|
|
2
3
|
export declare const TooltipGroup: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
4
|
type ExtraAvatarProps = {
|
|
4
5
|
hasTooltip?: boolean;
|
|
5
|
-
$
|
|
6
|
+
$content?: AvatarContent;
|
|
7
|
+
/** Resolved background of a text avatar, derived from its first letter. */
|
|
8
|
+
$textBackground?: string;
|
|
9
|
+
/** Frames an image. An icon is always framed; text carries its own colour and ignores this. */
|
|
10
|
+
$hasTile?: boolean;
|
|
6
11
|
};
|
|
7
12
|
/**
|
|
8
13
|
* The text/icon container. Its size-dependent styling lives on the root via the
|
|
@@ -19,6 +24,7 @@ export declare const StyledAvatar: import('styled-components').StyledComponent<R
|
|
|
19
24
|
src?: string;
|
|
20
25
|
alt?: string;
|
|
21
26
|
hasStatus?: boolean;
|
|
27
|
+
hasTile?: boolean;
|
|
22
28
|
size?: import('./Avatar.types').Size;
|
|
23
29
|
iconComponent?: React.ReactNode;
|
|
24
30
|
iconScale?: boolean;
|
package/dist/Avatar.styles.js
CHANGED
|
@@ -2,25 +2,20 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import styled, { css } from "styled-components";
|
|
4
4
|
import { macro } from "@synerise/ds-typography";
|
|
5
|
-
import { resolveCustomColor } from "@synerise/ds-utils";
|
|
6
5
|
const TooltipGroup = /* @__PURE__ */ styled.div.withConfig({
|
|
7
6
|
displayName: "Avatarstyles__TooltipGroup",
|
|
8
7
|
componentId: "sc-xcn5o4-0"
|
|
9
8
|
})(["margin:13px 8px;font-size:11px;line-height:1.45;text-align:center;p{margin:0;font-weight:normal;&:first-child{font-weight:500;}}"]);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if ($
|
|
17
|
-
return css(["background:var(--ds-
|
|
9
|
+
const tileFrame = /* @__PURE__ */ css(["border:1px solid var(--ds-color-border-base-strong);box-shadow:var(--ds-shadows-shadow-1);"]);
|
|
10
|
+
const applyContentBackground = ({
|
|
11
|
+
$content,
|
|
12
|
+
$textBackground,
|
|
13
|
+
$hasTile
|
|
14
|
+
}) => {
|
|
15
|
+
if ($content === "icon") {
|
|
16
|
+
return css(["background:var(--ds-color-background-base-default);", ";"], tileFrame);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
defaultShade: backgroundColorHue || "400",
|
|
21
|
-
passthroughResolved: true
|
|
22
|
-
}) : "transparent";
|
|
23
|
-
return css(["background:", ";"], bg);
|
|
18
|
+
return css(["background:", ";", ";"], $content === "text" && $textBackground || "transparent", $hasTile && $content === "image" && tileFrame);
|
|
24
19
|
};
|
|
25
20
|
const applyDisabledStyles = (props) => props.disabled && css(["opacity:var(--ds-avatar-disabled-opacity);pointer-events:none;"]);
|
|
26
21
|
const BADGE_POSITION = {
|
|
@@ -63,8 +58,6 @@ const AvatarImg = /* @__PURE__ */ styled.img.withConfig({
|
|
|
63
58
|
})(["display:block;width:100%;height:100%;object-fit:cover;"]);
|
|
64
59
|
const AvatarBase = forwardRef(({
|
|
65
60
|
// DS-only / styling props — consumed here so they do not leak to the DOM
|
|
66
|
-
backgroundColor,
|
|
67
|
-
backgroundColorHue,
|
|
68
61
|
hasStatus,
|
|
69
62
|
hasTooltip,
|
|
70
63
|
disabled,
|
|
@@ -83,7 +76,7 @@ const AvatarBase = forwardRef(({
|
|
|
83
76
|
const StyledAvatar = /* @__PURE__ */ styled(AvatarBase).withConfig({
|
|
84
77
|
displayName: "Avatarstyles__StyledAvatar",
|
|
85
78
|
componentId: "sc-xcn5o4-3"
|
|
86
|
-
})(["&&{position:relative;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;overflow:hidden;width:24px;height:24px;min-width:24px;vertical-align:middle;border-radius:50%;", " user-select:none;transition:background 0.3s ease;", ";", ";", ";", "{position:relative;left:0;width:100%;height:100%;font-size:11px;", " user-select:none;pointer-events:none;", ";", ";& > div{max-width:100%;max-height:100%;svg{width:100%;height:100%;}}}&::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--ds-color-background-overlay-solid);opacity:0;border-radius:inherit;}", ";", ";& ~ .ds-badge-dot{display:none;}", ";", ";", ";", ";}"], (props) => props.$
|
|
79
|
+
})(["&&{position:relative;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;overflow:hidden;width:24px;height:24px;min-width:24px;vertical-align:middle;border-radius:50%;", " user-select:none;transition:background 0.3s ease;", ";", ";", ";", "{position:relative;left:0;width:100%;height:100%;font-size:11px;", " user-select:none;pointer-events:none;", ";", ";& > div{max-width:100%;max-height:100%;svg{width:100%;height:100%;}}}&::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--ds-color-background-overlay-solid);opacity:0;border-radius:inherit;}", ";", ";& ~ .ds-badge-dot{display:none;}", ";", ";", ";", ";}"], (props) => props.$content === "icon" ? "color: var(--ds-avatar-icon-icon);" : "color: var(--ds-avatar-text-text) !important;", (props) => applyContentBackground(props), (props) => applyDisabledStyles(props), (props) => props.shape === "square" && css(["border-radius:8px;"]), AvatarString, (props) => props.$content === "icon" ? "color: inherit;" : "color: var(--ds-avatar-text-text) !important;", (props) => applyFontSize(props), macro.flexCentered, (props) => (props.onClick || props.hasTooltip) && css(["&:hover::before{opacity:var(--ds-avatar-overlay-opacity-hover);}"]), (props) => props.onClick && css(["cursor:pointer;&:active::before{opacity:var(--ds-avatar-overlay-opacity-pressed);}"]), (props) => props.hasStatus && css(["& ~ .ds-badge-dot{display:flex;box-sizing:border-box;width:10px;height:10px;box-shadow:none;", ";}"], applyBadgePosition(props)), (props) => props.size === "medium" && css(["width:40px;min-width:40px;height:40px;", "{line-height:40px;}"], AvatarString), (props) => props.size === "large" && css(["width:84px;min-width:84px;height:84px;", "{line-height:84px;font-size:18px;}"], AvatarString), (props) => props.size === "extraLarge" && css(["width:120px;min-width:120px;height:120px;font-size:22px;", "{line-height:120px;", ";}"], AvatarString, macro.xlAvatar));
|
|
87
80
|
export {
|
|
88
81
|
AvatarImg,
|
|
89
82
|
AvatarString,
|
package/dist/Avatar.types.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import { BadgeStatus } from '@synerise/ds-badge';
|
|
|
3
3
|
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
4
4
|
import { DataAttributes } from '@synerise/ds-utils';
|
|
5
5
|
export type Color = 'red' | 'green' | 'grey' | 'yellow' | 'blue' | 'pink' | 'mars' | 'orange' | 'fern' | 'cyan' | 'purple' | 'violet';
|
|
6
|
-
export type ColorHue = '900' | '800' | '700' | '600' | '500' | '400' | '300' | '200' | '100' | '050';
|
|
7
6
|
export type Size = 'small' | 'medium' | 'large' | 'extraLarge' | undefined;
|
|
7
|
+
export type ColorHue = '900' | '800' | '700' | '600' | '500' | '400' | '300' | '200' | '100' | '050';
|
|
8
8
|
export type Shape = 'circle' | 'square';
|
|
9
|
+
/** What an avatar shows, which decides its background: an image, the icon tile, a text colour or none. */
|
|
10
|
+
export type AvatarContent = 'image' | 'icon' | 'text' | 'custom';
|
|
9
11
|
export type TooltipObject = Omit<TooltipProps, 'children'> & {
|
|
10
12
|
name?: ReactNode;
|
|
11
13
|
email?: ReactNode;
|
|
@@ -28,6 +30,12 @@ export type AvatarProps = {
|
|
|
28
30
|
* Aligns a badge with the avatar
|
|
29
31
|
*/
|
|
30
32
|
hasStatus?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Draws the tile border and shadow around an image. An icon always has them, and a text avatar
|
|
35
|
+
* ignores this because it already has a colour of its own.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
hasTile?: boolean;
|
|
31
39
|
/**
|
|
32
40
|
* The size of the avatar
|
|
33
41
|
*/
|
|
@@ -42,11 +50,12 @@ export type AvatarProps = {
|
|
|
42
50
|
*/
|
|
43
51
|
iconScale?: boolean;
|
|
44
52
|
/**
|
|
45
|
-
*
|
|
53
|
+
* @deprecated Has no effect: the content decides the background (image, icon tile, or a colour
|
|
54
|
+
* from the text's first letter). Will be removed once consumers stop passing it.
|
|
46
55
|
*/
|
|
47
56
|
backgroundColor?: Color | string;
|
|
48
57
|
/**
|
|
49
|
-
*
|
|
58
|
+
* @deprecated Has no effect; see `backgroundColor`.
|
|
50
59
|
*/
|
|
51
60
|
backgroundColorHue?: ColorHue;
|
|
52
61
|
/**
|
|
@@ -63,7 +72,11 @@ export type AvatarProps = {
|
|
|
63
72
|
id?: string;
|
|
64
73
|
onClick?: MouseEventHandler<HTMLElement>;
|
|
65
74
|
} & DataAttributes;
|
|
66
|
-
type DefinedAvatarProps = Pick<AvatarProps, 'style' | 'disabled' | 'iconComponent' | 'size' | 'src'> & {
|
|
75
|
+
type DefinedAvatarProps = Pick<AvatarProps, 'style' | 'disabled' | 'hasTile' | 'iconComponent' | 'size' | 'src'> & {
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Has no effect: the content decides the background. Will be removed once consumers
|
|
78
|
+
* stop passing it.
|
|
79
|
+
*/
|
|
67
80
|
backgroundColor?: 'auto' | Color | string;
|
|
68
81
|
badgeStatus?: BadgeStatus;
|
|
69
82
|
text?: string;
|
|
@@ -4,5 +4,5 @@ export { TOTAL_DEFAULT_AVATARS };
|
|
|
4
4
|
type DefaultAvatarIconProps = {
|
|
5
5
|
index: number;
|
|
6
6
|
};
|
|
7
|
-
declare const DefaultAvatarIcon: React.
|
|
7
|
+
declare const DefaultAvatarIcon: ({ index }: DefaultAvatarIconProps) => React.JSX.Element | null;
|
|
8
8
|
export default DefaultAvatarIcon;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ObjectAvatarProps } from '../Avatar.types';
|
|
3
3
|
export declare const DEFAULT_COLOR_HUE = "600";
|
|
4
|
-
declare const ObjectAvatar: ({
|
|
4
|
+
declare const ObjectAvatar: ({ badgeStatus, iconComponent, color, object, size, src, tooltip, text, children, disabled, style, ...restProps }: ObjectAvatarProps) => React.JSX.Element;
|
|
5
5
|
export default ObjectAvatar;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import Badge from "@synerise/ds-badge";
|
|
3
|
-
import Icon, {
|
|
3
|
+
import Icon, { Close2M } from "@synerise/ds-icon";
|
|
4
4
|
import Status from "@synerise/ds-status";
|
|
5
5
|
import { customColors } from "@synerise/ds-tokens/names";
|
|
6
6
|
import Avatar from "../Avatar.js";
|
|
7
|
-
import { getObjectName,
|
|
7
|
+
import { getObjectName, addIconColor } from "../utils.js";
|
|
8
8
|
const DEFAULT_COLOR_HUE = "600";
|
|
9
9
|
const ObjectAvatar = ({
|
|
10
|
-
backgroundColor,
|
|
11
10
|
badgeStatus,
|
|
12
11
|
iconComponent,
|
|
13
12
|
color,
|
|
@@ -33,18 +32,11 @@ const ObjectAvatar = ({
|
|
|
33
32
|
status: objectStatus ? /* @__PURE__ */ jsx(Status, { label: objectStatus, type: "disabled" }) : ""
|
|
34
33
|
};
|
|
35
34
|
const avatarText = getObjectName(objectName, text);
|
|
36
|
-
const
|
|
37
|
-
const [avatarBackgroundColor, avatarBackgroundHue] = getColorByText(avatarText, backgroundColor);
|
|
38
|
-
let iconColor;
|
|
39
|
-
if (color) {
|
|
40
|
-
iconColor = customColors[color]?.[DEFAULT_COLOR_HUE];
|
|
41
|
-
} else if (hasBackgroundColor) {
|
|
42
|
-
iconColor = "var(--ds-avatar-icon-icon)";
|
|
43
|
-
}
|
|
35
|
+
const iconColor = color ? customColors[color]?.[DEFAULT_COLOR_HUE] : void 0;
|
|
44
36
|
const avatarTooltip = tooltip === void 0 && (defaultTooltip.title || defaultTooltip.description) ? defaultTooltip : tooltip;
|
|
45
37
|
const iconElement = addIconColor(iconComponent, iconColor);
|
|
46
|
-
const icon = !avatarText ? iconElement || /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(
|
|
47
|
-
const avatarRender = /* @__PURE__ */ jsx(Avatar, { iconComponent: icon, shape: "square",
|
|
38
|
+
const icon = !avatarText ? iconElement || /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(Close2M, {}), color: iconColor }) : null;
|
|
39
|
+
const avatarRender = /* @__PURE__ */ jsx(Avatar, { iconComponent: icon, shape: "square", size, hasStatus: disabled === true ? false : !!badgeStatus, src: avatar || src, tooltip: avatarTooltip, disabled, style: badgeStatus ? {} : style, ...restProps, children: children || avatarText });
|
|
48
40
|
return badgeStatus ? /* @__PURE__ */ jsx("span", { style, children: /* @__PURE__ */ jsx(Badge, { status: badgeStatus, children: avatarRender }) }) : avatarRender;
|
|
49
41
|
};
|
|
50
42
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { UserAvatarProps } from '../Avatar.types';
|
|
3
|
-
declare const UserAvatar: React.
|
|
3
|
+
declare const UserAvatar: ({ size, text, tooltip, badgeStatus, user, src, iconComponent, children, disabled, style, ...restProps }: UserAvatarProps) => React.JSX.Element;
|
|
4
4
|
export default UserAvatar;
|
|
@@ -3,10 +3,9 @@ import Badge from "@synerise/ds-badge";
|
|
|
3
3
|
import Icon, { UserS, UserM } from "@synerise/ds-icon";
|
|
4
4
|
import Avatar from "../Avatar.js";
|
|
5
5
|
import DefaultAvatarIcon from "../DefaultAvatarIcon.js";
|
|
6
|
-
import { getUserText,
|
|
6
|
+
import { getUserText, getDefaultAvatarIndex } from "../utils.js";
|
|
7
7
|
import { TOTAL_DEFAULT_AVATARS } from "../defaultAvatars/index.js";
|
|
8
8
|
const UserAvatar = ({
|
|
9
|
-
backgroundColor,
|
|
10
9
|
size,
|
|
11
10
|
text,
|
|
12
11
|
tooltip,
|
|
@@ -35,23 +34,13 @@ const UserAvatar = ({
|
|
|
35
34
|
description: email || ""
|
|
36
35
|
};
|
|
37
36
|
const avatarTooltip = (tooltip === void 0 || tooltip === true) && (defaultTooltip.title || defaultTooltip.description) ? defaultTooltip : tooltip;
|
|
38
|
-
const
|
|
39
|
-
const
|
|
37
|
+
const iconElement = iconComponent;
|
|
38
|
+
const illustration = useDefaultSvg ? /* @__PURE__ */ jsx(DefaultAvatarIcon, { index: getDefaultAvatarIndex(avatarId, TOTAL_DEFAULT_AVATARS) }) : null;
|
|
40
39
|
let icon = null;
|
|
41
|
-
if (useDefaultSvg) {
|
|
42
|
-
|
|
43
|
-
icon = /* @__PURE__ */ jsx(DefaultAvatarIcon, { index: avatarIndex });
|
|
44
|
-
} else if (!avatarText) {
|
|
45
|
-
icon = iconElement || /* @__PURE__ */ jsx(Icon, { component: size === "small" ? /* @__PURE__ */ jsx(UserS, {}) : /* @__PURE__ */ jsx(UserM, {}), color: "var(--ds-color-icon-base-subtle)" });
|
|
40
|
+
if (!useDefaultSvg && !avatarText) {
|
|
41
|
+
icon = iconElement || /* @__PURE__ */ jsx(Icon, { component: size === "small" ? /* @__PURE__ */ jsx(UserS, {}) : /* @__PURE__ */ jsx(UserM, {}) });
|
|
46
42
|
}
|
|
47
|
-
const
|
|
48
|
-
const avatarRender = /* @__PURE__ */ jsx(Avatar, { iconComponent: icon, iconScale: !useDefaultSvg, shape: "circle", hasStatus: disabled === true ? false : !!badgeStatus, backgroundColor: useDefaultSvg ? void 0 : avatarBackgroundColor, backgroundColorHue: useDefaultSvg ? void 0 : avatarBackgroundHue, size, src: avatar || src, tooltip: avatarTooltip, disabled, style: {
|
|
49
|
-
...badgeStatus ? {} : style,
|
|
50
|
-
...useDefaultSvg ? {
|
|
51
|
-
background: "transparent",
|
|
52
|
-
overflow: "hidden"
|
|
53
|
-
} : {}
|
|
54
|
-
}, ...restProps, children: children || avatarText });
|
|
43
|
+
const avatarRender = /* @__PURE__ */ jsx(Avatar, { iconComponent: icon, shape: "circle", hasStatus: disabled === true ? false : !!badgeStatus, size, src: avatar || src, tooltip: avatarTooltip, disabled, style: badgeStatus ? {} : style, ...restProps, children: children || illustration || avatarText });
|
|
55
44
|
return badgeStatus ? /* @__PURE__ */ jsx("span", { style, children: /* @__PURE__ */ jsx(Badge, { status: badgeStatus, children: avatarRender }) }) : avatarRender;
|
|
56
45
|
};
|
|
57
46
|
export {
|
|
@@ -1,103 +1,103 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
|
-
export { default as Icon0001 } from './Icon0001';
|
|
3
2
|
export { default as Icon0003 } from './Icon0003';
|
|
4
|
-
export { default as
|
|
3
|
+
export { default as Icon0001 } from './Icon0001';
|
|
5
4
|
export { default as Icon0007 } from './Icon0007';
|
|
6
|
-
export { default as
|
|
5
|
+
export { default as Icon0004 } from './Icon0004';
|
|
7
6
|
export { default as Icon0012 } from './Icon0012';
|
|
7
|
+
export { default as Icon0011 } from './Icon0011';
|
|
8
8
|
export { default as Icon0014 } from './Icon0014';
|
|
9
9
|
export { default as Icon0015 } from './Icon0015';
|
|
10
|
+
export { default as Icon0024 } from './Icon0024';
|
|
11
|
+
export { default as Icon0025 } from './Icon0025';
|
|
10
12
|
export { default as Icon0022 } from './Icon0022';
|
|
11
|
-
export { default as Icon0027 } from './Icon0027';
|
|
12
|
-
export { default as Icon0029 } from './Icon0029';
|
|
13
|
-
export { default as Icon0030 } from './Icon0030';
|
|
14
13
|
export { default as Icon0031 } from './Icon0031';
|
|
14
|
+
export { default as Icon0029 } from './Icon0029';
|
|
15
15
|
export { default as Icon0032 } from './Icon0032';
|
|
16
|
-
export { default as Icon0033 } from './Icon0033';
|
|
17
16
|
export { default as Icon0038 } from './Icon0038';
|
|
17
|
+
export { default as Icon0033 } from './Icon0033';
|
|
18
18
|
export { default as Icon0039 } from './Icon0039';
|
|
19
19
|
export { default as Icon0040 } from './Icon0040';
|
|
20
20
|
export { default as Icon0041 } from './Icon0041';
|
|
21
|
+
export { default as Icon0027 } from './Icon0027';
|
|
21
22
|
export { default as Icon0042 } from './Icon0042';
|
|
22
|
-
export { default as Icon0043 } from './Icon0043';
|
|
23
|
-
export { default as Icon0049 } from './Icon0049';
|
|
24
23
|
export { default as Icon0044 } from './Icon0044';
|
|
24
|
+
export { default as Icon0043 } from './Icon0043';
|
|
25
25
|
export { default as Icon0048 } from './Icon0048';
|
|
26
|
-
export { default as
|
|
26
|
+
export { default as Icon0030 } from './Icon0030';
|
|
27
|
+
export { default as Icon0049 } from './Icon0049';
|
|
27
28
|
export { default as Icon0051 } from './Icon0051';
|
|
29
|
+
export { default as Icon0050 } from './Icon0050';
|
|
28
30
|
export { default as Icon0053 } from './Icon0053';
|
|
29
31
|
export { default as Icon0054 } from './Icon0054';
|
|
30
|
-
export { default as
|
|
32
|
+
export { default as Icon0056 } from './Icon0056';
|
|
31
33
|
export { default as Icon0058 } from './Icon0058';
|
|
32
|
-
export { default as Icon0061 } from './Icon0061';
|
|
33
|
-
export { default as Icon0066 } from './Icon0066';
|
|
34
34
|
export { default as Icon0060 } from './Icon0060';
|
|
35
|
+
export { default as Icon0061 } from './Icon0061';
|
|
36
|
+
export { default as Icon0055 } from './Icon0055';
|
|
35
37
|
export { default as Icon0067 } from './Icon0067';
|
|
36
|
-
export { default as
|
|
38
|
+
export { default as Icon0066 } from './Icon0066';
|
|
37
39
|
export { default as Icon0071 } from './Icon0071';
|
|
40
|
+
export { default as Icon0070 } from './Icon0070';
|
|
38
41
|
export { default as Icon0073 } from './Icon0073';
|
|
39
|
-
export { default as Icon0074 } from './Icon0074';
|
|
40
42
|
export { default as Icon0075 } from './Icon0075';
|
|
41
43
|
export { default as Icon0076 } from './Icon0076';
|
|
42
|
-
export { default as
|
|
44
|
+
export { default as Icon0074 } from './Icon0074';
|
|
43
45
|
export { default as Icon0082 } from './Icon0082';
|
|
44
|
-
export { default as
|
|
46
|
+
export { default as Icon0078 } from './Icon0078';
|
|
45
47
|
export { default as Icon0084 } from './Icon0084';
|
|
48
|
+
export { default as Icon0083 } from './Icon0083';
|
|
46
49
|
export { default as Icon0088 } from './Icon0088';
|
|
50
|
+
export { default as Icon0079 } from './Icon0079';
|
|
47
51
|
export { default as Icon0089 } from './Icon0089';
|
|
48
52
|
export { default as Icon0090 } from './Icon0090';
|
|
53
|
+
export { default as Icon0077 } from './Icon0077';
|
|
49
54
|
export { default as Icon0091 } from './Icon0091';
|
|
50
55
|
export { default as Icon0092 } from './Icon0092';
|
|
51
|
-
export { default as Icon0095 } from './Icon0095';
|
|
52
56
|
export { default as Icon0098 } from './Icon0098';
|
|
53
|
-
export { default as
|
|
57
|
+
export { default as Icon0095 } from './Icon0095';
|
|
54
58
|
export { default as Icon0101 } from './Icon0101';
|
|
55
59
|
export { default as Icon0102 } from './Icon0102';
|
|
60
|
+
export { default as Icon0100 } from './Icon0100';
|
|
56
61
|
export { default as Icon0103 } from './Icon0103';
|
|
57
62
|
export { default as Icon0105 } from './Icon0105';
|
|
58
63
|
export { default as Icon0106 } from './Icon0106';
|
|
59
|
-
export { default as Icon0107 } from './Icon0107';
|
|
60
64
|
export { default as Icon0108 } from './Icon0108';
|
|
61
65
|
export { default as Icon0109 } from './Icon0109';
|
|
62
|
-
export { default as Icon0110 } from './Icon0110';
|
|
63
66
|
export { default as Icon0111 } from './Icon0111';
|
|
67
|
+
export { default as Icon0107 } from './Icon0107';
|
|
64
68
|
export { default as Icon0112 } from './Icon0112';
|
|
69
|
+
export { default as Icon0110 } from './Icon0110';
|
|
65
70
|
export { default as Icon0114 } from './Icon0114';
|
|
66
71
|
export { default as Icon0115 } from './Icon0115';
|
|
67
72
|
export { default as Icon0116 } from './Icon0116';
|
|
68
|
-
export { default as Icon0118 } from './Icon0118';
|
|
69
73
|
export { default as Icon0119 } from './Icon0119';
|
|
74
|
+
export { default as Icon0118 } from './Icon0118';
|
|
70
75
|
export { default as Icon0120 } from './Icon0120';
|
|
71
|
-
export { default as Icon0122 } from './Icon0122';
|
|
72
76
|
export { default as Icon0123 } from './Icon0123';
|
|
73
|
-
export { default as
|
|
77
|
+
export { default as Icon0122 } from './Icon0122';
|
|
74
78
|
export { default as Icon0125 } from './Icon0125';
|
|
79
|
+
export { default as Icon0124 } from './Icon0124';
|
|
75
80
|
export { default as Icon0126 } from './Icon0126';
|
|
76
|
-
export { default as Icon0127 } from './Icon0127';
|
|
77
81
|
export { default as Icon0128 } from './Icon0128';
|
|
82
|
+
export { default as Icon0132 } from './Icon0132';
|
|
78
83
|
export { default as Icon0129 } from './Icon0129';
|
|
79
84
|
export { default as Icon0130 } from './Icon0130';
|
|
80
|
-
export { default as Icon0132 } from './Icon0132';
|
|
81
85
|
export { default as Icon0133 } from './Icon0133';
|
|
82
|
-
export { default as Icon0134 } from './Icon0134';
|
|
83
86
|
export { default as Icon0137 } from './Icon0137';
|
|
87
|
+
export { default as Icon0134 } from './Icon0134';
|
|
84
88
|
export { default as Icon0138 } from './Icon0138';
|
|
85
|
-
export { default as Icon0139 } from './Icon0139';
|
|
86
|
-
export { default as Icon0140 } from './Icon0140';
|
|
87
89
|
export { default as Icon0141 } from './Icon0141';
|
|
88
|
-
export { default as
|
|
90
|
+
export { default as Icon0139 } from './Icon0139';
|
|
89
91
|
export { default as Icon0143 } from './Icon0143';
|
|
90
|
-
export { default as
|
|
92
|
+
export { default as Icon0142 } from './Icon0142';
|
|
91
93
|
export { default as Icon0145 } from './Icon0145';
|
|
94
|
+
export { default as Icon0127 } from './Icon0127';
|
|
95
|
+
export { default as Icon0144 } from './Icon0144';
|
|
96
|
+
export { default as Icon0140 } from './Icon0140';
|
|
92
97
|
export { default as Icon0147 } from './Icon0147';
|
|
93
98
|
export { default as Icon0146 } from './Icon0146';
|
|
94
99
|
export { default as Icon0148 } from './Icon0148';
|
|
95
|
-
export { default as Icon0149 } from './Icon0149';
|
|
96
100
|
export { default as Icon015 } from './Icon015';
|
|
97
|
-
export { default as
|
|
98
|
-
export { default as Icon0024 } from './Icon0024';
|
|
99
|
-
export { default as Icon0056 } from './Icon0056';
|
|
100
|
-
export { default as Icon0079 } from './Icon0079';
|
|
101
|
-
export { default as Icon0078 } from './Icon0078';
|
|
101
|
+
export { default as Icon0149 } from './Icon0149';
|
|
102
102
|
export declare const DEFAULT_AVATARS: ComponentType<React.SVGProps<SVGSVGElement>>[];
|
|
103
103
|
export declare const TOTAL_DEFAULT_AVATARS = 100;
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import Icon0004 from "./Icon0004.js";
|
|
2
1
|
import Icon0003 from "./Icon0003.js";
|
|
3
2
|
import Icon0001 from "./Icon0001.js";
|
|
4
|
-
import
|
|
3
|
+
import Icon0012 from "./Icon0012.js";
|
|
4
|
+
import Icon0004 from "./Icon0004.js";
|
|
5
5
|
import Icon0011 from "./Icon0011.js";
|
|
6
|
+
import Icon0007 from "./Icon0007.js";
|
|
6
7
|
import Icon0015 from "./Icon0015.js";
|
|
7
|
-
import Icon0012 from "./Icon0012.js";
|
|
8
|
-
import Icon0014 from "./Icon0014.js";
|
|
9
8
|
import Icon0022 from "./Icon0022.js";
|
|
10
|
-
import Icon0024 from "./Icon0024.js";
|
|
11
9
|
import Icon0025 from "./Icon0025.js";
|
|
10
|
+
import Icon0014 from "./Icon0014.js";
|
|
11
|
+
import Icon0024 from "./Icon0024.js";
|
|
12
12
|
import Icon0027 from "./Icon0027.js";
|
|
13
13
|
import Icon0029 from "./Icon0029.js";
|
|
14
|
-
import Icon0030 from "./Icon0030.js";
|
|
15
14
|
import Icon0031 from "./Icon0031.js";
|
|
16
15
|
import Icon0032 from "./Icon0032.js";
|
|
16
|
+
import Icon0030 from "./Icon0030.js";
|
|
17
17
|
import Icon0033 from "./Icon0033.js";
|
|
18
|
-
import Icon0038 from "./Icon0038.js";
|
|
19
18
|
import Icon0039 from "./Icon0039.js";
|
|
20
19
|
import Icon0041 from "./Icon0041.js";
|
|
21
|
-
import
|
|
20
|
+
import Icon0038 from "./Icon0038.js";
|
|
22
21
|
import Icon0042 from "./Icon0042.js";
|
|
22
|
+
import Icon0048 from "./Icon0048.js";
|
|
23
|
+
import Icon0040 from "./Icon0040.js";
|
|
23
24
|
import Icon0043 from "./Icon0043.js";
|
|
24
25
|
import Icon0044 from "./Icon0044.js";
|
|
25
|
-
import Icon0048 from "./Icon0048.js";
|
|
26
|
-
import Icon0050 from "./Icon0050.js";
|
|
27
26
|
import Icon0049 from "./Icon0049.js";
|
|
28
|
-
import Icon0051 from "./Icon0051.js";
|
|
29
27
|
import Icon0053 from "./Icon0053.js";
|
|
28
|
+
import Icon0050 from "./Icon0050.js";
|
|
29
|
+
import Icon0051 from "./Icon0051.js";
|
|
30
30
|
import Icon0054 from "./Icon0054.js";
|
|
31
31
|
import Icon0055 from "./Icon0055.js";
|
|
32
32
|
import Icon0056 from "./Icon0056.js";
|
|
33
33
|
import Icon0060 from "./Icon0060.js";
|
|
34
|
-
import Icon0058 from "./Icon0058.js";
|
|
35
34
|
import Icon0061 from "./Icon0061.js";
|
|
36
35
|
import Icon0067 from "./Icon0067.js";
|
|
36
|
+
import Icon0058 from "./Icon0058.js";
|
|
37
37
|
import Icon0066 from "./Icon0066.js";
|
|
38
38
|
import Icon0070 from "./Icon0070.js";
|
|
39
39
|
import Icon0071 from "./Icon0071.js";
|
|
40
|
-
import Icon0073 from "./Icon0073.js";
|
|
41
|
-
import Icon0074 from "./Icon0074.js";
|
|
42
40
|
import Icon0075 from "./Icon0075.js";
|
|
43
41
|
import Icon0076 from "./Icon0076.js";
|
|
44
|
-
import
|
|
42
|
+
import Icon0073 from "./Icon0073.js";
|
|
43
|
+
import Icon0077 from "./Icon0077.js";
|
|
44
|
+
import Icon0082 from "./Icon0082.js";
|
|
45
|
+
import Icon0083 from "./Icon0083.js";
|
|
45
46
|
import Icon0084 from "./Icon0084.js";
|
|
47
|
+
import Icon0078 from "./Icon0078.js";
|
|
46
48
|
import Icon0088 from "./Icon0088.js";
|
|
47
49
|
import Icon0089 from "./Icon0089.js";
|
|
50
|
+
import Icon0079 from "./Icon0079.js";
|
|
48
51
|
import Icon0090 from "./Icon0090.js";
|
|
49
|
-
import Icon0082 from "./Icon0082.js";
|
|
50
|
-
import Icon0091 from "./Icon0091.js";
|
|
51
52
|
import Icon0092 from "./Icon0092.js";
|
|
52
53
|
import Icon0098 from "./Icon0098.js";
|
|
53
54
|
import Icon0095 from "./Icon0095.js";
|
|
54
|
-
import Icon0101 from "./Icon0101.js";
|
|
55
55
|
import Icon0100 from "./Icon0100.js";
|
|
56
|
+
import Icon0091 from "./Icon0091.js";
|
|
57
|
+
import Icon0101 from "./Icon0101.js";
|
|
56
58
|
import Icon0102 from "./Icon0102.js";
|
|
57
59
|
import Icon0103 from "./Icon0103.js";
|
|
58
60
|
import Icon0105 from "./Icon0105.js";
|
|
59
|
-
import Icon0106 from "./Icon0106.js";
|
|
60
|
-
import Icon0108 from "./Icon0108.js";
|
|
61
61
|
import Icon0107 from "./Icon0107.js";
|
|
62
|
+
import Icon0106 from "./Icon0106.js";
|
|
62
63
|
import Icon0109 from "./Icon0109.js";
|
|
63
|
-
import
|
|
64
|
+
import Icon0108 from "./Icon0108.js";
|
|
65
|
+
import Icon0074 from "./Icon0074.js";
|
|
64
66
|
import Icon0111 from "./Icon0111.js";
|
|
65
|
-
import
|
|
66
|
-
import Icon0114 from "./Icon0114.js";
|
|
67
|
+
import Icon0110 from "./Icon0110.js";
|
|
67
68
|
import Icon0115 from "./Icon0115.js";
|
|
69
|
+
import Icon0114 from "./Icon0114.js";
|
|
70
|
+
import Icon0112 from "./Icon0112.js";
|
|
68
71
|
import Icon0116 from "./Icon0116.js";
|
|
69
|
-
import Icon0118 from "./Icon0118.js";
|
|
70
|
-
import Icon0119 from "./Icon0119.js";
|
|
71
|
-
import Icon0120 from "./Icon0120.js";
|
|
72
72
|
import Icon0122 from "./Icon0122.js";
|
|
73
73
|
import Icon0123 from "./Icon0123.js";
|
|
74
|
+
import Icon0119 from "./Icon0119.js";
|
|
75
|
+
import Icon0118 from "./Icon0118.js";
|
|
76
|
+
import Icon0125 from "./Icon0125.js";
|
|
74
77
|
import Icon0124 from "./Icon0124.js";
|
|
78
|
+
import Icon0120 from "./Icon0120.js";
|
|
75
79
|
import Icon0126 from "./Icon0126.js";
|
|
76
80
|
import Icon0127 from "./Icon0127.js";
|
|
77
|
-
import Icon0125 from "./Icon0125.js";
|
|
78
81
|
import Icon0128 from "./Icon0128.js";
|
|
82
|
+
import Icon0133 from "./Icon0133.js";
|
|
79
83
|
import Icon0129 from "./Icon0129.js";
|
|
80
84
|
import Icon0130 from "./Icon0130.js";
|
|
81
|
-
import Icon0133 from "./Icon0133.js";
|
|
82
|
-
import Icon0132 from "./Icon0132.js";
|
|
83
85
|
import Icon0134 from "./Icon0134.js";
|
|
84
|
-
import
|
|
86
|
+
import Icon0132 from "./Icon0132.js";
|
|
85
87
|
import Icon0139 from "./Icon0139.js";
|
|
86
88
|
import Icon0137 from "./Icon0137.js";
|
|
87
89
|
import Icon0140 from "./Icon0140.js";
|
|
88
|
-
import Icon0141 from "./Icon0141.js";
|
|
89
|
-
import Icon0143 from "./Icon0143.js";
|
|
90
90
|
import Icon0142 from "./Icon0142.js";
|
|
91
|
+
import Icon0141 from "./Icon0141.js";
|
|
91
92
|
import Icon0144 from "./Icon0144.js";
|
|
92
|
-
import
|
|
93
|
+
import Icon0138 from "./Icon0138.js";
|
|
94
|
+
import Icon0143 from "./Icon0143.js";
|
|
93
95
|
import Icon0145 from "./Icon0145.js";
|
|
94
96
|
import Icon0146 from "./Icon0146.js";
|
|
97
|
+
import Icon0147 from "./Icon0147.js";
|
|
95
98
|
import Icon0149 from "./Icon0149.js";
|
|
96
99
|
import Icon0148 from "./Icon0148.js";
|
|
97
100
|
import Icon015 from "./Icon015.js";
|
|
98
|
-
import Icon0077 from "./Icon0077.js";
|
|
99
|
-
import Icon0079 from "./Icon0079.js";
|
|
100
|
-
import Icon0083 from "./Icon0083.js";
|
|
101
101
|
const DEFAULT_AVATARS = [Icon0001, Icon0003, Icon0004, Icon0007, Icon0011, Icon0012, Icon0014, Icon0015, Icon0022, Icon0024, Icon0025, Icon0027, Icon0029, Icon0030, Icon0031, Icon0032, Icon0033, Icon0038, Icon0039, Icon0040, Icon0041, Icon0042, Icon0043, Icon0044, Icon0048, Icon0049, Icon0050, Icon0051, Icon0053, Icon0054, Icon0055, Icon0056, Icon0058, Icon0060, Icon0061, Icon0066, Icon0067, Icon0070, Icon0071, Icon0073, Icon0074, Icon0075, Icon0076, Icon0077, Icon0078, Icon0079, Icon0082, Icon0083, Icon0084, Icon0088, Icon0089, Icon0090, Icon0091, Icon0092, Icon0095, Icon0098, Icon0100, Icon0101, Icon0102, Icon0103, Icon0105, Icon0106, Icon0107, Icon0108, Icon0109, Icon0110, Icon0111, Icon0112, Icon0114, Icon0115, Icon0116, Icon0118, Icon0119, Icon0120, Icon0122, Icon0123, Icon0124, Icon0125, Icon0126, Icon0127, Icon0128, Icon0129, Icon0130, Icon0132, Icon0133, Icon0134, Icon0137, Icon0138, Icon0139, Icon0140, Icon0141, Icon0142, Icon0143, Icon0144, Icon0145, Icon0146, Icon0147, Icon0148, Icon0149, Icon015];
|
|
102
102
|
const TOTAL_DEFAULT_AVATARS = 100;
|
|
103
103
|
export {
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { AvatarProps,
|
|
2
|
+
import { AvatarProps, TooltipObject, UserAvatar } from './Avatar.types';
|
|
3
3
|
export declare function getUserText(user: UserAvatar, src?: string | null, text?: string | null): string | null;
|
|
4
4
|
export declare function isIconComponent(component: ReactNode | undefined): boolean;
|
|
5
5
|
export declare function isSmallIconVariant(iconElement: ReactElement): boolean;
|
|
6
6
|
export declare function getObjectName(name?: string | null, text?: string): string | null;
|
|
7
7
|
export declare function addIconColor(iconComponent: ReactNode, color?: string): ReactElement;
|
|
8
|
-
|
|
8
|
+
/** A text avatar's background: the custom colour its first letter maps to, at shade 500. */
|
|
9
|
+
export declare function getTextBackground(text: string): string;
|
|
9
10
|
export declare function getDefaultAvatarIndex(userId: string | number, totalAvatars: number): number;
|
|
10
11
|
export declare function getTooltipProps(tooltip: AvatarProps['tooltip']): TooltipObject;
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isValidElement, cloneElement } from "react";
|
|
2
2
|
import Icon from "@synerise/ds-icon";
|
|
3
|
-
import { selectColorByLetter } from "@synerise/ds-utils";
|
|
3
|
+
import { selectColorByLetter, resolveCustomColor } from "@synerise/ds-utils";
|
|
4
4
|
function getFirstLetter(from) {
|
|
5
5
|
return (from || "").substr(0, 1).toUpperCase();
|
|
6
6
|
}
|
|
@@ -56,17 +56,11 @@ function addIconColor(iconComponent, color) {
|
|
|
56
56
|
}
|
|
57
57
|
return iconElement;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return [backgroundColor, "100"];
|
|
65
|
-
}
|
|
66
|
-
const autoColor = (typeof text === "string" ? selectColorByLetter(text.slice(0, 1), true) : {})?.color || "grey";
|
|
67
|
-
const color = text && backgroundColor && backgroundColor !== "auto" ? backgroundColor : autoColor;
|
|
68
|
-
const hue = text ? "500" : "100";
|
|
69
|
-
return [color, hue];
|
|
59
|
+
function getTextBackground(text) {
|
|
60
|
+
const {
|
|
61
|
+
color
|
|
62
|
+
} = selectColorByLetter(text.trim().slice(0, 1), true);
|
|
63
|
+
return resolveCustomColor(`${color || "grey"}-500`, "transparent");
|
|
70
64
|
}
|
|
71
65
|
function getDefaultAvatarIndex(userId, totalAvatars) {
|
|
72
66
|
const str = String(userId);
|
|
@@ -95,9 +89,9 @@ function getTooltipProps(tooltip) {
|
|
|
95
89
|
}
|
|
96
90
|
export {
|
|
97
91
|
addIconColor,
|
|
98
|
-
getColorByText,
|
|
99
92
|
getDefaultAvatarIndex,
|
|
100
93
|
getObjectName,
|
|
94
|
+
getTextBackground,
|
|
101
95
|
getTooltipProps,
|
|
102
96
|
getUserText,
|
|
103
97
|
isIconComponent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-avatar",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Avatar UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "synerise/synerise-design",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
],
|
|
44
44
|
"types": "dist/index.d.ts",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@synerise/ds-badge": "^2.1.
|
|
47
|
-
"@synerise/ds-icon": "^2.
|
|
48
|
-
"@synerise/ds-status": "^2.1.
|
|
46
|
+
"@synerise/ds-badge": "^2.1.5",
|
|
47
|
+
"@synerise/ds-icon": "^2.6.0",
|
|
48
|
+
"@synerise/ds-status": "^2.1.5",
|
|
49
49
|
"@synerise/ds-tokens": "^2.1.2",
|
|
50
|
-
"@synerise/ds-tooltip": "^2.1.
|
|
51
|
-
"@synerise/ds-typography": "^2.1.
|
|
50
|
+
"@synerise/ds-tooltip": "^2.1.5",
|
|
51
|
+
"@synerise/ds-typography": "^2.1.5",
|
|
52
52
|
"@synerise/ds-utils": "^2.3.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"react": ">=16.9.0 <= 18.3.1",
|
|
66
66
|
"styled-components": "^5.3.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "2eb32bb38fc5909422347a9286f863db2e5f6832"
|
|
69
69
|
}
|