@vaadin/avatar 23.2.0-dev.8a7678b70 → 23.3.0-alpha1

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A web component for graphical representation of an object or entity, for example a person or an organization.
4
4
 
5
- [Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/avatar)
5
+ [Documentation + Live Demo ↗](https://vaadin.com/docs/latest/components/avatar)
6
6
 
7
7
  [![npm version](https://badgen.net/npm/v/@vaadin/avatar)](https://www.npmjs.com/package/@vaadin/avatar)
8
8
  [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
@@ -13,7 +13,7 @@ A web component for graphical representation of an object or entity, for example
13
13
  <vaadin-avatar abbr="SK"></vaadin-avatar>
14
14
  ```
15
15
 
16
- [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/avatar/screenshot.png" width="132" alt="Screenshot of vaadin-avatar">](https://vaadin.com/docs/latest/ds/components/avatar)
16
+ [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/avatar/screenshot.png" width="132" alt="Screenshot of vaadin-avatar">](https://vaadin.com/docs/latest/components/avatar)
17
17
 
18
18
  ## Installation
19
19
 
@@ -31,7 +31,7 @@ import '@vaadin/avatar';
31
31
 
32
32
  ## Themes
33
33
 
34
- Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
34
+ Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
35
35
  The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/avatar/vaadin-avatar.js) of the package uses the Lumo theme.
36
36
 
37
37
  To use the Material theme, import the component from the `theme/material` folder:
@@ -54,7 +54,7 @@ import '@vaadin/avatar/src/vaadin-avatar.js';
54
54
 
55
55
  ## Contributing
56
56
 
57
- Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
57
+ Read the [contributing guide](https://vaadin.com/docs/latest/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
58
58
 
59
59
  ## License
60
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/avatar",
3
- "version": "23.2.0-dev.8a7678b70",
3
+ "version": "23.3.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,7 +23,9 @@
23
23
  "src",
24
24
  "theme",
25
25
  "vaadin-*.d.ts",
26
- "vaadin-*.js"
26
+ "vaadin-*.js",
27
+ "web-types.json",
28
+ "web-types.lit.json"
27
29
  ],
28
30
  "keywords": [
29
31
  "Vaadin",
@@ -35,18 +37,23 @@
35
37
  ],
36
38
  "dependencies": {
37
39
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/component-base": "23.2.0-dev.8a7678b70",
39
- "@vaadin/item": "23.2.0-dev.8a7678b70",
40
- "@vaadin/list-box": "23.2.0-dev.8a7678b70",
41
- "@vaadin/vaadin-lumo-styles": "23.2.0-dev.8a7678b70",
42
- "@vaadin/vaadin-material-styles": "23.2.0-dev.8a7678b70",
43
- "@vaadin/vaadin-overlay": "23.2.0-dev.8a7678b70",
44
- "@vaadin/vaadin-themable-mixin": "23.2.0-dev.8a7678b70"
40
+ "@vaadin/component-base": "23.3.0-alpha1",
41
+ "@vaadin/item": "23.3.0-alpha1",
42
+ "@vaadin/list-box": "23.3.0-alpha1",
43
+ "@vaadin/tooltip": "23.3.0-alpha1",
44
+ "@vaadin/vaadin-lumo-styles": "23.3.0-alpha1",
45
+ "@vaadin/vaadin-material-styles": "23.3.0-alpha1",
46
+ "@vaadin/vaadin-overlay": "23.3.0-alpha1",
47
+ "@vaadin/vaadin-themable-mixin": "23.3.0-alpha1"
45
48
  },
46
49
  "devDependencies": {
47
50
  "@esm-bundle/chai": "^4.3.4",
48
51
  "@vaadin/testing-helpers": "^0.3.2",
49
52
  "sinon": "^13.0.2"
50
53
  },
51
- "gitHead": "85b403f96d8282f262322b56c0ff4289f843d02a"
54
+ "web-types": [
55
+ "web-types.json",
56
+ "web-types.lit.json"
57
+ ],
58
+ "gitHead": "beabc527d4b1274eb798ff701d406fed45cfe638"
52
59
  }
@@ -3,9 +3,9 @@
3
3
  * Copyright (c) 2020 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- const $_documentContainer = document.createElement('template');
6
+ const template = document.createElement('template');
7
7
 
8
- $_documentContainer.innerHTML = `
8
+ template.innerHTML = `
9
9
  <style>
10
10
  @font-face {
11
11
  font-family: 'vaadin-avatar-icons';
@@ -16,4 +16,4 @@ $_documentContainer.innerHTML = `
16
16
  </style>
17
17
  `;
18
18
 
19
- document.head.appendChild($_documentContainer.content);
19
+ document.head.appendChild(template.content);
@@ -3,6 +3,7 @@
3
3
  * Copyright (c) 2020 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
6
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
8
  import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
8
9
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -35,9 +36,9 @@ export interface AvatarI18n {
35
36
  * `focused` | Set when the avatar is focused.
36
37
  * `has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.
37
38
  *
38
- * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
39
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
39
40
  */
40
- declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(HTMLElement))) {
41
+ declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement)))) {
41
42
  /**
42
43
  * The path to the image
43
44
  */
@@ -51,12 +52,13 @@ declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(HTMLElement))
51
52
 
52
53
  /**
53
54
  * Full name of the user
54
- * used for the title of the avatar.
55
+ * used for the tooltip of the avatar.
55
56
  */
56
57
  name: string | null | undefined;
57
58
 
58
59
  /**
59
60
  * Color index used for avatar background.
61
+ * @attr {number} color-index
60
62
  */
61
63
  colorIndex: number | null | undefined;
62
64
 
@@ -66,12 +68,23 @@ declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(HTMLElement))
66
68
  * _i18n_ object or just the property you want to modify.
67
69
  *
68
70
  * The object has the following JSON structure and default values:
69
- * {
70
- * // Translation of the anonymous user avatar title.
71
- * anonymous: 'anonymous'
72
- * }
71
+ *
72
+ * ```
73
+ * {
74
+ * // Translation of the anonymous user avatar tooltip.
75
+ * anonymous: 'anonymous'
76
+ * }
77
+ * ```
73
78
  */
74
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;
75
88
  }
76
89
 
77
90
  declare global {
@@ -5,8 +5,10 @@
5
5
  */
6
6
  import './vaadin-avatar-icons.js';
7
7
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
8
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
9
10
  import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
11
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
10
12
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
13
 
12
14
  /**
@@ -33,14 +35,15 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
33
35
  * `focused` | Set when the avatar is focused.
34
36
  * `has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.
35
37
  *
36
- * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
38
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
37
39
  *
38
40
  * @extends HTMLElement
41
+ * @mixes ControllerMixin
39
42
  * @mixes FocusMixin
40
43
  * @mixes ElementMixin
41
44
  * @mixes ThemableMixin
42
45
  */
43
- class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
46
+ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
44
47
  static get template() {
45
48
  return html`
46
49
  <style>
@@ -49,13 +52,12 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
49
52
  flex: none;
50
53
  border-radius: 50%;
51
54
  overflow: hidden;
52
- height: var(--vaadin-avatar-size);
53
- width: var(--vaadin-avatar-size);
55
+ height: var(--vaadin-avatar-size, 64px);
56
+ width: var(--vaadin-avatar-size, 64px);
54
57
  border: var(--vaadin-avatar-outline-width) solid transparent;
55
58
  margin: calc(var(--vaadin-avatar-outline-width) * -1);
56
59
  background-clip: content-box;
57
60
  --vaadin-avatar-outline-width: 2px;
58
- --vaadin-avatar-size: 64px;
59
61
  }
60
62
 
61
63
  img {
@@ -121,6 +123,8 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
121
123
  >
122
124
  <text dy=".35em" text-anchor="middle">[[abbr]]</text>
123
125
  </svg>
126
+
127
+ <slot name="tooltip"></slot>
124
128
  `;
125
129
  }
126
130
 
@@ -150,7 +154,7 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
150
154
 
151
155
  /**
152
156
  * Full name of the user
153
- * used for the title of the avatar.
157
+ * used for the tooltip of the avatar.
154
158
  */
155
159
  name: {
156
160
  type: String,
@@ -159,6 +163,7 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
159
163
 
160
164
  /**
161
165
  * Color index used for avatar background.
166
+ * @attr {number} color-index
162
167
  */
163
168
  colorIndex: {
164
169
  type: Number,
@@ -171,13 +176,17 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
171
176
  * _i18n_ object or just the property you want to modify.
172
177
  *
173
178
  * The object has the following JSON structure and default values:
174
- {
175
- // Translation of the anonymous user avatar title.
176
- anonymous: 'anonymous'
177
- }
178
- * @type {!AvatarI18n}
179
- * @default {English/US}
180
- */
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
+ */
181
190
  i18n: {
182
191
  type: Object,
183
192
  value: () => {
@@ -187,6 +196,18 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
187
196
  },
188
197
  },
189
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
+
190
211
  /** @private */
191
212
  __imgVisible: Boolean,
192
213
 
@@ -195,11 +216,18 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
195
216
 
196
217
  /** @private */
197
218
  __abbrVisible: Boolean,
219
+
220
+ /** @private */
221
+ __tooltipNode: Object,
198
222
  };
199
223
  }
200
224
 
201
225
  static get observers() {
202
- return ['__imgOrAbbrOrNameChanged(img, abbr, name)', '__i18nChanged(i18n.*)'];
226
+ return [
227
+ '__imgOrAbbrOrNameChanged(img, abbr, name)',
228
+ '__i18nChanged(i18n.*)',
229
+ '__tooltipChanged(__tooltipNode, name, abbr)',
230
+ ];
203
231
  }
204
232
 
205
233
  /** @protected */
@@ -208,16 +236,19 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
208
236
 
209
237
  this.__updateVisibility();
210
238
 
211
- // Should set `anonymous` if name / abbr is not provided
212
- if (!this.name && !this.abbr) {
213
- this.__setTitle(this.name);
214
- }
215
-
216
239
  this.setAttribute('role', 'button');
217
240
 
218
241
  if (!this.hasAttribute('tabindex')) {
219
242
  this.setAttribute('tabindex', '0');
220
243
  }
244
+
245
+ this._tooltipController = new TooltipController(this);
246
+ this.addController(this._tooltipController);
247
+
248
+ // Should set `anonymous` if name / abbr is not provided
249
+ if (!this.name && !this.abbr) {
250
+ this.__setTooltip();
251
+ }
221
252
  }
222
253
 
223
254
  /** @private */
@@ -250,7 +281,6 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
250
281
  this.__updateVisibility();
251
282
 
252
283
  if (abbr && abbr !== this.__generatedAbbr) {
253
- this.__setTitle(name ? `${name} (${abbr})` : abbr);
254
284
  return;
255
285
  }
256
286
 
@@ -262,15 +292,40 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
262
292
  } else {
263
293
  this.abbr = undefined;
264
294
  }
295
+ }
296
+
297
+ /** @private */
298
+ __tooltipChanged(tooltipNode, name, abbr) {
299
+ if (tooltipNode) {
300
+ if (abbr && abbr !== this.__generatedAbbr) {
301
+ this.__setTooltip(name ? `${name} (${abbr})` : abbr);
302
+ } else {
303
+ this.__setTooltip(name);
304
+ }
305
+ }
306
+ }
265
307
 
266
- this.__setTitle(name);
308
+ /** @private */
309
+ __withTooltipChanged(withTooltip, oldWithTooltip) {
310
+ if (withTooltip) {
311
+ // Create and attach tooltip
312
+ const tooltipNode = document.createElement('vaadin-tooltip');
313
+ tooltipNode.setAttribute('slot', 'tooltip');
314
+ this.appendChild(tooltipNode);
315
+ this.__tooltipNode = tooltipNode;
316
+ } else if (oldWithTooltip) {
317
+ // Cleanup and detach tooltip
318
+ this.__tooltipNode.target = null;
319
+ this.__tooltipNode.remove();
320
+ this.__tooltipNode = null;
321
+ }
267
322
  }
268
323
 
269
324
  /** @private */
270
325
  __i18nChanged(i18n) {
271
326
  if (i18n.base && i18n.base.anonymous) {
272
- if (this.__oldAnonymous && this.getAttribute('title') === this.__oldAnonymous) {
273
- this.__setTitle();
327
+ if (this.__oldAnonymous && this.__tooltipNode && this.__tooltipNode.text === this.__oldAnonymous) {
328
+ this.__setTooltip();
274
329
  }
275
330
 
276
331
  this.__oldAnonymous = i18n.base.anonymous;
@@ -285,11 +340,10 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
285
340
  }
286
341
 
287
342
  /** @private */
288
- __setTitle(title) {
289
- if (title) {
290
- this.setAttribute('title', title);
291
- } else {
292
- this.setAttribute('title', this.i18n.anonymous);
343
+ __setTooltip(tooltip) {
344
+ const tooltipNode = this.__tooltipNode;
345
+ if (tooltipNode) {
346
+ tooltipNode.text = tooltip || this.i18n.anonymous;
293
347
  }
294
348
  }
295
349
 
@@ -6,11 +6,14 @@ import '@vaadin/vaadin-lumo-styles/typography.js';
6
6
  import '@vaadin/vaadin-lumo-styles/user-colors.js';
7
7
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
8
 
9
+ const globalStyle = document.createElement('style');
10
+ globalStyle.textContent = 'html { --vaadin-avatar-size: var(--lumo-size-m); }';
11
+ document.head.appendChild(globalStyle);
12
+
9
13
  registerStyles(
10
14
  'vaadin-avatar',
11
15
  css`
12
16
  :host {
13
- --vaadin-avatar-size: var(--lumo-size-m);
14
17
  color: var(--lumo-secondary-text-color);
15
18
  background-color: var(--lumo-contrast-10pct);
16
19
  border-radius: 50%;
@@ -1,2 +1,3 @@
1
+ import '@vaadin/tooltip/theme/lumo/vaadin-tooltip.js';
1
2
  import './vaadin-avatar-styles.js';
2
3
  import '../../src/vaadin-avatar.js';
@@ -3,11 +3,14 @@ import '@vaadin/vaadin-material-styles/typography.js';
3
3
  import '@vaadin/vaadin-material-styles/user-colors.js';
4
4
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
5
5
 
6
+ const globalStyle = document.createElement('style');
7
+ globalStyle.textContent = 'html { --vaadin-avatar-size: 2.25rem; }';
8
+ document.head.appendChild(globalStyle);
9
+
6
10
  registerStyles(
7
11
  'vaadin-avatar',
8
12
  css`
9
13
  :host {
10
- --vaadin-avatar-size: 2.25rem;
11
14
  color: var(--material-secondary-text-color);
12
15
  background-color: var(--material-secondary-background-color);
13
16
  border-radius: 50%;
@@ -37,6 +40,22 @@ registerStyles(
37
40
  font-size: 3em;
38
41
  font-weight: 500;
39
42
  }
43
+
44
+ :host([theme~='xlarge']) {
45
+ --vaadin-avatar-size: 3.5rem;
46
+ }
47
+
48
+ :host([theme~='large']) {
49
+ --vaadin-avatar-size: 2.75rem;
50
+ }
51
+
52
+ :host([theme~='small']) {
53
+ --vaadin-avatar-size: 1.875rem;
54
+ }
55
+
56
+ :host([theme~='xsmall']) {
57
+ --vaadin-avatar-size: 1.625rem;
58
+ }
40
59
  `,
41
60
  { moduleId: 'material-avatar' },
42
61
  );
@@ -1,2 +1,3 @@
1
+ import '@vaadin/tooltip/theme/material/vaadin-tooltip.js';
1
2
  import './vaadin-avatar-styles.js';
2
3
  import '../../src/vaadin-avatar.js';
package/web-types.json ADDED
@@ -0,0 +1,153 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/avatar",
4
+ "version": "23.3.0-alpha1",
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/custom-theme/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
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/avatar",
4
+ "version": "23.3.0-alpha1",
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/custom-theme/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
+ }