@vaadin/avatar 23.2.0-dev.8a7678b70 → 23.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.2.1",
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,22 @@
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.2.1",
41
+ "@vaadin/item": "~23.2.1",
42
+ "@vaadin/list-box": "~23.2.1",
43
+ "@vaadin/vaadin-lumo-styles": "~23.2.1",
44
+ "@vaadin/vaadin-material-styles": "~23.2.1",
45
+ "@vaadin/vaadin-overlay": "~23.2.1",
46
+ "@vaadin/vaadin-themable-mixin": "~23.2.1"
45
47
  },
46
48
  "devDependencies": {
47
49
  "@esm-bundle/chai": "^4.3.4",
48
50
  "@vaadin/testing-helpers": "^0.3.2",
49
51
  "sinon": "^13.0.2"
50
52
  },
51
- "gitHead": "85b403f96d8282f262322b56c0ff4289f843d02a"
53
+ "web-types": [
54
+ "web-types.json",
55
+ "web-types.lit.json"
56
+ ],
57
+ "gitHead": "a6c314f6927bfd3309fc735eae6c6dc72ab8367a"
52
58
  }
@@ -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);
@@ -35,7 +35,7 @@ export interface AvatarI18n {
35
35
  * `focused` | Set when the avatar is focused.
36
36
  * `has-color-index` | Set when the avatar has `colorIndex` and the corresponding custom CSS property exists.
37
37
  *
38
- * 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.
39
39
  */
40
40
  declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(HTMLElement))) {
41
41
  /**
@@ -57,6 +57,7 @@ declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(HTMLElement))
57
57
 
58
58
  /**
59
59
  * Color index used for avatar background.
60
+ * @attr {number} color-index
60
61
  */
61
62
  colorIndex: number | null | undefined;
62
63
 
@@ -66,10 +67,13 @@ declare class Avatar extends FocusMixin(ElementMixin(ThemableMixin(HTMLElement))
66
67
  * _i18n_ object or just the property you want to modify.
67
68
  *
68
69
  * The object has the following JSON structure and default values:
69
- * {
70
- * // Translation of the anonymous user avatar title.
71
- * anonymous: 'anonymous'
72
- * }
70
+ *
71
+ * ```
72
+ * {
73
+ * // Translation of the anonymous user avatar title.
74
+ * anonymous: 'anonymous'
75
+ * }
76
+ * ```
73
77
  */
74
78
  i18n: AvatarI18n;
75
79
  }
@@ -33,7 +33,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
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
35
  *
36
- * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
36
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
37
37
  *
38
38
  * @extends HTMLElement
39
39
  * @mixes FocusMixin
@@ -49,13 +49,12 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
49
49
  flex: none;
50
50
  border-radius: 50%;
51
51
  overflow: hidden;
52
- height: var(--vaadin-avatar-size);
53
- width: var(--vaadin-avatar-size);
52
+ height: var(--vaadin-avatar-size, 64px);
53
+ width: var(--vaadin-avatar-size, 64px);
54
54
  border: var(--vaadin-avatar-outline-width) solid transparent;
55
55
  margin: calc(var(--vaadin-avatar-outline-width) * -1);
56
56
  background-clip: content-box;
57
57
  --vaadin-avatar-outline-width: 2px;
58
- --vaadin-avatar-size: 64px;
59
58
  }
60
59
 
61
60
  img {
@@ -159,6 +158,7 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
159
158
 
160
159
  /**
161
160
  * Color index used for avatar background.
161
+ * @attr {number} color-index
162
162
  */
163
163
  colorIndex: {
164
164
  type: Number,
@@ -171,13 +171,17 @@ class Avatar extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
171
171
  * _i18n_ object or just the property you want to modify.
172
172
  *
173
173
  * 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
- */
174
+ *
175
+ * ```
176
+ * {
177
+ * // Translation of the anonymous user avatar title.
178
+ * anonymous: 'anonymous'
179
+ * }
180
+ * ```
181
+ *
182
+ * @type {!AvatarI18n}
183
+ * @default {English/US}
184
+ */
181
185
  i18n: {
182
186
  type: Object,
183
187
  value: () => {
@@ -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%;
@@ -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
  );
package/web-types.json ADDED
@@ -0,0 +1,131 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/avatar",
4
+ "version": "23.2.1",
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 title 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": "theme",
59
+ "description": "The theme variants to apply to the component.",
60
+ "value": {
61
+ "type": [
62
+ "string",
63
+ "null",
64
+ "undefined"
65
+ ]
66
+ }
67
+ }
68
+ ],
69
+ "js": {
70
+ "properties": [
71
+ {
72
+ "name": "img",
73
+ "description": "The path to the image",
74
+ "value": {
75
+ "type": [
76
+ "string",
77
+ "null",
78
+ "undefined"
79
+ ]
80
+ }
81
+ },
82
+ {
83
+ "name": "abbr",
84
+ "description": "A shortened form of name that is displayed\nin the avatar when `img` is not provided.",
85
+ "value": {
86
+ "type": [
87
+ "string",
88
+ "null",
89
+ "undefined"
90
+ ]
91
+ }
92
+ },
93
+ {
94
+ "name": "name",
95
+ "description": "Full name of the user\nused for the title of the avatar.",
96
+ "value": {
97
+ "type": [
98
+ "string",
99
+ "null",
100
+ "undefined"
101
+ ]
102
+ }
103
+ },
104
+ {
105
+ "name": "colorIndex",
106
+ "description": "Color index used for avatar background.",
107
+ "value": {
108
+ "type": [
109
+ "number",
110
+ "null",
111
+ "undefined"
112
+ ]
113
+ }
114
+ },
115
+ {
116
+ "name": "i18n",
117
+ "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 title.\n anonymous: 'anonymous'\n}\n```",
118
+ "value": {
119
+ "type": [
120
+ "AvatarI18n"
121
+ ]
122
+ }
123
+ }
124
+ ],
125
+ "events": []
126
+ }
127
+ }
128
+ ]
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/avatar",
4
+ "version": "23.2.1",
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": ".img",
24
+ "description": "The path to the image",
25
+ "value": {
26
+ "kind": "expression"
27
+ }
28
+ },
29
+ {
30
+ "name": ".abbr",
31
+ "description": "A shortened form of name that is displayed\nin the avatar when `img` is not provided.",
32
+ "value": {
33
+ "kind": "expression"
34
+ }
35
+ },
36
+ {
37
+ "name": ".name",
38
+ "description": "Full name of the user\nused for the title of the avatar.",
39
+ "value": {
40
+ "kind": "expression"
41
+ }
42
+ },
43
+ {
44
+ "name": ".colorIndex",
45
+ "description": "Color index used for avatar background.",
46
+ "value": {
47
+ "kind": "expression"
48
+ }
49
+ },
50
+ {
51
+ "name": ".i18n",
52
+ "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 title.\n anonymous: 'anonymous'\n}\n```",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ }
57
+ ]
58
+ }
59
+ ]
60
+ }
61
+ }
62
+ }