@momentum-design/components 0.15.5 → 0.15.6
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/dist/browser/index.js +72 -54
- package/dist/browser/index.js.map +4 -4
- package/dist/components/avatar/avatar.component.d.ts +2 -65
- package/dist/components/avatar/avatar.component.js +5 -50
- package/dist/components/avatar/avatar.constants.d.ts +11 -2
- package/dist/components/avatar/avatar.constants.js +11 -3
- package/dist/components/avatar/avatar.styles.js +14 -14
- package/dist/components/avatar/avatar.types.d.ts +1 -2
- package/dist/components/avatar/avatar.utils.d.ts +3 -1
- package/dist/components/avatar/avatar.utils.js +29 -16
- package/dist/components/avatarbutton/avatarbutton.component.d.ts +25 -0
- package/dist/components/avatarbutton/avatarbutton.component.js +70 -0
- package/dist/components/avatarbutton/avatarbutton.constants.d.ts +2 -0
- package/dist/components/avatarbutton/avatarbutton.constants.js +3 -0
- package/dist/components/avatarbutton/avatarbutton.styles.d.ts +2 -0
- package/dist/components/avatarbutton/avatarbutton.styles.js +11 -0
- package/dist/components/avatarbutton/index.d.ts +8 -0
- package/dist/components/avatarbutton/index.js +5 -0
- package/dist/custom-elements.json +1074 -199
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/avatarbutton/index.d.ts +13 -0
- package/dist/react/avatarbutton/index.js +22 -0
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/utils/mixins/AvatarComponentMixin.d.ts +15 -0
- package/dist/utils/mixins/AvatarComponentMixin.js +66 -0
- package/dist/utils/mixins/DisabledMixin.d.ts +1 -2
- package/dist/utils/mixins/TabIndexMixin.d.ts +1 -2
- package/dist/utils/mixins/index.types.d.ts +1 -0
- package/dist/utils/mixins/index.types.js +1 -0
- package/package.json +1 -1
@@ -1,9 +1,7 @@
|
|
1
1
|
import { CSSResult } from 'lit';
|
2
2
|
import type { PropertyValues, TemplateResult } from 'lit';
|
3
3
|
import { Component } from '../../models';
|
4
|
-
|
5
|
-
import type { PresenceType } from '../presence/presence.types';
|
6
|
-
import type { AvatarSize } from './avatar.types';
|
4
|
+
declare const Avatar_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/AvatarComponentMixin").AvatarComponentMixinInterface> & typeof Component;
|
7
5
|
/**
|
8
6
|
* The `mdc-avatar` component is used to represent a person or a space.
|
9
7
|
* An avatar can be an icon, initials, counter and photo.
|
@@ -39,68 +37,7 @@ import type { AvatarSize } from './avatar.types';
|
|
39
37
|
* @cssproperty --mdc-avatar-loading-overlay-background-color -
|
40
38
|
* Allows customization of the loading overlay background color.
|
41
39
|
*/
|
42
|
-
declare class Avatar extends
|
43
|
-
/**
|
44
|
-
* The src is the url which will be used to display the avatar.
|
45
|
-
* When the src is loading, we will display the initials as a placeholder.
|
46
|
-
*/
|
47
|
-
src?: string;
|
48
|
-
/**
|
49
|
-
* The initials to be displayed for the avatar.
|
50
|
-
*/
|
51
|
-
initials?: string;
|
52
|
-
/**
|
53
|
-
* The presence is the status which can be used to display the
|
54
|
-
* activity state of a user or a space within an avatar component.
|
55
|
-
*
|
56
|
-
* Acceptable values include:
|
57
|
-
* - `active`
|
58
|
-
* - `away`
|
59
|
-
* - `away-calling`
|
60
|
-
* - `busy`
|
61
|
-
* - `dnd`
|
62
|
-
* - `meeting`
|
63
|
-
* - `on-call`
|
64
|
-
* - `on-device`
|
65
|
-
* - `on-mobile`
|
66
|
-
* - `pause`
|
67
|
-
* - `pto`
|
68
|
-
* - `presenting`
|
69
|
-
* - `quiet`
|
70
|
-
* - `scheduled`
|
71
|
-
*/
|
72
|
-
presence?: PresenceType;
|
73
|
-
/**
|
74
|
-
* Acceptable values include:
|
75
|
-
* - xx_small
|
76
|
-
* - x_small
|
77
|
-
* - small
|
78
|
-
* - midsize
|
79
|
-
* - large
|
80
|
-
* - x_large
|
81
|
-
* - xx_large
|
82
|
-
*
|
83
|
-
* @default x_small
|
84
|
-
*/
|
85
|
-
size: AvatarSize;
|
86
|
-
/**
|
87
|
-
* Name of the icon to be displayed inside the Avatar.
|
88
|
-
* Must be a valid icon name.
|
89
|
-
*/
|
90
|
-
iconName?: IconNames;
|
91
|
-
/**
|
92
|
-
* The counter is the number which can be displayed on the avatar.
|
93
|
-
* The maximum number is 99 and if the give number is greater than 99,
|
94
|
-
* then the avatar will be displayed as `99+`.
|
95
|
-
* If the given number is a negative number,
|
96
|
-
* then the avatar will be displayed as `0`.
|
97
|
-
*/
|
98
|
-
counter?: number;
|
99
|
-
/**
|
100
|
-
* Represents the typing indicator when the user is typing.
|
101
|
-
* @default false
|
102
|
-
*/
|
103
|
-
isTyping: boolean;
|
40
|
+
declare class Avatar extends Avatar_base {
|
104
41
|
/**
|
105
42
|
* @internal
|
106
43
|
*/
|
@@ -8,12 +8,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
9
|
};
|
10
10
|
import { html, nothing } from 'lit';
|
11
|
-
import {
|
11
|
+
import { state } from 'lit/decorators.js';
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
13
|
import { Component } from '../../models';
|
14
|
+
import { AvatarComponentMixin } from '../../utils/mixins/AvatarComponentMixin';
|
14
15
|
import { AVATAR_TYPE, DEFAULTS, MAX_COUNTER } from './avatar.constants';
|
15
16
|
import styles from './avatar.styles';
|
16
|
-
import { getAvatarIconSize, getAvatarTextFontSize } from './avatar.utils';
|
17
|
+
import { getAvatarIconSize, getAvatarTextFontSize, getPresenceSize } from './avatar.utils';
|
17
18
|
/**
|
18
19
|
* The `mdc-avatar` component is used to represent a person or a space.
|
19
20
|
* An avatar can be an icon, initials, counter and photo.
|
@@ -49,27 +50,9 @@ import { getAvatarIconSize, getAvatarTextFontSize } from './avatar.utils';
|
|
49
50
|
* @cssproperty --mdc-avatar-loading-overlay-background-color -
|
50
51
|
* Allows customization of the loading overlay background color.
|
51
52
|
*/
|
52
|
-
class Avatar extends Component {
|
53
|
+
class Avatar extends AvatarComponentMixin(Component) {
|
53
54
|
constructor() {
|
54
55
|
super(...arguments);
|
55
|
-
/**
|
56
|
-
* Acceptable values include:
|
57
|
-
* - xx_small
|
58
|
-
* - x_small
|
59
|
-
* - small
|
60
|
-
* - midsize
|
61
|
-
* - large
|
62
|
-
* - x_large
|
63
|
-
* - xx_large
|
64
|
-
*
|
65
|
-
* @default x_small
|
66
|
-
*/
|
67
|
-
this.size = DEFAULTS.SIZE;
|
68
|
-
/**
|
69
|
-
* Represents the typing indicator when the user is typing.
|
70
|
-
* @default false
|
71
|
-
*/
|
72
|
-
this.isTyping = false;
|
73
56
|
/**
|
74
57
|
* @internal
|
75
58
|
*/
|
@@ -90,7 +73,7 @@ class Avatar extends Component {
|
|
90
73
|
}
|
91
74
|
if (this.presence) {
|
92
75
|
return html `
|
93
|
-
<mdc-presence class="presence" type="${this.presence}" size="${this.size}"></mdc-presence>
|
76
|
+
<mdc-presence class="presence" type="${this.presence}" size="${getPresenceSize(this.size)}"></mdc-presence>
|
94
77
|
`;
|
95
78
|
}
|
96
79
|
return nothing;
|
@@ -323,34 +306,6 @@ class Avatar extends Component {
|
|
323
306
|
}
|
324
307
|
}
|
325
308
|
Avatar.styles = [...Component.styles, ...styles];
|
326
|
-
__decorate([
|
327
|
-
property({ type: String }),
|
328
|
-
__metadata("design:type", String)
|
329
|
-
], Avatar.prototype, "src", void 0);
|
330
|
-
__decorate([
|
331
|
-
property({ type: String }),
|
332
|
-
__metadata("design:type", String)
|
333
|
-
], Avatar.prototype, "initials", void 0);
|
334
|
-
__decorate([
|
335
|
-
property({ type: String }),
|
336
|
-
__metadata("design:type", String)
|
337
|
-
], Avatar.prototype, "presence", void 0);
|
338
|
-
__decorate([
|
339
|
-
property({ type: String, reflect: true }),
|
340
|
-
__metadata("design:type", String)
|
341
|
-
], Avatar.prototype, "size", void 0);
|
342
|
-
__decorate([
|
343
|
-
property({ type: String, attribute: 'icon-name' }),
|
344
|
-
__metadata("design:type", String)
|
345
|
-
], Avatar.prototype, "iconName", void 0);
|
346
|
-
__decorate([
|
347
|
-
property({ type: Number }),
|
348
|
-
__metadata("design:type", Number)
|
349
|
-
], Avatar.prototype, "counter", void 0);
|
350
|
-
__decorate([
|
351
|
-
property({ type: Boolean, attribute: 'is-typing' }),
|
352
|
-
__metadata("design:type", Object)
|
353
|
-
], Avatar.prototype, "isTyping", void 0);
|
354
309
|
__decorate([
|
355
310
|
state(),
|
356
311
|
__metadata("design:type", Object)
|
@@ -6,9 +6,18 @@ declare const AVATAR_TYPE: {
|
|
6
6
|
readonly TEXT: "text";
|
7
7
|
};
|
8
8
|
declare const MAX_COUNTER = 99;
|
9
|
+
declare const AVATAR_SIZE: {
|
10
|
+
readonly 24: 24;
|
11
|
+
readonly 32: 32;
|
12
|
+
readonly 48: 48;
|
13
|
+
readonly 64: 64;
|
14
|
+
readonly 72: 72;
|
15
|
+
readonly 88: 88;
|
16
|
+
readonly 124: 124;
|
17
|
+
};
|
9
18
|
declare const DEFAULTS: {
|
10
19
|
readonly TYPE: "photo";
|
11
|
-
readonly SIZE:
|
20
|
+
readonly SIZE: 32;
|
12
21
|
readonly ICON_NAME: "user-regular";
|
13
22
|
};
|
14
|
-
export { TAG_NAME, DEFAULTS, AVATAR_TYPE, MAX_COUNTER, };
|
23
|
+
export { TAG_NAME, DEFAULTS, AVATAR_TYPE, MAX_COUNTER, AVATAR_SIZE, };
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import utils from '../../utils/tag-name';
|
2
|
-
import { SIZE as AVATAR_SIZE } from '../presence/presence.constants';
|
3
2
|
const TAG_NAME = utils.constructTagName('avatar');
|
4
3
|
const AVATAR_TYPE = {
|
5
4
|
COUNTER: 'counter',
|
@@ -9,9 +8,18 @@ const AVATAR_TYPE = {
|
|
9
8
|
};
|
10
9
|
const MAX_COUNTER = 99;
|
11
10
|
const ICON_NAME = 'user-regular';
|
11
|
+
const AVATAR_SIZE = {
|
12
|
+
24: 24,
|
13
|
+
32: 32,
|
14
|
+
48: 48,
|
15
|
+
64: 64,
|
16
|
+
72: 72,
|
17
|
+
88: 88,
|
18
|
+
124: 124,
|
19
|
+
};
|
12
20
|
const DEFAULTS = {
|
13
21
|
TYPE: AVATAR_TYPE.PHOTO,
|
14
|
-
SIZE: AVATAR_SIZE
|
22
|
+
SIZE: AVATAR_SIZE[32],
|
15
23
|
ICON_NAME,
|
16
24
|
};
|
17
|
-
export { TAG_NAME, DEFAULTS, AVATAR_TYPE, MAX_COUNTER, };
|
25
|
+
export { TAG_NAME, DEFAULTS, AVATAR_TYPE, MAX_COUNTER, AVATAR_SIZE, };
|
@@ -8,51 +8,51 @@ const styles = [hostFitContentStyles, css `
|
|
8
8
|
--mdc-avatar-loading-indicator-foreground-color: var(--mdc-avatar-default-foreground-color);
|
9
9
|
--mdc-avatar-loading-overlay-background-color: var(--mds-color-theme-common-overlays-secondary-normal);
|
10
10
|
}
|
11
|
-
:host([size="
|
11
|
+
:host([size="124"]) .content {
|
12
12
|
width: 7.75rem;
|
13
13
|
height: 7.75rem;
|
14
14
|
}
|
15
|
-
:host([size="
|
15
|
+
:host([size="88"]) .content {
|
16
16
|
width: 5.5rem;
|
17
17
|
height: 5.5rem;
|
18
18
|
}
|
19
|
-
:host([size="
|
19
|
+
:host([size="72"]) .content {
|
20
20
|
width: 4.5rem;
|
21
21
|
height: 4.5rem;
|
22
22
|
}
|
23
|
-
:host([size="
|
23
|
+
:host([size="64"]) .content {
|
24
24
|
width: 4rem;
|
25
25
|
height: 4rem;
|
26
26
|
}
|
27
|
-
:host([size="
|
27
|
+
:host([size="48"]) .content {
|
28
28
|
width: 3rem;
|
29
29
|
height: 3rem;
|
30
30
|
}
|
31
|
-
:host([size="
|
31
|
+
:host([size="32"]) .content {
|
32
32
|
width: 2rem;
|
33
33
|
height: 2rem;
|
34
34
|
}
|
35
|
-
:host([size="
|
35
|
+
:host([size="24"]) .content {
|
36
36
|
width: 1.5rem;
|
37
37
|
height: 1.5rem;
|
38
38
|
}
|
39
|
-
:host([size="
|
39
|
+
:host([size="124"]) .content > .loading__wrapper > .loader {
|
40
40
|
transform: scale(1.5);
|
41
41
|
}
|
42
|
-
:host([size="
|
42
|
+
:host([size="88"]) .content > .loading__wrapper > .loader {
|
43
43
|
transform: scale(1.2);
|
44
44
|
}
|
45
|
-
:host([size="
|
46
|
-
:host([size="
|
45
|
+
:host([size="72"]) .content > .loading__wrapper > .loader,
|
46
|
+
:host([size="64"]) .content > .loading__wrapper > .loader {
|
47
47
|
transform: scale(0.8);
|
48
48
|
}
|
49
|
-
:host([size="
|
49
|
+
:host([size="48"]) .content > .loading__wrapper > .loader {
|
50
50
|
transform: scale(0.6);
|
51
51
|
}
|
52
|
-
:host([size="
|
52
|
+
:host([size="32"]) .content > .loading__wrapper > .loader {
|
53
53
|
transform: scale(0.4);
|
54
54
|
}
|
55
|
-
:host([size="
|
55
|
+
:host([size="24"]) .content > .loading__wrapper > .loader {
|
56
56
|
transform: scale(0.3);
|
57
57
|
}
|
58
58
|
.content {
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { AVATAR_TYPE } from './avatar.constants';
|
2
|
-
import { SIZE as AVATAR_SIZE } from '../presence/presence.constants';
|
1
|
+
import { AVATAR_TYPE, AVATAR_SIZE } from './avatar.constants';
|
3
2
|
import type { ValueOf } from '../../utils/types';
|
4
3
|
export type AvatarType = ValueOf<typeof AVATAR_TYPE>;
|
5
4
|
export type AvatarSize = ValueOf<typeof AVATAR_SIZE>;
|
@@ -1,5 +1,7 @@
|
|
1
|
+
import type { PresenceSize } from '../presence/presence.types';
|
1
2
|
import type { TextType } from '../text/text.types';
|
2
3
|
import type { AvatarSize } from './avatar.types';
|
4
|
+
declare const getPresenceSize: (size: AvatarSize) => PresenceSize;
|
3
5
|
declare const getAvatarIconSize: (size: AvatarSize) => number;
|
4
6
|
declare const getAvatarTextFontSize: (size: AvatarSize) => TextType;
|
5
|
-
export { getAvatarIconSize, getAvatarTextFontSize, };
|
7
|
+
export { getAvatarIconSize, getAvatarTextFontSize, getPresenceSize, };
|
@@ -1,27 +1,40 @@
|
|
1
|
-
import { SIZE as
|
1
|
+
import { SIZE as PRESENCE_SIZE } from '../presence/presence.constants';
|
2
2
|
import { TYPE as FONT_TYPE } from '../text/text.constants';
|
3
|
+
import { AVATAR_SIZE } from './avatar.constants';
|
4
|
+
const getPresenceSize = (size) => {
|
5
|
+
const avatarPresenceSizeMap = {
|
6
|
+
[AVATAR_SIZE[124]]: PRESENCE_SIZE.XX_LARGE,
|
7
|
+
[AVATAR_SIZE[88]]: PRESENCE_SIZE.X_LARGE,
|
8
|
+
[AVATAR_SIZE[72]]: PRESENCE_SIZE.LARGE,
|
9
|
+
[AVATAR_SIZE[64]]: PRESENCE_SIZE.MIDSIZE,
|
10
|
+
[AVATAR_SIZE[48]]: PRESENCE_SIZE.SMALL,
|
11
|
+
[AVATAR_SIZE[32]]: PRESENCE_SIZE.X_SMALL,
|
12
|
+
[AVATAR_SIZE[24]]: PRESENCE_SIZE.XX_SMALL,
|
13
|
+
};
|
14
|
+
return avatarPresenceSizeMap[size] || PRESENCE_SIZE.X_SMALL; // default size of presence
|
15
|
+
};
|
3
16
|
const getAvatarIconSize = (size) => {
|
4
17
|
const avatarIconSizeMap = {
|
5
|
-
[AVATAR_SIZE
|
6
|
-
[AVATAR_SIZE
|
7
|
-
[AVATAR_SIZE
|
8
|
-
[AVATAR_SIZE
|
9
|
-
[AVATAR_SIZE
|
10
|
-
[AVATAR_SIZE
|
11
|
-
[AVATAR_SIZE
|
18
|
+
[AVATAR_SIZE[124]]: 4.75,
|
19
|
+
[AVATAR_SIZE[88]]: 3,
|
20
|
+
[AVATAR_SIZE[72]]: 2.5,
|
21
|
+
[AVATAR_SIZE[64]]: 2.25,
|
22
|
+
[AVATAR_SIZE[48]]: 1.75,
|
23
|
+
[AVATAR_SIZE[32]]: 1.25,
|
24
|
+
[AVATAR_SIZE[24]]: 1,
|
12
25
|
};
|
13
26
|
return avatarIconSizeMap[size] || 1.25; // default size of icon
|
14
27
|
};
|
15
28
|
const getAvatarTextFontSize = (size) => {
|
16
29
|
const avatarTextFontSizeMap = {
|
17
|
-
[AVATAR_SIZE
|
18
|
-
[AVATAR_SIZE
|
19
|
-
[AVATAR_SIZE
|
20
|
-
[AVATAR_SIZE
|
21
|
-
[AVATAR_SIZE
|
22
|
-
[AVATAR_SIZE
|
23
|
-
[AVATAR_SIZE
|
30
|
+
[AVATAR_SIZE[124]]: FONT_TYPE.HEADING_XLARGE_MEDIUM,
|
31
|
+
[AVATAR_SIZE[88]]: FONT_TYPE.HEADING_LARGE_MEDIUM,
|
32
|
+
[AVATAR_SIZE[72]]: FONT_TYPE.HEADING_MIDSIZE_MEDIUM,
|
33
|
+
[AVATAR_SIZE[64]]: FONT_TYPE.HEADING_SMALL_MEDIUM,
|
34
|
+
[AVATAR_SIZE[48]]: FONT_TYPE.HEADING_SMALL_MEDIUM,
|
35
|
+
[AVATAR_SIZE[32]]: FONT_TYPE.BODY_MIDSIZE_MEDIUM,
|
36
|
+
[AVATAR_SIZE[24]]: FONT_TYPE.BODY_SMALL_MEDIUM,
|
24
37
|
};
|
25
38
|
return avatarTextFontSizeMap[size] || FONT_TYPE.BODY_MIDSIZE_MEDIUM; // default size of text font
|
26
39
|
};
|
27
|
-
export { getAvatarIconSize, getAvatarTextFontSize, };
|
40
|
+
export { getAvatarIconSize, getAvatarTextFontSize, getPresenceSize, };
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { CSSResult, PropertyValueMap } from 'lit';
|
2
|
+
import Buttonsimple from '../buttonsimple';
|
3
|
+
declare const AvatarButton_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/AvatarComponentMixin").AvatarComponentMixinInterface> & typeof Buttonsimple;
|
4
|
+
/**
|
5
|
+
* The `mdc-avatarbutton` component is an interactable version of the `mdc-avatar` component.
|
6
|
+
*
|
7
|
+
* This component is made by extending `buttonsimple` class.
|
8
|
+
* The button component acts as a wrapper for the avatar component.
|
9
|
+
*
|
10
|
+
* @dependency mdc-avatar
|
11
|
+
*
|
12
|
+
* @tagname mdc-avatarbutton
|
13
|
+
*/
|
14
|
+
declare class AvatarButton extends AvatarButton_base {
|
15
|
+
/**
|
16
|
+
* Aria-label attribute to be set for accessibility
|
17
|
+
*/
|
18
|
+
ariaLabel: string | null;
|
19
|
+
constructor();
|
20
|
+
update(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
21
|
+
private setSize;
|
22
|
+
render(): import("lit-html").TemplateResult<1>;
|
23
|
+
static styles: Array<CSSResult>;
|
24
|
+
}
|
25
|
+
export default AvatarButton;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
|
+
import { AvatarComponentMixin } from '../../utils/mixins/AvatarComponentMixin';
|
14
|
+
import { AVATAR_SIZE, DEFAULTS } from '../avatar/avatar.constants';
|
15
|
+
import { DEFAULTS as BUTTON_DEFAULTS } from '../button/button.constants';
|
16
|
+
import Buttonsimple from '../buttonsimple';
|
17
|
+
import styles from './avatarbutton.styles';
|
18
|
+
/**
|
19
|
+
* The `mdc-avatarbutton` component is an interactable version of the `mdc-avatar` component.
|
20
|
+
*
|
21
|
+
* This component is made by extending `buttonsimple` class.
|
22
|
+
* The button component acts as a wrapper for the avatar component.
|
23
|
+
*
|
24
|
+
* @dependency mdc-avatar
|
25
|
+
*
|
26
|
+
* @tagname mdc-avatarbutton
|
27
|
+
*/
|
28
|
+
class AvatarButton extends AvatarComponentMixin(Buttonsimple) {
|
29
|
+
constructor() {
|
30
|
+
super();
|
31
|
+
/**
|
32
|
+
* Aria-label attribute to be set for accessibility
|
33
|
+
*/
|
34
|
+
this.ariaLabel = null;
|
35
|
+
this.active = undefined;
|
36
|
+
this.disabled = undefined;
|
37
|
+
this.softDisabled = undefined;
|
38
|
+
this.role = 'button';
|
39
|
+
this.type = BUTTON_DEFAULTS.TYPE;
|
40
|
+
}
|
41
|
+
update(changedProperties) {
|
42
|
+
super.update(changedProperties);
|
43
|
+
if (changedProperties.has('size')) {
|
44
|
+
this.setSize(this.size);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
setSize(size) {
|
48
|
+
this.setAttribute('size', Object.values(AVATAR_SIZE).includes(size) ? `${size}` : DEFAULTS.SIZE.toString());
|
49
|
+
}
|
50
|
+
render() {
|
51
|
+
return html `
|
52
|
+
<mdc-avatar
|
53
|
+
slot="prefixIcon"
|
54
|
+
?is-typing="${this.isTyping}"
|
55
|
+
counter="${ifDefined(this.counter)}"
|
56
|
+
icon-name="${ifDefined(this.iconName)}"
|
57
|
+
initials="${ifDefined(this.initials)}"
|
58
|
+
presence="${ifDefined(this.presence)}"
|
59
|
+
size="${ifDefined(this.size)}"
|
60
|
+
src="${ifDefined(this.src)}"
|
61
|
+
></mdc-avatar>
|
62
|
+
`;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
AvatarButton.styles = [...styles];
|
66
|
+
__decorate([
|
67
|
+
property({ type: String, attribute: 'aria-label' }),
|
68
|
+
__metadata("design:type", Object)
|
69
|
+
], AvatarButton.prototype, "ariaLabel", void 0);
|
70
|
+
export default AvatarButton;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
|
3
|
+
const styles = [hostFitContentStyles, css `
|
4
|
+
:host {
|
5
|
+
padding: unset;
|
6
|
+
margin: unset;
|
7
|
+
outline: none;
|
8
|
+
border-radius: 0.25rem;
|
9
|
+
}
|
10
|
+
`, hostFocusRingStyles];
|
11
|
+
export default styles;
|