@vaadin/avatar 24.8.4 → 25.0.0-alpha10
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 +0 -23
- package/package.json +13 -14
- package/src/styles/vaadin-avatar-base-styles.d.ts +8 -0
- package/src/styles/vaadin-avatar-base-styles.js +74 -0
- package/src/styles/vaadin-avatar-core-styles.d.ts +8 -0
- package/src/{vaadin-avatar-styles.js → styles/vaadin-avatar-core-styles.js} +11 -13
- package/src/vaadin-avatar.d.ts +1 -2
- package/src/vaadin-avatar.js +29 -30
- package/theme/lumo/vaadin-avatar-styles.d.ts +1 -0
- package/theme/lumo/vaadin-avatar-styles.js +6 -3
- package/web-types.json +1 -1
- package/web-types.lit.json +1 -1
- package/src/vaadin-avatar-icons.js +0 -19
- package/src/vaadin-lit-avatar.js +0 -82
- package/theme/lumo/vaadin-lit-avatar.d.ts +0 -3
- package/theme/lumo/vaadin-lit-avatar.js +0 -3
- package/theme/material/vaadin-avatar-styles.d.ts +0 -3
- package/theme/material/vaadin-avatar-styles.js +0 -61
- package/theme/material/vaadin-avatar.d.ts +0 -3
- package/theme/material/vaadin-avatar.js +0 -3
- package/theme/material/vaadin-lit-avatar.d.ts +0 -3
- package/theme/material/vaadin-lit-avatar.js +0 -3
- package/vaadin-lit-avatar.d.ts +0 -1
- package/vaadin-lit-avatar.js +0 -2
package/README.md
CHANGED
|
@@ -28,29 +28,6 @@ Once installed, import the component in your application:
|
|
|
28
28
|
import '@vaadin/avatar';
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
## Themes
|
|
32
|
-
|
|
33
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
|
|
34
|
-
The [main entrypoint](https://github.com/vaadin/web-components/blob/main/packages/avatar/vaadin-avatar.js) of the package uses the Lumo theme.
|
|
35
|
-
|
|
36
|
-
To use the Material theme, import the component from the `theme/material` folder:
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
import '@vaadin/avatar/theme/material/vaadin-avatar.js';
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
You can also import the Lumo version of the component explicitly:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
import '@vaadin/avatar/theme/lumo/vaadin-avatar.js';
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
import '@vaadin/avatar/src/vaadin-avatar.js';
|
|
52
|
-
```
|
|
53
|
-
|
|
54
31
|
## Contributing
|
|
55
32
|
|
|
56
33
|
Read the [contributing guide](https://vaadin.com/docs/latest/contributing) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/avatar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.0-alpha10",
|
|
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/styles/*-base-styles.d.ts",
|
|
25
|
+
"!src/styles/*-base-styles.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -32,29 +34,26 @@
|
|
|
32
34
|
"Avatar",
|
|
33
35
|
"vaadin-avatar",
|
|
34
36
|
"web-components",
|
|
35
|
-
"web-component"
|
|
36
|
-
"polymer"
|
|
37
|
+
"web-component"
|
|
37
38
|
],
|
|
38
39
|
"dependencies": {
|
|
39
40
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@
|
|
41
|
-
"@vaadin/
|
|
42
|
-
"@vaadin/
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/vaadin-
|
|
45
|
-
"@vaadin/vaadin-material-styles": "~24.8.4",
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "~24.8.4",
|
|
41
|
+
"@vaadin/a11y-base": "25.0.0-alpha10",
|
|
42
|
+
"@vaadin/component-base": "25.0.0-alpha10",
|
|
43
|
+
"@vaadin/tooltip": "25.0.0-alpha10",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha10",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha10",
|
|
47
46
|
"lit": "^3.0.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@vaadin/chai-plugins": "
|
|
51
|
-
"@vaadin/test-runner-commands": "
|
|
52
|
-
"@vaadin/testing-helpers": "^
|
|
49
|
+
"@vaadin/chai-plugins": "25.0.0-alpha10",
|
|
50
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha10",
|
|
51
|
+
"@vaadin/testing-helpers": "^2.0.0",
|
|
53
52
|
"sinon": "^18.0.0"
|
|
54
53
|
},
|
|
55
54
|
"web-types": [
|
|
56
55
|
"web-types.json",
|
|
57
56
|
"web-types.lit.json"
|
|
58
57
|
],
|
|
59
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6cc6c94079e805fa5b2f0af4dbf3b2a7485e57d0"
|
|
60
59
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/component-base/src/style-props.js';
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
|
|
9
|
+
export const avatarStyles = css`
|
|
10
|
+
:host {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
flex: none;
|
|
13
|
+
border-radius: 50%;
|
|
14
|
+
cursor: default;
|
|
15
|
+
color: var(--vaadin-avatar-color, var(--vaadin-color-subtle));
|
|
16
|
+
line-height: 0;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
height: var(--vaadin-avatar-size, 32px);
|
|
19
|
+
width: var(--vaadin-avatar-size, 32px);
|
|
20
|
+
border: var(--vaadin-focus-ring-width) solid transparent;
|
|
21
|
+
margin: calc(var(--vaadin-focus-ring-width) * -1);
|
|
22
|
+
background: var(--vaadin-avatar-background, var(--vaadin-background-container-strong));
|
|
23
|
+
background-clip: content-box;
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
-webkit-user-select: none;
|
|
26
|
+
user-select: none;
|
|
27
|
+
-webkit-tap-highlight-color: transparent;
|
|
28
|
+
position: relative;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([role='button']) {
|
|
32
|
+
cursor: var(--vaadin-clickable-cursor);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
img {
|
|
36
|
+
height: 100%;
|
|
37
|
+
width: 100%;
|
|
38
|
+
object-fit: cover;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[part='icon'] {
|
|
42
|
+
height: 100%;
|
|
43
|
+
mask: var(--_vaadin-icon-user) no-repeat center / 74%;
|
|
44
|
+
background: currentColor;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[part='abbr'] {
|
|
48
|
+
font-size: 2.75em;
|
|
49
|
+
fill: currentColor;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:host([hidden]),
|
|
53
|
+
[hidden] {
|
|
54
|
+
display: none !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([has-color-index]) {
|
|
58
|
+
background-color: var(--vaadin-avatar-user-color);
|
|
59
|
+
color: oklch(from var(--vaadin-avatar-user-color) clamp(0, (0.62 - l) * 1000, 1) 0 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
: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);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:host([focus-ring]) {
|
|
71
|
+
outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
|
|
72
|
+
outline-offset: calc((var(--vaadin-focus-ring-width)) * -1);
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020 - 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 { css } from '
|
|
6
|
+
import { css } from 'lit';
|
|
7
7
|
|
|
8
8
|
export const avatarStyles = css`
|
|
9
9
|
:host {
|
|
10
|
+
position: relative;
|
|
10
11
|
display: inline-block;
|
|
11
12
|
flex: none;
|
|
12
13
|
border-radius: 50%;
|
|
@@ -26,27 +27,24 @@ export const avatarStyles = css`
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
[part='icon'] {
|
|
29
|
-
|
|
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;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
[part='abbr'] {
|
|
33
39
|
font-size: 2.2em;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
[
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
:host([hidden]) {
|
|
41
|
-
display: none !important;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
svg[hidden] {
|
|
42
|
+
:host([hidden]),
|
|
43
|
+
[hidden] {
|
|
45
44
|
display: none !important;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
:host([has-color-index]) {
|
|
49
|
-
position: relative;
|
|
50
48
|
background-color: var(--vaadin-avatar-user-color);
|
|
51
49
|
}
|
|
52
50
|
|
package/src/vaadin-avatar.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright (c) 2020 - 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 { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
6
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
8
7
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
8
|
import { AvatarMixin } from './vaadin-avatar-mixin.js';
|
|
@@ -36,7 +35,7 @@ export { AvatarI18n } from './vaadin-avatar-mixin.js';
|
|
|
36
35
|
*
|
|
37
36
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
38
37
|
*/
|
|
39
|
-
declare class Avatar extends AvatarMixin(ElementMixin(ThemableMixin(
|
|
38
|
+
declare class Avatar extends AvatarMixin(ElementMixin(ThemableMixin(HTMLElement))) {}
|
|
40
39
|
|
|
41
40
|
declare global {
|
|
42
41
|
interface HTMLElementTagNameMap {
|
package/src/vaadin-avatar.js
CHANGED
|
@@ -4,17 +4,16 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/tooltip/src/vaadin-tooltip.js';
|
|
7
|
-
import '
|
|
8
|
-
import {
|
|
9
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
|
+
import { html, LitElement } from 'lit';
|
|
8
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
9
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
10
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
12
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
13
|
-
import {
|
|
13
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
14
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
|
+
import { avatarStyles } from './styles/vaadin-avatar-core-styles.js';
|
|
14
16
|
import { AvatarMixin } from './vaadin-avatar-mixin.js';
|
|
15
|
-
import { avatarStyles } from './vaadin-avatar-styles.js';
|
|
16
|
-
|
|
17
|
-
registerStyles('vaadin-avatar', avatarStyles, { moduleId: 'vaadin-avatar-styles' });
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* `<vaadin-avatar>` is a Web Component providing avatar displaying functionality.
|
|
@@ -45,49 +44,49 @@ registerStyles('vaadin-avatar', avatarStyles, { moduleId: 'vaadin-avatar-styles'
|
|
|
45
44
|
* @customElement
|
|
46
45
|
* @extends HTMLElement
|
|
47
46
|
* @mixes AvatarMixin
|
|
48
|
-
* @mixes ControllerMixin
|
|
49
47
|
* @mixes ElementMixin
|
|
50
48
|
* @mixes ThemableMixin
|
|
51
49
|
*/
|
|
52
|
-
class Avatar extends AvatarMixin(ElementMixin(ThemableMixin(
|
|
53
|
-
static get
|
|
50
|
+
class Avatar extends AvatarMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
51
|
+
static get is() {
|
|
52
|
+
return 'vaadin-avatar';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static get styles() {
|
|
56
|
+
return avatarStyles;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static get lumoInjector() {
|
|
60
|
+
return {
|
|
61
|
+
includeBaseStyles: true,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** @protected */
|
|
66
|
+
render() {
|
|
54
67
|
return html`
|
|
55
68
|
<img
|
|
56
|
-
hidden
|
|
57
|
-
src
|
|
69
|
+
?hidden="${!this.__imgVisible}"
|
|
70
|
+
src="${ifDefined(this.img)}"
|
|
58
71
|
aria-hidden="true"
|
|
59
|
-
|
|
72
|
+
@error="${this.__onImageLoadError}"
|
|
60
73
|
draggable="false"
|
|
61
74
|
/>
|
|
62
|
-
<
|
|
63
|
-
part="icon"
|
|
64
|
-
hidden$="[[!__iconVisible]]"
|
|
65
|
-
id="avatar-icon"
|
|
66
|
-
viewBox="-50 -50 100 100"
|
|
67
|
-
preserveAspectRatio="xMidYMid meet"
|
|
68
|
-
aria-hidden="true"
|
|
69
|
-
>
|
|
70
|
-
<text dy=".35em" text-anchor="middle"></text>
|
|
71
|
-
</svg>
|
|
75
|
+
<div part="icon" ?hidden="${!this.__iconVisible}" aria-hidden="true"></div>
|
|
72
76
|
<svg
|
|
73
77
|
part="abbr"
|
|
74
|
-
hidden
|
|
75
|
-
id="avatar-abbr"
|
|
78
|
+
?hidden="${!this.__abbrVisible}"
|
|
76
79
|
viewBox="-50 -50 100 100"
|
|
77
80
|
preserveAspectRatio="xMidYMid meet"
|
|
78
81
|
aria-hidden="true"
|
|
79
82
|
>
|
|
80
|
-
<text dy=".35em" text-anchor="middle"
|
|
83
|
+
<text dy=".35em" text-anchor="middle">${this.abbr}</text>
|
|
81
84
|
</svg>
|
|
82
85
|
|
|
83
86
|
<slot name="tooltip"></slot>
|
|
84
87
|
`;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
static get is() {
|
|
88
|
-
return 'vaadin-avatar';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
90
|
/** @protected */
|
|
92
91
|
ready() {
|
|
93
92
|
super.ready();
|
|
@@ -2,5 +2,6 @@ import '@vaadin/vaadin-lumo-styles/color.js';
|
|
|
2
2
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
3
3
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
4
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
5
|
+
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
5
6
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
7
|
import '@vaadin/vaadin-lumo-styles/user-colors.js';
|
|
@@ -2,6 +2,7 @@ import '@vaadin/vaadin-lumo-styles/color.js';
|
|
|
2
2
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
3
3
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
4
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
5
|
+
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
5
6
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
7
|
import '@vaadin/vaadin-lumo-styles/user-colors.js';
|
|
7
8
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
@@ -33,15 +34,17 @@ registerStyles(
|
|
|
33
34
|
border-color: var(--vaadin-focus-ring-color, var(--lumo-primary-color-50pct));
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
[part='icon']
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
[part='icon']::before {
|
|
38
|
+
content: var(--lumo-icons-user);
|
|
39
|
+
font-family: lumo-icons;
|
|
40
|
+
font-size: 0.9em;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
[part='abbr'] {
|
|
42
44
|
font-family: var(--lumo-font-family);
|
|
43
45
|
font-size: 2.4375em;
|
|
44
46
|
font-weight: 500;
|
|
47
|
+
fill: currentColor;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
:host([theme~='xlarge']) [part='abbr'] {
|
package/web-types.json
CHANGED
package/web-types.lit.json
CHANGED
|
@@ -1,19 +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
|
-
const template = document.createElement('template');
|
|
7
|
-
|
|
8
|
-
template.innerHTML = `
|
|
9
|
-
<style>
|
|
10
|
-
@font-face {
|
|
11
|
-
font-family: 'vaadin-avatar-icons';
|
|
12
|
-
src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAQAAAsAAAAABnwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADsAAABUIIslek9TLzIAAAFEAAAAQwAAAFZAIUmEY21hcAAAAYgAAABLAAABcOspwa1nbHlmAAAB1AAAAEUAAABMYO4o1WhlYWQAAAIcAAAALgAAADYYaAmGaGhlYQAAAkwAAAAdAAAAJAZsA1VobXR4AAACbAAAAAgAAAAIA+gAAGxvY2EAAAJ0AAAABgAAAAYAJgAAbWF4cAAAAnwAAAAeAAAAIAEOACFuYW1lAAACnAAAAUIAAAKavFDYrHBvc3QAAAPgAAAAHQAAAC52hGZ4eJxjYGRgYOBiMGCwY2BycfMJYeDLSSzJY5BiYGGAAJA8MpsxJzM9kYEDxgPKsYBpDiBmg4gCACY7BUgAeJxjYGT8wjiBgZWBgamKaQ8DA0MPhGZ8wGDIyAQUZWBlZsAKAtJcUxgcXjG+YmQO+p/FEMUcxDANKMwIkgMADiUMJQB4nGNgYGBlYGBgBmIdIGZhYGAMYWBkAAE/oCgjWJyZgQsszsKgBFbDAhJ/xfj/P4wE8lnAJAMjG8Mo4AGTMlAeOKwgmIERADU0CX0AeJxjYGIAAmYJpkgGHgYRBgZGJT1GEztGIzlGET5GKEuU8YuSpZKSpQuI+LfLv21emz9jHJQPJP7dsUywsEiwBACG8g9CAAAAeJxjYGRgYADicIOnh+P5bb4ycDO/AIow3JZ4rIJMM0swRQIpDgYmEA8AKwgJOwAAeJxjYGRgYA76nwUkXzAAAbMEAyMDKmACAE2GAskAAAAAAAAAA+gAAAAAAAAAJgAAeJxjYGRgYGBiEAViBjCLgYELCBkY/oP5DAAKuwEwAAB4nI2Qu07DMBSG//SGaCWEhMSAGDx1QU0vYyemdmDrUDEhuamTpkriyHEj9RF4B56Bh2Bg5mmY+8d4Qh3qo9jf+c45thQAt/hGgGYFuHN7s1q4YvbHbdKD5w555LmLAZ499+hfPPfxhDfPA/p33hB0rmmG+PDcwg2+PLfpfzx3yL+eu7gPHj33MAxmnvtYB6+eB/SftZTbtBjJWlppRmmki2qlkkMmzZnKGbVWpkp1Iabh5Ex1qQplpFVbsTmKqk5m1sYiNjoXC11YlWValEbvVWTDnbXlfDyOvQ8jnaOGZGyRouCfky63/AyzFBE0fYUVFBIckLnKZTOXda15s+GZulxgihCTC2eXnC3cfFNV7BfY4Mi9eT3BjNYiZh6zRyMnLdxs050xNE3panuaiD7Ezk2VmGPMiP/1h+71/ATcWYAhAAB4nGNgYoAALgbsgImRiZGZgaW0OLWIgQEACl4B2QAAAA==) format('woff');
|
|
13
|
-
font-weight: normal;
|
|
14
|
-
font-style: normal;
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
document.head.appendChild(template.content);
|
package/src/vaadin-lit-avatar.js
DELETED
|
@@ -1,82 +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 '@vaadin/tooltip/src/vaadin-lit-tooltip.js';
|
|
7
|
-
import './vaadin-avatar-icons.js';
|
|
8
|
-
import { html, LitElement } from 'lit';
|
|
9
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
|
-
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
13
|
-
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
14
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
|
-
import { AvatarMixin } from './vaadin-avatar-mixin.js';
|
|
16
|
-
import { avatarStyles } from './vaadin-avatar-styles.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* LitElement based version of `<vaadin-avatar>` web component.
|
|
20
|
-
*
|
|
21
|
-
* ## Disclaimer
|
|
22
|
-
*
|
|
23
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
24
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
25
|
-
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
26
|
-
*/
|
|
27
|
-
class Avatar extends AvatarMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
28
|
-
static get is() {
|
|
29
|
-
return 'vaadin-avatar';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static get styles() {
|
|
33
|
-
return avatarStyles;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @protected */
|
|
37
|
-
ready() {
|
|
38
|
-
super.ready();
|
|
39
|
-
|
|
40
|
-
this._tooltipController = new TooltipController(this);
|
|
41
|
-
this.addController(this._tooltipController);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** @protected */
|
|
45
|
-
render() {
|
|
46
|
-
return html`
|
|
47
|
-
<img
|
|
48
|
-
?hidden="${!this.__imgVisible}"
|
|
49
|
-
src="${ifDefined(this.img)}"
|
|
50
|
-
aria-hidden="true"
|
|
51
|
-
@error="${this.__onImageLoadError}"
|
|
52
|
-
draggable="false"
|
|
53
|
-
/>
|
|
54
|
-
<svg
|
|
55
|
-
part="icon"
|
|
56
|
-
?hidden="${!this.__iconVisible}"
|
|
57
|
-
id="avatar-icon"
|
|
58
|
-
viewBox="-50 -50 100 100"
|
|
59
|
-
preserveAspectRatio="xMidYMid meet"
|
|
60
|
-
aria-hidden="true"
|
|
61
|
-
>
|
|
62
|
-
<text dy=".35em" text-anchor="middle"></text>
|
|
63
|
-
</svg>
|
|
64
|
-
<svg
|
|
65
|
-
part="abbr"
|
|
66
|
-
?hidden="${!this.__abbrVisible}"
|
|
67
|
-
id="avatar-abbr"
|
|
68
|
-
viewBox="-50 -50 100 100"
|
|
69
|
-
preserveAspectRatio="xMidYMid meet"
|
|
70
|
-
aria-hidden="true"
|
|
71
|
-
>
|
|
72
|
-
<text dy=".35em" text-anchor="middle">${this.abbr}</text>
|
|
73
|
-
</svg>
|
|
74
|
-
|
|
75
|
-
<slot name="tooltip"></slot>
|
|
76
|
-
`;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
defineCustomElement(Avatar);
|
|
81
|
-
|
|
82
|
-
export { Avatar };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import '@vaadin/vaadin-material-styles/color.js';
|
|
2
|
-
import '@vaadin/vaadin-material-styles/typography.js';
|
|
3
|
-
import '@vaadin/vaadin-material-styles/user-colors.js';
|
|
4
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
5
|
-
|
|
6
|
-
const globalStyle = document.createElement('style');
|
|
7
|
-
globalStyle.textContent = 'html { --vaadin-avatar-size: 2.25rem; }';
|
|
8
|
-
document.head.appendChild(globalStyle);
|
|
9
|
-
|
|
10
|
-
registerStyles(
|
|
11
|
-
'vaadin-avatar',
|
|
12
|
-
css`
|
|
13
|
-
:host {
|
|
14
|
-
color: var(--material-secondary-text-color);
|
|
15
|
-
background-color: var(--material-secondary-background-color);
|
|
16
|
-
border-radius: 50%;
|
|
17
|
-
cursor: default;
|
|
18
|
-
outline: none;
|
|
19
|
-
user-select: none;
|
|
20
|
-
-webkit-tap-highlight-color: transparent;
|
|
21
|
-
-webkit-font-smoothing: antialiased;
|
|
22
|
-
-moz-osx-font-smoothing: grayscale;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
:host([has-color-index]) {
|
|
26
|
-
color: var(--material-primary-contrast-color);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
:host([focus-ring]) {
|
|
30
|
-
border-color: var(--material-primary-color);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
[part='icon'],
|
|
34
|
-
[part='abbr'] {
|
|
35
|
-
fill: currentColor;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
[part='abbr'] {
|
|
39
|
-
font-family: var(--material-font-family);
|
|
40
|
-
font-size: 3em;
|
|
41
|
-
font-weight: 500;
|
|
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
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
{ moduleId: 'material-avatar' },
|
|
61
|
-
);
|
package/vaadin-lit-avatar.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/vaadin-avatar.js';
|
package/vaadin-lit-avatar.js
DELETED