@vaadin/avatar 22.0.0-alpha9 → 22.0.0
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 +25 -24
- package/package.json +10 -10
- package/src/vaadin-avatar.d.ts +7 -4
- package/src/vaadin-avatar.js +10 -50
- package/theme/lumo/vaadin-avatar-styles.js +1 -1
- package/theme/material/vaadin-avatar-styles.js +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vaadin/avatar
|
|
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
|
-
[Live Demo ↗](https://vaadin.com/components/
|
|
6
|
-
|
|
|
7
|
-
[API documentation ↗](https://vaadin.com/components/vaadin-avatar/html-api)
|
|
5
|
+
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/avatar)
|
|
8
6
|
|
|
9
7
|
[](https://www.npmjs.com/package/@vaadin/avatar)
|
|
10
|
-
[](https://vaadin.com/directory/component/vaadinvaadin-avatar)
|
|
11
8
|
[](https://discord.gg/PHmkCKC)
|
|
12
9
|
|
|
13
10
|
```html
|
|
@@ -16,41 +13,44 @@
|
|
|
16
13
|
<vaadin-avatar abbr="SK"></vaadin-avatar>
|
|
17
14
|
```
|
|
18
15
|
|
|
19
|
-
[<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/avatar/screenshot.png" width="
|
|
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)
|
|
20
17
|
|
|
21
18
|
## Installation
|
|
22
19
|
|
|
23
|
-
Install
|
|
20
|
+
Install the component:
|
|
24
21
|
|
|
25
22
|
```sh
|
|
26
|
-
npm i @vaadin/avatar
|
|
23
|
+
npm i @vaadin/avatar
|
|
27
24
|
```
|
|
28
25
|
|
|
29
|
-
Once installed, import
|
|
26
|
+
Once installed, import the component in your application:
|
|
30
27
|
|
|
31
28
|
```js
|
|
32
|
-
import '@vaadin/avatar
|
|
29
|
+
import '@vaadin/avatar';
|
|
33
30
|
```
|
|
34
31
|
|
|
35
|
-
##
|
|
32
|
+
## Themes
|
|
36
33
|
|
|
37
|
-
Vaadin components
|
|
34
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
|
|
35
|
+
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/avatar/vaadin-avatar.js) of the package uses the Lumo theme.
|
|
38
36
|
|
|
39
|
-
To use the Material theme, import the
|
|
37
|
+
To use the Material theme, import the component from the `theme/material` folder:
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`theme/lumo/vaadin-avatar.js`
|
|
39
|
+
```js
|
|
40
|
+
import '@vaadin/avatar/theme/material/vaadin-avatar.js';
|
|
41
|
+
```
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
You can also import the Lumo version of the component explicitly:
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
```js
|
|
46
|
+
import '@vaadin/avatar/theme/lumo/vaadin-avatar.js';
|
|
47
|
+
```
|
|
50
48
|
|
|
51
|
-
-
|
|
49
|
+
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
```js
|
|
52
|
+
import '@vaadin/avatar/src/vaadin-avatar.js';
|
|
53
|
+
```
|
|
54
54
|
|
|
55
55
|
## Contributing
|
|
56
56
|
|
|
@@ -60,4 +60,5 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
|
|
|
60
60
|
|
|
61
61
|
Apache License 2.0
|
|
62
62
|
|
|
63
|
-
Vaadin collects development time
|
|
63
|
+
Vaadin collects usage statistics at development time to improve this product.
|
|
64
|
+
For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/avatar",
|
|
3
|
-
"version": "22.0.0
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"@polymer/iron-a11y-announcer": "^3.0.0",
|
|
37
37
|
"@polymer/iron-resizable-behavior": "^3.0.0",
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/component-base": "22.0.0
|
|
40
|
-
"@vaadin/item": "22.0.0
|
|
41
|
-
"@vaadin/list-box": "22.0.0
|
|
42
|
-
"@vaadin/vaadin-lumo-styles": "22.0.0
|
|
43
|
-
"@vaadin/vaadin-material-styles": "22.0.0
|
|
44
|
-
"@vaadin/vaadin-overlay": "22.0.0
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "22.0.0
|
|
39
|
+
"@vaadin/component-base": "^22.0.0",
|
|
40
|
+
"@vaadin/item": "^22.0.0",
|
|
41
|
+
"@vaadin/list-box": "^22.0.0",
|
|
42
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.0",
|
|
43
|
+
"@vaadin/vaadin-material-styles": "^22.0.0",
|
|
44
|
+
"@vaadin/vaadin-overlay": "^22.0.0",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "^22.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
49
|
-
"@vaadin/testing-helpers": "^0.3.
|
|
49
|
+
"@vaadin/testing-helpers": "^0.3.2",
|
|
50
50
|
"sinon": "^9.2.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "b668e9b1a975227fbe34beb70d1cd5b03dce2348"
|
|
53
53
|
}
|
package/src/vaadin-avatar.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
|
+
import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
|
|
7
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
9
|
|
|
9
10
|
export interface AvatarI18n {
|
|
@@ -26,15 +27,17 @@ export interface AvatarI18n {
|
|
|
26
27
|
* `abbr` | The abbreviation element
|
|
27
28
|
* `icon` | The icon element
|
|
28
29
|
*
|
|
29
|
-
* The following attributes are
|
|
30
|
+
* The following state attributes are available for styling:
|
|
30
31
|
*
|
|
31
|
-
* Attribute
|
|
32
|
-
*
|
|
32
|
+
* Attribute | Description
|
|
33
|
+
* ------------------|-------------
|
|
34
|
+
* `focus-ring` | Set when the avatar is focused using the keyboard.
|
|
35
|
+
* `focused` | Set when the avatar is focused.
|
|
33
36
|
* `has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.
|
|
34
37
|
*
|
|
35
38
|
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
36
39
|
*/
|
|
37
|
-
declare class Avatar extends ElementMixin(ThemableMixin(HTMLElement)) {
|
|
40
|
+
declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(HTMLElement))) {
|
|
38
41
|
/**
|
|
39
42
|
* The path to the image
|
|
40
43
|
*/
|
package/src/vaadin-avatar.js
CHANGED
|
@@ -3,32 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import './vaadin-avatar-icons.js';
|
|
7
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
8
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
|
+
import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
|
|
8
10
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
-
import './vaadin-avatar-icons.js';
|
|
10
|
-
|
|
11
|
-
// We consider the keyboard to be active if the window has received a keydown
|
|
12
|
-
// event since the last mousedown event.
|
|
13
|
-
let keyboardActive = false;
|
|
14
|
-
|
|
15
|
-
// Listen for top-level Tab keydown and mousedown events.
|
|
16
|
-
// Use capture phase so we detect events even if they're handled.
|
|
17
|
-
window.addEventListener(
|
|
18
|
-
'keydown',
|
|
19
|
-
(e) => {
|
|
20
|
-
keyboardActive = e.keyCode === 9;
|
|
21
|
-
},
|
|
22
|
-
true
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
window.addEventListener(
|
|
26
|
-
'mousedown',
|
|
27
|
-
() => {
|
|
28
|
-
keyboardActive = false;
|
|
29
|
-
},
|
|
30
|
-
true
|
|
31
|
-
);
|
|
32
11
|
|
|
33
12
|
/**
|
|
34
13
|
* `<vaadin-avatar>` is a Web Component providing avatar displaying functionality.
|
|
@@ -46,19 +25,22 @@ window.addEventListener(
|
|
|
46
25
|
* `abbr` | The abbreviation element
|
|
47
26
|
* `icon` | The icon element
|
|
48
27
|
*
|
|
49
|
-
* The following attributes are
|
|
28
|
+
* The following state attributes are available for styling:
|
|
50
29
|
*
|
|
51
|
-
* Attribute
|
|
52
|
-
*
|
|
30
|
+
* Attribute | Description
|
|
31
|
+
* ------------------|-------------
|
|
32
|
+
* `focus-ring` | Set when the avatar is focused using the keyboard.
|
|
33
|
+
* `focused` | Set when the avatar is focused.
|
|
53
34
|
* `has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.
|
|
54
35
|
*
|
|
55
36
|
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
56
37
|
*
|
|
57
38
|
* @extends HTMLElement
|
|
39
|
+
* @mixes FocusMixin
|
|
58
40
|
* @mixes ElementMixin
|
|
59
41
|
* @mixes ThemableMixin
|
|
60
42
|
*/
|
|
61
|
-
class Avatar extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
43
|
+
class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
62
44
|
static get template() {
|
|
63
45
|
return html`
|
|
64
46
|
<style>
|
|
@@ -236,28 +218,6 @@ class Avatar extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
236
218
|
if (!this.hasAttribute('tabindex')) {
|
|
237
219
|
this.setAttribute('tabindex', '0');
|
|
238
220
|
}
|
|
239
|
-
|
|
240
|
-
this.addEventListener('focusin', () => {
|
|
241
|
-
this.__setFocused(true);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
this.addEventListener('focusout', () => {
|
|
245
|
-
this.__setFocused(false);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/** @private */
|
|
250
|
-
__setFocused(focused) {
|
|
251
|
-
if (focused) {
|
|
252
|
-
this.setAttribute('focused', '');
|
|
253
|
-
|
|
254
|
-
if (keyboardActive) {
|
|
255
|
-
this.setAttribute('focus-ring', '');
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
this.removeAttribute('focused');
|
|
259
|
-
this.removeAttribute('focus-ring');
|
|
260
|
-
}
|
|
261
221
|
}
|
|
262
222
|
|
|
263
223
|
/** @private */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
3
2
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
4
3
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
5
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
6
5
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
7
|
|
|
8
8
|
registerStyles(
|
|
9
9
|
'vaadin-avatar',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-material-styles/color.js';
|
|
3
2
|
import '@vaadin/vaadin-material-styles/typography.js';
|
|
3
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
4
|
|
|
5
5
|
registerStyles(
|
|
6
6
|
'vaadin-avatar',
|