@vaadin/avatar 25.0.0-alpha9 → 25.0.0-beta1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/avatar",
3
- "version": "25.0.0-alpha9",
3
+ "version": "25.0.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,9 +21,6 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
- "!src/styles/*-base-styles.d.ts",
25
- "!src/styles/*-base-styles.js",
26
- "theme",
27
24
  "vaadin-*.d.ts",
28
25
  "vaadin-*.js",
29
26
  "web-types.json",
@@ -38,22 +35,22 @@
38
35
  ],
39
36
  "dependencies": {
40
37
  "@open-wc/dedupe-mixin": "^1.3.0",
41
- "@vaadin/a11y-base": "25.0.0-alpha9",
42
- "@vaadin/component-base": "25.0.0-alpha9",
43
- "@vaadin/tooltip": "25.0.0-alpha9",
44
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha9",
45
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha9",
38
+ "@vaadin/a11y-base": "25.0.0-beta1",
39
+ "@vaadin/component-base": "25.0.0-beta1",
40
+ "@vaadin/tooltip": "25.0.0-beta1",
41
+ "@vaadin/vaadin-themable-mixin": "25.0.0-beta1",
46
42
  "lit": "^3.0.0"
47
43
  },
48
44
  "devDependencies": {
49
- "@vaadin/chai-plugins": "25.0.0-alpha9",
50
- "@vaadin/test-runner-commands": "25.0.0-alpha9",
45
+ "@vaadin/chai-plugins": "25.0.0-beta1",
46
+ "@vaadin/test-runner-commands": "25.0.0-beta1",
51
47
  "@vaadin/testing-helpers": "^2.0.0",
52
- "sinon": "^18.0.0"
48
+ "@vaadin/vaadin-lumo-styles": "25.0.0-beta1",
49
+ "sinon": "^21.0.0"
53
50
  },
54
51
  "web-types": [
55
52
  "web-types.json",
56
53
  "web-types.lit.json"
57
54
  ],
58
- "gitHead": "bbe4720721e0955ffc87a79b412bee38b1f0eb1e"
55
+ "gitHead": "1d20cf54e582d1f2e209126d4586f8b4c01c50e0"
59
56
  }
@@ -3,7 +3,8 @@
3
3
  * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import '@vaadin/component-base/src/style-props.js';
6
+ import '@vaadin/component-base/src/styles/style-props.js';
7
+ import '@vaadin/component-base/src/styles/user-colors.js';
7
8
  import { css } from 'lit';
8
9
 
9
10
  export const avatarStyles = css`
@@ -12,11 +13,11 @@ export const avatarStyles = css`
12
13
  flex: none;
13
14
  border-radius: 50%;
14
15
  cursor: default;
15
- color: var(--vaadin-avatar-color, var(--vaadin-color-subtle));
16
- line-height: 0;
16
+ color: var(--vaadin-avatar-text-color, var(--vaadin-text-color-secondary));
17
17
  overflow: hidden;
18
- height: var(--vaadin-avatar-size, 32px);
19
- width: var(--vaadin-avatar-size, 32px);
18
+ --_size: var(--vaadin-avatar-size, calc(1lh + var(--vaadin-padding-xs) * 2));
19
+ height: var(--_size);
20
+ width: var(--_size);
20
21
  border: var(--vaadin-focus-ring-width) solid transparent;
21
22
  margin: calc(var(--vaadin-focus-ring-width) * -1);
22
23
  background: var(--vaadin-avatar-background, var(--vaadin-background-container-strong));
@@ -26,6 +27,17 @@ export const avatarStyles = css`
26
27
  user-select: none;
27
28
  -webkit-tap-highlight-color: transparent;
28
29
  position: relative;
30
+ font-weight: var(--vaadin-avatar-font-weight, 400);
31
+ font-size: var(--vaadin-avatar-font-size, inherit);
32
+ }
33
+
34
+ /* Overlay border on top of image and icon as well */
35
+ :host::before {
36
+ position: absolute;
37
+ content: '';
38
+ inset: 0;
39
+ border-radius: inherit;
40
+ border: var(--vaadin-avatar-border-width, 1px) solid var(--vaadin-avatar-border-color, transparent);
29
41
  }
30
42
 
31
43
  :host([role='button']) {
@@ -60,15 +72,22 @@ export const avatarStyles = css`
60
72
  }
61
73
 
62
74
  :host([has-color-index])::before {
63
- position: absolute;
64
- content: '';
65
- inset: 0;
66
- border-radius: inherit;
67
- border: 2px solid var(--vaadin-avatar-user-color);
75
+ --vaadin-avatar-border-width: 2px;
76
+ --vaadin-avatar-border-color: var(--vaadin-avatar-user-color);
68
77
  }
69
78
 
70
79
  :host([focus-ring]) {
71
80
  outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
72
81
  outline-offset: calc((var(--vaadin-focus-ring-width)) * -1);
73
82
  }
83
+
84
+ @media (forced-colors: active) {
85
+ :host {
86
+ border-color: Canvas !important;
87
+ }
88
+
89
+ [part='icon'] {
90
+ background: CanvasText !important;
91
+ }
92
+ }
74
93
  `;
@@ -48,7 +48,7 @@ export declare class AvatarMixinClass {
48
48
  * just the individual properties you want to change.
49
49
  *
50
50
  * The object has the following JSON structure and default values:
51
- * ```
51
+ * ```js
52
52
  * {
53
53
  * // Translation of the anonymous user avatar tooltip.
54
54
  * anonymous: 'anonymous'
@@ -96,7 +96,7 @@ export const AvatarMixin = (superClass) =>
96
96
  * just the individual properties you want to change.
97
97
  *
98
98
  * The object has the following JSON structure and default values:
99
- * ```
99
+ * ```js
100
100
  * {
101
101
  * // Translation of the anonymous user avatar tooltip.
102
102
  * anonymous: 'anonymous'
@@ -124,10 +124,6 @@ export const AvatarMixin = (superClass) =>
124
124
  this.setAttribute('role', 'img');
125
125
  }
126
126
 
127
- if (!this.hasAttribute('tabindex')) {
128
- this.setAttribute('tabindex', '0');
129
- }
130
-
131
127
  // Should set `anonymous` if name / abbr is not provided
132
128
  if (!this.name && !this.abbr) {
133
129
  this.__setTooltip();
@@ -137,20 +133,11 @@ export const AvatarMixin = (superClass) =>
137
133
  /** @private */
138
134
  __colorIndexChanged(index) {
139
135
  if (index != null) {
140
- const prop = `--vaadin-user-color-${index}`;
141
-
142
- // Check if custom CSS property is defined
143
- const isValid = Boolean(getComputedStyle(document.documentElement).getPropertyValue(prop));
144
-
145
- if (isValid) {
146
- this.setAttribute('has-color-index', '');
147
- this.style.setProperty('--vaadin-avatar-user-color', `var(${prop})`);
148
- } else {
149
- this.removeAttribute('has-color-index');
150
- console.warn(`The CSS property --vaadin-user-color-${index} is not defined`);
151
- }
136
+ this.setAttribute('has-color-index', '');
137
+ this.style.setProperty('--vaadin-avatar-user-color', `var(--vaadin-user-color-${index})`);
152
138
  } else {
153
139
  this.removeAttribute('has-color-index');
140
+ this.style.removeProperty('--vaadin-avatar-user-color');
154
141
  }
155
142
  }
156
143
 
@@ -198,6 +185,8 @@ export const AvatarMixin = (superClass) =>
198
185
 
199
186
  /** @private */
200
187
  __withTooltipChanged(withTooltip, oldWithTooltip) {
188
+ this.toggleAttribute('has-tooltip', withTooltip);
189
+
201
190
  if (withTooltip) {
202
191
  // Create and attach tooltip
203
192
  const tooltipNode = document.createElement('vaadin-tooltip');
@@ -32,6 +32,7 @@ export { AvatarI18n } from './vaadin-avatar-mixin.js';
32
32
  * `focus-ring` | Set when the avatar is focused using the keyboard.
33
33
  * `focused` | Set when the avatar is focused.
34
34
  * `has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.
35
+ * `has-tooltip` | Set when the element has a slotted tooltip.
35
36
  *
36
37
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
37
38
  */
@@ -12,7 +12,7 @@ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
12
12
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
13
13
  import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
14
14
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
15
- import { avatarStyles } from './styles/vaadin-avatar-core-styles.js';
15
+ import { avatarStyles } from './styles/vaadin-avatar-base-styles.js';
16
16
  import { AvatarMixin } from './vaadin-avatar-mixin.js';
17
17
 
18
18
  /**
@@ -38,6 +38,7 @@ import { AvatarMixin } from './vaadin-avatar-mixin.js';
38
38
  * `focus-ring` | Set when the avatar is focused using the keyboard.
39
39
  * `focused` | Set when the avatar is focused.
40
40
  * `has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.
41
+ * `has-tooltip` | Set when the element has a slotted tooltip.
41
42
  *
42
43
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
43
44
  *
package/vaadin-avatar.js CHANGED
@@ -1,2 +1,2 @@
1
- import './theme/lumo/vaadin-avatar.js';
1
+ import './src/vaadin-avatar.js';
2
2
  export * from './src/vaadin-avatar.js';
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/avatar",
4
- "version": "25.0.0-alpha9",
4
+ "version": "25.0.0-beta1",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
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.",
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`has-tooltip` | Set when the element has a slotted tooltip.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "img",
@@ -81,7 +81,7 @@
81
81
  "properties": [
82
82
  {
83
83
  "name": "i18n",
84
- "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
84
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
85
85
  "value": {
86
86
  "type": [
87
87
  "AvatarI18n"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/avatar",
4
- "version": "25.0.0-alpha9",
4
+ "version": "25.0.0-beta1",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
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.",
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`has-tooltip` | Set when the element has a slotted tooltip.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  {
30
30
  "name": ".i18n",
31
- "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
31
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
32
32
  "value": {
33
33
  "kind": "expression"
34
34
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2020 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import type { CSSResult } from 'lit';
7
-
8
- export const avatarStyles: CSSResult;
@@ -1,58 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2020 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { css } from 'lit';
7
-
8
- export const avatarStyles = css`
9
- :host {
10
- position: relative;
11
- display: inline-block;
12
- flex: none;
13
- border-radius: 50%;
14
- overflow: hidden;
15
- height: var(--vaadin-avatar-size, 64px);
16
- width: var(--vaadin-avatar-size, 64px);
17
- border: var(--vaadin-avatar-outline-width) solid transparent;
18
- margin: calc(var(--vaadin-avatar-outline-width) * -1);
19
- background-clip: content-box;
20
- --vaadin-avatar-outline-width: var(--vaadin-focus-ring-width, 2px);
21
- }
22
-
23
- img {
24
- height: 100%;
25
- width: 100%;
26
- object-fit: cover;
27
- }
28
-
29
- [part='icon'] {
30
- display: flex;
31
- align-items: center;
32
- justify-content: center;
33
- height: 100%;
34
- font-size: var(--vaadin-avatar-size, 64px);
35
- line-height: 1;
36
- }
37
-
38
- [part='abbr'] {
39
- font-size: 2.2em;
40
- }
41
-
42
- :host([hidden]),
43
- [hidden] {
44
- display: none !important;
45
- }
46
-
47
- :host([has-color-index]) {
48
- background-color: var(--vaadin-avatar-user-color);
49
- }
50
-
51
- :host([has-color-index])::before {
52
- position: absolute;
53
- content: '';
54
- inset: 0;
55
- border-radius: inherit;
56
- box-shadow: inset 0 0 0 2px var(--vaadin-avatar-user-color);
57
- }
58
- `;
@@ -1,7 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/color.js';
2
- import '@vaadin/vaadin-lumo-styles/sizing.js';
3
- import '@vaadin/vaadin-lumo-styles/spacing.js';
4
- import '@vaadin/vaadin-lumo-styles/style.js';
5
- import '@vaadin/vaadin-lumo-styles/font-icons.js';
6
- import '@vaadin/vaadin-lumo-styles/typography.js';
7
- import '@vaadin/vaadin-lumo-styles/user-colors.js';
@@ -1,83 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/color.js';
2
- import '@vaadin/vaadin-lumo-styles/sizing.js';
3
- import '@vaadin/vaadin-lumo-styles/spacing.js';
4
- import '@vaadin/vaadin-lumo-styles/style.js';
5
- import '@vaadin/vaadin-lumo-styles/font-icons.js';
6
- import '@vaadin/vaadin-lumo-styles/typography.js';
7
- import '@vaadin/vaadin-lumo-styles/user-colors.js';
8
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
-
10
- const globalStyle = document.createElement('style');
11
- globalStyle.textContent = 'html { --vaadin-avatar-size: var(--lumo-size-m); }';
12
- document.head.appendChild(globalStyle);
13
-
14
- registerStyles(
15
- 'vaadin-avatar',
16
- css`
17
- :host {
18
- color: var(--lumo-secondary-text-color);
19
- background-color: var(--lumo-contrast-10pct);
20
- border-radius: 50%;
21
- outline: none;
22
- cursor: default;
23
- user-select: none;
24
- -webkit-tap-highlight-color: transparent;
25
- -webkit-font-smoothing: antialiased;
26
- -moz-osx-font-smoothing: grayscale;
27
- }
28
-
29
- :host([has-color-index]) {
30
- color: var(--lumo-base-color);
31
- }
32
-
33
- :host([focus-ring]) {
34
- border-color: var(--vaadin-focus-ring-color, var(--lumo-primary-color-50pct));
35
- }
36
-
37
- [part='icon']::before {
38
- content: var(--lumo-icons-user);
39
- font-family: lumo-icons;
40
- font-size: 0.9em;
41
- }
42
-
43
- [part='abbr'] {
44
- font-family: var(--lumo-font-family);
45
- font-size: 2.4375em;
46
- font-weight: 500;
47
- fill: currentColor;
48
- }
49
-
50
- :host([theme~='xlarge']) [part='abbr'] {
51
- font-size: 2.5em;
52
- }
53
-
54
- :host([theme~='large']) [part='abbr'] {
55
- font-size: 2.375em;
56
- }
57
-
58
- :host([theme~='small']) [part='abbr'] {
59
- font-size: 2.75em;
60
- }
61
-
62
- :host([theme~='xsmall']) [part='abbr'] {
63
- font-size: 3em;
64
- }
65
-
66
- :host([theme~='xlarge']) {
67
- --vaadin-avatar-size: var(--lumo-size-xl);
68
- }
69
-
70
- :host([theme~='large']) {
71
- --vaadin-avatar-size: var(--lumo-size-l);
72
- }
73
-
74
- :host([theme~='small']) {
75
- --vaadin-avatar-size: var(--lumo-size-s);
76
- }
77
-
78
- :host([theme~='xsmall']) {
79
- --vaadin-avatar-size: var(--lumo-size-xs);
80
- }
81
- `,
82
- { moduleId: 'lumo-avatar' },
83
- );
@@ -1,3 +0,0 @@
1
- import '@vaadin/tooltip/theme/lumo/vaadin-tooltip.js';
2
- import './vaadin-avatar-styles.js';
3
- import '../../src/vaadin-avatar.js';
@@ -1,3 +0,0 @@
1
- import '@vaadin/tooltip/theme/lumo/vaadin-tooltip.js';
2
- import './vaadin-avatar-styles.js';
3
- import '../../src/vaadin-avatar.js';