@vaadin/avatar 24.2.0-alpha4 → 24.2.0-dev.385a0a5b2
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/package.json +14 -12
- package/src/vaadin-avatar-mixin.d.ts +67 -0
- package/src/vaadin-avatar-mixin.js +240 -0
- package/src/vaadin-avatar-styles.js +60 -0
- package/src/vaadin-avatar.d.ts +3 -52
- package/src/vaadin-avatar.js +7 -280
- package/web-types.json +0 -153
- package/web-types.lit.json +0 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/avatar",
|
|
3
|
-
"version": "24.2.0-
|
|
3
|
+
"version": "24.2.0-dev.385a0a5b2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
+
"!src/vaadin-lit-avatar.d.ts",
|
|
25
|
+
"!src/vaadin-lit-avatar.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -37,24 +39,24 @@
|
|
|
37
39
|
],
|
|
38
40
|
"dependencies": {
|
|
39
41
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/a11y-base": "24.2.0-
|
|
41
|
-
"@vaadin/component-base": "24.2.0-
|
|
42
|
-
"@vaadin/item": "24.2.0-
|
|
43
|
-
"@vaadin/list-box": "24.2.0-
|
|
44
|
-
"@vaadin/overlay": "24.2.0-
|
|
45
|
-
"@vaadin/tooltip": "24.2.0-
|
|
46
|
-
"@vaadin/vaadin-lumo-styles": "24.2.0-
|
|
47
|
-
"@vaadin/vaadin-material-styles": "24.2.0-
|
|
48
|
-
"@vaadin/vaadin-themable-mixin": "24.2.0-
|
|
42
|
+
"@vaadin/a11y-base": "24.2.0-dev.385a0a5b2",
|
|
43
|
+
"@vaadin/component-base": "24.2.0-dev.385a0a5b2",
|
|
44
|
+
"@vaadin/item": "24.2.0-dev.385a0a5b2",
|
|
45
|
+
"@vaadin/list-box": "24.2.0-dev.385a0a5b2",
|
|
46
|
+
"@vaadin/overlay": "24.2.0-dev.385a0a5b2",
|
|
47
|
+
"@vaadin/tooltip": "24.2.0-dev.385a0a5b2",
|
|
48
|
+
"@vaadin/vaadin-lumo-styles": "24.2.0-dev.385a0a5b2",
|
|
49
|
+
"@vaadin/vaadin-material-styles": "24.2.0-dev.385a0a5b2",
|
|
50
|
+
"@vaadin/vaadin-themable-mixin": "24.2.0-dev.385a0a5b2"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@esm-bundle/chai": "^4.3.4",
|
|
52
|
-
"@vaadin/testing-helpers": "^0.4.
|
|
54
|
+
"@vaadin/testing-helpers": "^0.4.3",
|
|
53
55
|
"sinon": "^13.0.2"
|
|
54
56
|
},
|
|
55
57
|
"web-types": [
|
|
56
58
|
"web-types.json",
|
|
57
59
|
"web-types.lit.json"
|
|
58
60
|
],
|
|
59
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "9d84e4049890430a33e91ff64a6e751a1ba9b9d9"
|
|
60
62
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
8
|
+
|
|
9
|
+
export interface AvatarI18n {
|
|
10
|
+
anonymous: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A mixin providing common avatar functionality.
|
|
15
|
+
*/
|
|
16
|
+
export declare function AvatarMixin<T extends Constructor<HTMLElement>>(
|
|
17
|
+
base: T,
|
|
18
|
+
): Constructor<AvatarMixinClass> & Constructor<FocusMixinClass> & T;
|
|
19
|
+
|
|
20
|
+
export declare class AvatarMixinClass {
|
|
21
|
+
/**
|
|
22
|
+
* The path to the image
|
|
23
|
+
*/
|
|
24
|
+
img: string | null | undefined;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A shortened form of name that is displayed
|
|
28
|
+
* in the avatar when `img` is not provided.
|
|
29
|
+
*/
|
|
30
|
+
abbr: string | null | undefined;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Full name of the user
|
|
34
|
+
* used for the tooltip of the avatar.
|
|
35
|
+
*/
|
|
36
|
+
name: string | null | undefined;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Color index used for avatar background.
|
|
40
|
+
* @attr {number} color-index
|
|
41
|
+
*/
|
|
42
|
+
colorIndex: number | null | undefined;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The object used to localize this component.
|
|
46
|
+
* To change the default localization, replace the entire
|
|
47
|
+
* _i18n_ object or just the property you want to modify.
|
|
48
|
+
*
|
|
49
|
+
* The object has the following JSON structure and default values:
|
|
50
|
+
*
|
|
51
|
+
* ```
|
|
52
|
+
* {
|
|
53
|
+
* // Translation of the anonymous user avatar tooltip.
|
|
54
|
+
* anonymous: 'anonymous'
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
i18n: AvatarI18n;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* When true, the avatar has tooltip shown on hover and focus.
|
|
62
|
+
* The tooltip text is based on the `name` and `abbr` properties.
|
|
63
|
+
* When neither is provided, `i18n.anonymous` is used instead.
|
|
64
|
+
* @attr {boolean} with-tooltip
|
|
65
|
+
*/
|
|
66
|
+
withTooltip: boolean;
|
|
67
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A mixin providing common avatar functionality.
|
|
10
|
+
*
|
|
11
|
+
* @polymerMixin
|
|
12
|
+
* @mixes FocusMixin
|
|
13
|
+
*/
|
|
14
|
+
export const AvatarMixin = (superClass) =>
|
|
15
|
+
class AvatarMixinClass extends FocusMixin(superClass) {
|
|
16
|
+
static get properties() {
|
|
17
|
+
return {
|
|
18
|
+
/**
|
|
19
|
+
* The path to the image
|
|
20
|
+
*/
|
|
21
|
+
img: {
|
|
22
|
+
type: String,
|
|
23
|
+
reflectToAttribute: true,
|
|
24
|
+
observer: '__imgChanged',
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A shortened form of name that is displayed
|
|
29
|
+
* in the avatar when `img` is not provided.
|
|
30
|
+
*/
|
|
31
|
+
abbr: {
|
|
32
|
+
type: String,
|
|
33
|
+
reflectToAttribute: true,
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Full name of the user
|
|
38
|
+
* used for the tooltip of the avatar.
|
|
39
|
+
*/
|
|
40
|
+
name: {
|
|
41
|
+
type: String,
|
|
42
|
+
reflectToAttribute: true,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Color index used for avatar background.
|
|
47
|
+
* @attr {number} color-index
|
|
48
|
+
*/
|
|
49
|
+
colorIndex: {
|
|
50
|
+
type: Number,
|
|
51
|
+
observer: '__colorIndexChanged',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The object used to localize this component.
|
|
56
|
+
* To change the default localization, replace the entire
|
|
57
|
+
* _i18n_ object or just the property you want to modify.
|
|
58
|
+
*
|
|
59
|
+
* The object has the following JSON structure and default values:
|
|
60
|
+
*
|
|
61
|
+
* ```
|
|
62
|
+
* {
|
|
63
|
+
* // Translation of the anonymous user avatar tooltip.
|
|
64
|
+
* anonymous: 'anonymous'
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @type {!AvatarI18n}
|
|
69
|
+
* @default {English/US}
|
|
70
|
+
*/
|
|
71
|
+
i18n: {
|
|
72
|
+
type: Object,
|
|
73
|
+
value: () => {
|
|
74
|
+
return {
|
|
75
|
+
anonymous: 'anonymous',
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* When true, the avatar has tooltip shown on hover and focus.
|
|
82
|
+
* The tooltip text is based on the `name` and `abbr` properties.
|
|
83
|
+
* When neither is provided, `i18n.anonymous` is used instead.
|
|
84
|
+
* @attr {boolean} with-tooltip
|
|
85
|
+
*/
|
|
86
|
+
withTooltip: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
value: false,
|
|
89
|
+
observer: '__withTooltipChanged',
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/** @protected */
|
|
93
|
+
__imgVisible: Boolean,
|
|
94
|
+
|
|
95
|
+
/** @protected */
|
|
96
|
+
__iconVisible: Boolean,
|
|
97
|
+
|
|
98
|
+
/** @protected */
|
|
99
|
+
__abbrVisible: Boolean,
|
|
100
|
+
|
|
101
|
+
/** @private */
|
|
102
|
+
__tooltipNode: Object,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static get observers() {
|
|
107
|
+
return [
|
|
108
|
+
'__imgOrAbbrOrNameChanged(img, abbr, name)',
|
|
109
|
+
'__i18nChanged(i18n)',
|
|
110
|
+
'__tooltipChanged(__tooltipNode, name, abbr)',
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** @protected */
|
|
115
|
+
ready() {
|
|
116
|
+
super.ready();
|
|
117
|
+
|
|
118
|
+
this.__updateVisibility();
|
|
119
|
+
|
|
120
|
+
// By default, if the user hasn't provided a custom role,
|
|
121
|
+
// the role attribute is set to "button".
|
|
122
|
+
if (!this.hasAttribute('role')) {
|
|
123
|
+
this.setAttribute('role', 'button');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!this.hasAttribute('tabindex')) {
|
|
127
|
+
this.setAttribute('tabindex', '0');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Should set `anonymous` if name / abbr is not provided
|
|
131
|
+
if (!this.name && !this.abbr) {
|
|
132
|
+
this.__setTooltip();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** @private */
|
|
137
|
+
__colorIndexChanged(index) {
|
|
138
|
+
if (index != null) {
|
|
139
|
+
const prop = `--vaadin-user-color-${index}`;
|
|
140
|
+
|
|
141
|
+
// Check if custom CSS property is defined
|
|
142
|
+
const isValid = Boolean(getComputedStyle(document.documentElement).getPropertyValue(prop));
|
|
143
|
+
|
|
144
|
+
if (isValid) {
|
|
145
|
+
this.setAttribute('has-color-index', '');
|
|
146
|
+
this.style.setProperty('--vaadin-avatar-user-color', `var(${prop})`);
|
|
147
|
+
} else {
|
|
148
|
+
this.removeAttribute('has-color-index');
|
|
149
|
+
console.warn(`The CSS property --vaadin-user-color-${index} is not defined`);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
this.removeAttribute('has-color-index');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** @private */
|
|
157
|
+
__imgChanged() {
|
|
158
|
+
this.__imgFailedToLoad = false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** @private */
|
|
162
|
+
__imgOrAbbrOrNameChanged(img, abbr, name) {
|
|
163
|
+
this.__updateVisibility();
|
|
164
|
+
|
|
165
|
+
if (abbr && abbr !== this.__generatedAbbr) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (name) {
|
|
170
|
+
this.abbr = this.__generatedAbbr = name
|
|
171
|
+
.split(' ')
|
|
172
|
+
.map((word) => word.charAt(0))
|
|
173
|
+
.join('');
|
|
174
|
+
} else {
|
|
175
|
+
this.abbr = undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** @private */
|
|
180
|
+
__tooltipChanged(tooltipNode, name, abbr) {
|
|
181
|
+
if (tooltipNode) {
|
|
182
|
+
if (abbr && abbr !== this.__generatedAbbr) {
|
|
183
|
+
this.__setTooltip(name ? `${name} (${abbr})` : abbr);
|
|
184
|
+
} else {
|
|
185
|
+
this.__setTooltip(name);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** @private */
|
|
191
|
+
__withTooltipChanged(withTooltip, oldWithTooltip) {
|
|
192
|
+
if (withTooltip) {
|
|
193
|
+
// Create and attach tooltip
|
|
194
|
+
const tooltipNode = document.createElement('vaadin-tooltip');
|
|
195
|
+
tooltipNode.setAttribute('slot', 'tooltip');
|
|
196
|
+
this.appendChild(tooltipNode);
|
|
197
|
+
this.__tooltipNode = tooltipNode;
|
|
198
|
+
} else if (oldWithTooltip) {
|
|
199
|
+
// Cleanup and detach tooltip
|
|
200
|
+
this.__tooltipNode.target = null;
|
|
201
|
+
this.__tooltipNode.remove();
|
|
202
|
+
this.__tooltipNode = null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** @private */
|
|
207
|
+
__i18nChanged(i18n) {
|
|
208
|
+
if (i18n && i18n.anonymous) {
|
|
209
|
+
if (this.__oldAnonymous && this.__tooltipNode && this.__tooltipNode.text === this.__oldAnonymous) {
|
|
210
|
+
this.__setTooltip();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.__oldAnonymous = i18n.anonymous;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** @private */
|
|
218
|
+
__updateVisibility() {
|
|
219
|
+
this.__imgVisible = !!this.img && !this.__imgFailedToLoad;
|
|
220
|
+
this.__abbrVisible = !this.__imgVisible && !!this.abbr;
|
|
221
|
+
this.__iconVisible = !this.__imgVisible && !this.abbr;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** @private */
|
|
225
|
+
__setTooltip(tooltip) {
|
|
226
|
+
const tooltipNode = this.__tooltipNode;
|
|
227
|
+
if (tooltipNode) {
|
|
228
|
+
tooltipNode.text = tooltip || this.i18n.anonymous;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** @protected */
|
|
233
|
+
__onImageLoadError() {
|
|
234
|
+
if (this.img) {
|
|
235
|
+
console.warn(`<vaadin-avatar> The specified image could not be loaded: ${this.img}`);
|
|
236
|
+
this.__imgFailedToLoad = true;
|
|
237
|
+
this.__updateVisibility();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
|
+
|
|
8
|
+
export const avatarStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
flex: none;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
height: var(--vaadin-avatar-size, 64px);
|
|
15
|
+
width: var(--vaadin-avatar-size, 64px);
|
|
16
|
+
border: var(--vaadin-avatar-outline-width) solid transparent;
|
|
17
|
+
margin: calc(var(--vaadin-avatar-outline-width) * -1);
|
|
18
|
+
background-clip: content-box;
|
|
19
|
+
--vaadin-avatar-outline-width: 2px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
img {
|
|
23
|
+
height: 100%;
|
|
24
|
+
width: 100%;
|
|
25
|
+
object-fit: cover;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[part='icon'] {
|
|
29
|
+
font-size: 5.6em;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part='abbr'] {
|
|
33
|
+
font-size: 2.2em;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[part='icon'] > text {
|
|
37
|
+
font-family: 'vaadin-avatar-icons';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:host([hidden]) {
|
|
41
|
+
display: none !important;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
svg[hidden] {
|
|
45
|
+
display: none !important;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host([has-color-index]) {
|
|
49
|
+
position: relative;
|
|
50
|
+
background-color: var(--vaadin-avatar-user-color);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host([has-color-index])::before {
|
|
54
|
+
position: absolute;
|
|
55
|
+
content: '';
|
|
56
|
+
inset: 0;
|
|
57
|
+
border-radius: inherit;
|
|
58
|
+
box-shadow: inset 0 0 0 2px var(--vaadin-avatar-user-color);
|
|
59
|
+
}
|
|
60
|
+
`;
|
package/src/vaadin-avatar.d.ts
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
* Copyright (c) 2020 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
7
6
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
7
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
+
import { AvatarMixin } from './vaadin-avatar-mixin.js';
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
anonymous: string;
|
|
13
|
-
}
|
|
11
|
+
export { AvatarI18n } from './vaadin-avatar-mixin.js';
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* `<vaadin-avatar>` is a Web Component providing avatar displaying functionality.
|
|
@@ -38,54 +36,7 @@ export interface AvatarI18n {
|
|
|
38
36
|
*
|
|
39
37
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
40
38
|
*/
|
|
41
|
-
declare class Avatar extends
|
|
42
|
-
/**
|
|
43
|
-
* The path to the image
|
|
44
|
-
*/
|
|
45
|
-
img: string | null | undefined;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A shortened form of name that is displayed
|
|
49
|
-
* in the avatar when `img` is not provided.
|
|
50
|
-
*/
|
|
51
|
-
abbr: string | null | undefined;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Full name of the user
|
|
55
|
-
* used for the tooltip of the avatar.
|
|
56
|
-
*/
|
|
57
|
-
name: string | null | undefined;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Color index used for avatar background.
|
|
61
|
-
* @attr {number} color-index
|
|
62
|
-
*/
|
|
63
|
-
colorIndex: number | null | undefined;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The object used to localize this component.
|
|
67
|
-
* To change the default localization, replace the entire
|
|
68
|
-
* _i18n_ object or just the property you want to modify.
|
|
69
|
-
*
|
|
70
|
-
* The object has the following JSON structure and default values:
|
|
71
|
-
*
|
|
72
|
-
* ```
|
|
73
|
-
* {
|
|
74
|
-
* // Translation of the anonymous user avatar tooltip.
|
|
75
|
-
* anonymous: 'anonymous'
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
i18n: AvatarI18n;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* When true, the avatar has tooltip shown on hover and focus.
|
|
83
|
-
* The tooltip text is based on the `name` and `abbr` properties.
|
|
84
|
-
* When neither is provided, `i18n.anonymous` is used instead.
|
|
85
|
-
* @attr {boolean} with-tooltip
|
|
86
|
-
*/
|
|
87
|
-
withTooltip: boolean;
|
|
88
|
-
}
|
|
39
|
+
declare class Avatar extends AvatarMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement)))) {}
|
|
89
40
|
|
|
90
41
|
declare global {
|
|
91
42
|
interface HTMLElementTagNameMap {
|
package/src/vaadin-avatar.js
CHANGED
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-avatar-icons.js';
|
|
7
7
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
|
-
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
9
8
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
10
9
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
10
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
12
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
+
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
+
import { AvatarMixin } from './vaadin-avatar-mixin.js';
|
|
13
|
+
import { avatarStyles } from './vaadin-avatar-styles.js';
|
|
14
|
+
|
|
15
|
+
registerStyles('vaadin-avatar', avatarStyles, { moduleId: 'vaadin-avatar-styles' });
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* `<vaadin-avatar>` is a Web Component providing avatar displaying functionality.
|
|
@@ -38,70 +41,14 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
38
41
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
39
42
|
*
|
|
40
43
|
* @extends HTMLElement
|
|
44
|
+
* @mixes AvatarMixin
|
|
41
45
|
* @mixes ControllerMixin
|
|
42
|
-
* @mixes FocusMixin
|
|
43
46
|
* @mixes ElementMixin
|
|
44
47
|
* @mixes ThemableMixin
|
|
45
48
|
*/
|
|
46
|
-
class Avatar extends
|
|
49
|
+
class Avatar extends AvatarMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
|
|
47
50
|
static get template() {
|
|
48
51
|
return html`
|
|
49
|
-
<style>
|
|
50
|
-
:host {
|
|
51
|
-
display: inline-block;
|
|
52
|
-
flex: none;
|
|
53
|
-
border-radius: 50%;
|
|
54
|
-
overflow: hidden;
|
|
55
|
-
height: var(--vaadin-avatar-size, 64px);
|
|
56
|
-
width: var(--vaadin-avatar-size, 64px);
|
|
57
|
-
border: var(--vaadin-avatar-outline-width) solid transparent;
|
|
58
|
-
margin: calc(var(--vaadin-avatar-outline-width) * -1);
|
|
59
|
-
background-clip: content-box;
|
|
60
|
-
--vaadin-avatar-outline-width: 2px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
img {
|
|
64
|
-
height: 100%;
|
|
65
|
-
width: 100%;
|
|
66
|
-
object-fit: cover;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
[part='icon'] {
|
|
70
|
-
font-size: 5.6em;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
[part='abbr'] {
|
|
74
|
-
font-size: 2.2em;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
[part='icon'] > text {
|
|
78
|
-
font-family: 'vaadin-avatar-icons';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
:host([hidden]) {
|
|
82
|
-
display: none !important;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
svg[hidden] {
|
|
86
|
-
display: none !important;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
:host([has-color-index]) {
|
|
90
|
-
position: relative;
|
|
91
|
-
background-color: var(--vaadin-avatar-user-color);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
:host([has-color-index])::before {
|
|
95
|
-
position: absolute;
|
|
96
|
-
content: '';
|
|
97
|
-
top: 0;
|
|
98
|
-
left: 0;
|
|
99
|
-
bottom: 0;
|
|
100
|
-
right: 0;
|
|
101
|
-
border-radius: inherit;
|
|
102
|
-
box-shadow: inset 0 0 0 2px var(--vaadin-avatar-user-color);
|
|
103
|
-
}
|
|
104
|
-
</style>
|
|
105
52
|
<img hidden$="[[!__imgVisible]]" src$="[[img]]" aria-hidden="true" on-error="__onImageLoadError" />
|
|
106
53
|
<svg
|
|
107
54
|
part="icon"
|
|
@@ -132,232 +79,12 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(ControllerMixin(Polym
|
|
|
132
79
|
return 'vaadin-avatar';
|
|
133
80
|
}
|
|
134
81
|
|
|
135
|
-
static get properties() {
|
|
136
|
-
return {
|
|
137
|
-
/**
|
|
138
|
-
* The path to the image
|
|
139
|
-
*/
|
|
140
|
-
img: {
|
|
141
|
-
type: String,
|
|
142
|
-
reflectToAttribute: true,
|
|
143
|
-
observer: '__imgChanged',
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* A shortened form of name that is displayed
|
|
148
|
-
* in the avatar when `img` is not provided.
|
|
149
|
-
*/
|
|
150
|
-
abbr: {
|
|
151
|
-
type: String,
|
|
152
|
-
reflectToAttribute: true,
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Full name of the user
|
|
157
|
-
* used for the tooltip of the avatar.
|
|
158
|
-
*/
|
|
159
|
-
name: {
|
|
160
|
-
type: String,
|
|
161
|
-
reflectToAttribute: true,
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Color index used for avatar background.
|
|
166
|
-
* @attr {number} color-index
|
|
167
|
-
*/
|
|
168
|
-
colorIndex: {
|
|
169
|
-
type: Number,
|
|
170
|
-
observer: '__colorIndexChanged',
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* The object used to localize this component.
|
|
175
|
-
* To change the default localization, replace the entire
|
|
176
|
-
* _i18n_ object or just the property you want to modify.
|
|
177
|
-
*
|
|
178
|
-
* The object has the following JSON structure and default values:
|
|
179
|
-
*
|
|
180
|
-
* ```
|
|
181
|
-
* {
|
|
182
|
-
* // Translation of the anonymous user avatar tooltip.
|
|
183
|
-
* anonymous: 'anonymous'
|
|
184
|
-
* }
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* @type {!AvatarI18n}
|
|
188
|
-
* @default {English/US}
|
|
189
|
-
*/
|
|
190
|
-
i18n: {
|
|
191
|
-
type: Object,
|
|
192
|
-
value: () => {
|
|
193
|
-
return {
|
|
194
|
-
anonymous: 'anonymous',
|
|
195
|
-
};
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* When true, the avatar has tooltip shown on hover and focus.
|
|
201
|
-
* The tooltip text is based on the `name` and `abbr` properties.
|
|
202
|
-
* When neither is provided, `i18n.anonymous` is used instead.
|
|
203
|
-
* @attr {boolean} with-tooltip
|
|
204
|
-
*/
|
|
205
|
-
withTooltip: {
|
|
206
|
-
type: Boolean,
|
|
207
|
-
value: false,
|
|
208
|
-
observer: '__withTooltipChanged',
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
/** @private */
|
|
212
|
-
__imgVisible: Boolean,
|
|
213
|
-
|
|
214
|
-
/** @private */
|
|
215
|
-
__iconVisible: Boolean,
|
|
216
|
-
|
|
217
|
-
/** @private */
|
|
218
|
-
__abbrVisible: Boolean,
|
|
219
|
-
|
|
220
|
-
/** @private */
|
|
221
|
-
__tooltipNode: Object,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
static get observers() {
|
|
226
|
-
return [
|
|
227
|
-
'__imgOrAbbrOrNameChanged(img, abbr, name)',
|
|
228
|
-
'__i18nChanged(i18n.*)',
|
|
229
|
-
'__tooltipChanged(__tooltipNode, name, abbr)',
|
|
230
|
-
];
|
|
231
|
-
}
|
|
232
|
-
|
|
233
82
|
/** @protected */
|
|
234
83
|
ready() {
|
|
235
84
|
super.ready();
|
|
236
85
|
|
|
237
|
-
this.__updateVisibility();
|
|
238
|
-
|
|
239
|
-
// By default, if the user hasn't provided a custom role,
|
|
240
|
-
// the role attribute is set to "button".
|
|
241
|
-
if (!this.hasAttribute('role')) {
|
|
242
|
-
this.setAttribute('role', 'button');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (!this.hasAttribute('tabindex')) {
|
|
246
|
-
this.setAttribute('tabindex', '0');
|
|
247
|
-
}
|
|
248
|
-
|
|
249
86
|
this._tooltipController = new TooltipController(this);
|
|
250
87
|
this.addController(this._tooltipController);
|
|
251
|
-
|
|
252
|
-
// Should set `anonymous` if name / abbr is not provided
|
|
253
|
-
if (!this.name && !this.abbr) {
|
|
254
|
-
this.__setTooltip();
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/** @private */
|
|
259
|
-
__colorIndexChanged(index) {
|
|
260
|
-
if (index != null) {
|
|
261
|
-
const prop = `--vaadin-user-color-${index}`;
|
|
262
|
-
|
|
263
|
-
// Check if custom CSS property is defined
|
|
264
|
-
const isValid = Boolean(getComputedStyle(document.documentElement).getPropertyValue(prop));
|
|
265
|
-
|
|
266
|
-
if (isValid) {
|
|
267
|
-
this.setAttribute('has-color-index', '');
|
|
268
|
-
this.style.setProperty('--vaadin-avatar-user-color', `var(${prop})`);
|
|
269
|
-
} else {
|
|
270
|
-
this.removeAttribute('has-color-index');
|
|
271
|
-
console.warn(`The CSS property --vaadin-user-color-${index} is not defined`);
|
|
272
|
-
}
|
|
273
|
-
} else {
|
|
274
|
-
this.removeAttribute('has-color-index');
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/** @private */
|
|
279
|
-
__imgChanged() {
|
|
280
|
-
this.__imgFailedToLoad = false;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/** @private */
|
|
284
|
-
__imgOrAbbrOrNameChanged(img, abbr, name) {
|
|
285
|
-
this.__updateVisibility();
|
|
286
|
-
|
|
287
|
-
if (abbr && abbr !== this.__generatedAbbr) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (name) {
|
|
292
|
-
this.abbr = this.__generatedAbbr = name
|
|
293
|
-
.split(' ')
|
|
294
|
-
.map((word) => word.charAt(0))
|
|
295
|
-
.join('');
|
|
296
|
-
} else {
|
|
297
|
-
this.abbr = undefined;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/** @private */
|
|
302
|
-
__tooltipChanged(tooltipNode, name, abbr) {
|
|
303
|
-
if (tooltipNode) {
|
|
304
|
-
if (abbr && abbr !== this.__generatedAbbr) {
|
|
305
|
-
this.__setTooltip(name ? `${name} (${abbr})` : abbr);
|
|
306
|
-
} else {
|
|
307
|
-
this.__setTooltip(name);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/** @private */
|
|
313
|
-
__withTooltipChanged(withTooltip, oldWithTooltip) {
|
|
314
|
-
if (withTooltip) {
|
|
315
|
-
// Create and attach tooltip
|
|
316
|
-
const tooltipNode = document.createElement('vaadin-tooltip');
|
|
317
|
-
tooltipNode.setAttribute('slot', 'tooltip');
|
|
318
|
-
this.appendChild(tooltipNode);
|
|
319
|
-
this.__tooltipNode = tooltipNode;
|
|
320
|
-
} else if (oldWithTooltip) {
|
|
321
|
-
// Cleanup and detach tooltip
|
|
322
|
-
this.__tooltipNode.target = null;
|
|
323
|
-
this.__tooltipNode.remove();
|
|
324
|
-
this.__tooltipNode = null;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/** @private */
|
|
329
|
-
__i18nChanged(i18n) {
|
|
330
|
-
if (i18n.base && i18n.base.anonymous) {
|
|
331
|
-
if (this.__oldAnonymous && this.__tooltipNode && this.__tooltipNode.text === this.__oldAnonymous) {
|
|
332
|
-
this.__setTooltip();
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
this.__oldAnonymous = i18n.base.anonymous;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/** @private */
|
|
340
|
-
__updateVisibility() {
|
|
341
|
-
this.__imgVisible = !!this.img && !this.__imgFailedToLoad;
|
|
342
|
-
this.__abbrVisible = !this.__imgVisible && !!this.abbr;
|
|
343
|
-
this.__iconVisible = !this.__imgVisible && !this.abbr;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/** @private */
|
|
347
|
-
__setTooltip(tooltip) {
|
|
348
|
-
const tooltipNode = this.__tooltipNode;
|
|
349
|
-
if (tooltipNode) {
|
|
350
|
-
tooltipNode.text = tooltip || this.i18n.anonymous;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/** @private */
|
|
355
|
-
__onImageLoadError() {
|
|
356
|
-
if (this.img) {
|
|
357
|
-
console.warn(`<vaadin-avatar> The specified image could not be loaded: ${this.img}`);
|
|
358
|
-
this.__imgFailedToLoad = true;
|
|
359
|
-
this.__updateVisibility();
|
|
360
|
-
}
|
|
361
88
|
}
|
|
362
89
|
}
|
|
363
90
|
|
package/web-types.json
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/web-types",
|
|
3
|
-
"name": "@vaadin/avatar",
|
|
4
|
-
"version": "24.2.0-alpha4",
|
|
5
|
-
"description-markup": "markdown",
|
|
6
|
-
"contributions": {
|
|
7
|
-
"html": {
|
|
8
|
-
"elements": [
|
|
9
|
-
{
|
|
10
|
-
"name": "vaadin-avatar",
|
|
11
|
-
"description": "`<vaadin-avatar>` is a Web Component providing avatar displaying functionality.\n\n```html\n<vaadin-avatar img=\"avatars/avatar-1.jpg\"></vaadin-avatar>\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n--------- | ---------------\n`abbr` | The abbreviation element\n`icon` | The icon element\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n------------------|-------------\n`focus-ring` | Set when the avatar is focused using the keyboard.\n`focused` | Set when the avatar is focused.\n`has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
12
|
-
"attributes": [
|
|
13
|
-
{
|
|
14
|
-
"name": "img",
|
|
15
|
-
"description": "The path to the image",
|
|
16
|
-
"value": {
|
|
17
|
-
"type": [
|
|
18
|
-
"string",
|
|
19
|
-
"null",
|
|
20
|
-
"undefined"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "abbr",
|
|
26
|
-
"description": "A shortened form of name that is displayed\nin the avatar when `img` is not provided.",
|
|
27
|
-
"value": {
|
|
28
|
-
"type": [
|
|
29
|
-
"string",
|
|
30
|
-
"null",
|
|
31
|
-
"undefined"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"name": "name",
|
|
37
|
-
"description": "Full name of the user\nused for the tooltip of the avatar.",
|
|
38
|
-
"value": {
|
|
39
|
-
"type": [
|
|
40
|
-
"string",
|
|
41
|
-
"null",
|
|
42
|
-
"undefined"
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"name": "color-index",
|
|
48
|
-
"description": "Color index used for avatar background.",
|
|
49
|
-
"value": {
|
|
50
|
-
"type": [
|
|
51
|
-
"number",
|
|
52
|
-
"null",
|
|
53
|
-
"undefined"
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"name": "with-tooltip",
|
|
59
|
-
"description": "When true, the avatar has tooltip shown on hover and focus.\nThe tooltip text is based on the `name` and `abbr` properties.\nWhen neither is provided, `i18n.anonymous` is used instead.",
|
|
60
|
-
"value": {
|
|
61
|
-
"type": [
|
|
62
|
-
"boolean",
|
|
63
|
-
"null",
|
|
64
|
-
"undefined"
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"name": "theme",
|
|
70
|
-
"description": "The theme variants to apply to the component.",
|
|
71
|
-
"value": {
|
|
72
|
-
"type": [
|
|
73
|
-
"string",
|
|
74
|
-
"null",
|
|
75
|
-
"undefined"
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
"js": {
|
|
81
|
-
"properties": [
|
|
82
|
-
{
|
|
83
|
-
"name": "img",
|
|
84
|
-
"description": "The path to the image",
|
|
85
|
-
"value": {
|
|
86
|
-
"type": [
|
|
87
|
-
"string",
|
|
88
|
-
"null",
|
|
89
|
-
"undefined"
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"name": "abbr",
|
|
95
|
-
"description": "A shortened form of name that is displayed\nin the avatar when `img` is not provided.",
|
|
96
|
-
"value": {
|
|
97
|
-
"type": [
|
|
98
|
-
"string",
|
|
99
|
-
"null",
|
|
100
|
-
"undefined"
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"name": "name",
|
|
106
|
-
"description": "Full name of the user\nused for the tooltip of the avatar.",
|
|
107
|
-
"value": {
|
|
108
|
-
"type": [
|
|
109
|
-
"string",
|
|
110
|
-
"null",
|
|
111
|
-
"undefined"
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"name": "colorIndex",
|
|
117
|
-
"description": "Color index used for avatar background.",
|
|
118
|
-
"value": {
|
|
119
|
-
"type": [
|
|
120
|
-
"number",
|
|
121
|
-
"null",
|
|
122
|
-
"undefined"
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
"name": "i18n",
|
|
128
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n_i18n_ object or just the property you want to modify.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
|
|
129
|
-
"value": {
|
|
130
|
-
"type": [
|
|
131
|
-
"AvatarI18n"
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"name": "withTooltip",
|
|
137
|
-
"description": "When true, the avatar has tooltip shown on hover and focus.\nThe tooltip text is based on the `name` and `abbr` properties.\nWhen neither is provided, `i18n.anonymous` is used instead.",
|
|
138
|
-
"value": {
|
|
139
|
-
"type": [
|
|
140
|
-
"boolean",
|
|
141
|
-
"null",
|
|
142
|
-
"undefined"
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
"events": []
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
package/web-types.lit.json
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/web-types",
|
|
3
|
-
"name": "@vaadin/avatar",
|
|
4
|
-
"version": "24.2.0-alpha4",
|
|
5
|
-
"description-markup": "markdown",
|
|
6
|
-
"framework": "lit",
|
|
7
|
-
"framework-config": {
|
|
8
|
-
"enable-when": {
|
|
9
|
-
"node-packages": [
|
|
10
|
-
"lit"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"contributions": {
|
|
15
|
-
"html": {
|
|
16
|
-
"elements": [
|
|
17
|
-
{
|
|
18
|
-
"name": "vaadin-avatar",
|
|
19
|
-
"description": "`<vaadin-avatar>` is a Web Component providing avatar displaying functionality.\n\n```html\n<vaadin-avatar img=\"avatars/avatar-1.jpg\"></vaadin-avatar>\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n--------- | ---------------\n`abbr` | The abbreviation element\n`icon` | The icon element\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n------------------|-------------\n`focus-ring` | Set when the avatar is focused using the keyboard.\n`focused` | Set when the avatar is focused.\n`has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
20
|
-
"extension": true,
|
|
21
|
-
"attributes": [
|
|
22
|
-
{
|
|
23
|
-
"name": "?withTooltip",
|
|
24
|
-
"description": "When true, the avatar has tooltip shown on hover and focus.\nThe tooltip text is based on the `name` and `abbr` properties.\nWhen neither is provided, `i18n.anonymous` is used instead.",
|
|
25
|
-
"value": {
|
|
26
|
-
"kind": "expression"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"name": ".img",
|
|
31
|
-
"description": "The path to the image",
|
|
32
|
-
"value": {
|
|
33
|
-
"kind": "expression"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": ".abbr",
|
|
38
|
-
"description": "A shortened form of name that is displayed\nin the avatar when `img` is not provided.",
|
|
39
|
-
"value": {
|
|
40
|
-
"kind": "expression"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"name": ".name",
|
|
45
|
-
"description": "Full name of the user\nused for the tooltip of the avatar.",
|
|
46
|
-
"value": {
|
|
47
|
-
"kind": "expression"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"name": ".colorIndex",
|
|
52
|
-
"description": "Color index used for avatar background.",
|
|
53
|
-
"value": {
|
|
54
|
-
"kind": "expression"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"name": ".i18n",
|
|
59
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n_i18n_ object or just the property you want to modify.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
|
|
60
|
-
"value": {
|
|
61
|
-
"kind": "expression"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|