Skip to content

Commit bf6be2b

Browse files
authored
[chore]: create base class for avatar and remove style and layout specific api (#32083)
1 parent fe4b9c4 commit bf6be2b

File tree

5 files changed

+63
-43
lines changed

5 files changed

+63
-43
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "chore: create avatar base class to abstract style specfic api",
4+
"packageName": "@fluentui/web-components",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

Diff for: packages/web-components/docs/api-report.md

+25-21
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,9 @@ export const AnchorTarget: {
199199
export type AnchorTarget = ValuesOf<typeof AnchorTarget>;
200200

201201
// @public
202-
export class Avatar extends FASTElement {
203-
constructor();
204-
active?: AvatarActive | undefined;
202+
export class Avatar extends BaseAvatar {
205203
appearance?: AvatarAppearance | undefined;
206-
color?: AvatarColor | undefined;
207-
colorId?: AvatarNamedColor | undefined;
208-
static colors: ("anchor" | "dark-red" | "cranberry" | "red" | "pumpkin" | "peach" | "marigold" | "gold" | "brass" | "brown" | "forest" | "seafoam" | "dark-green" | "light-teal" | "teal" | "steel" | "blue" | "royal-blue" | "cornflower" | "navy" | "lavender" | "purple" | "grape" | "lilac" | "pink" | "magenta" | "plum" | "beige" | "mink" | "platinum")[];
209-
// (undocumented)
210-
connectedCallback(): void;
211-
// (undocumented)
212-
disconnectedCallback(): void;
213-
// @internal
214-
elementInternals: ElementInternals;
215-
// @internal
216-
generateColor(): void;
217-
// @internal
218-
generateInitials(): string | void;
219-
// @internal
220-
handleChange(source: any, propertyName: string): void;
221-
initials?: string | undefined;
222-
name?: string | undefined;
223204
shape?: AvatarShape | undefined;
224-
size?: AvatarSize | undefined;
225205
}
226206

227207
// Warning: (ae-missing-release-tag) "AvatarActive" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -456,6 +436,30 @@ export const BadgeStyles: ElementStyles;
456436
// @public (undocumented)
457437
export const BadgeTemplate: ElementViewTemplate<Badge>;
458438

439+
// @public
440+
export class BaseAvatar extends FASTElement {
441+
constructor();
442+
active?: AvatarActive | undefined;
443+
color?: AvatarColor | undefined;
444+
colorId?: AvatarNamedColor | undefined;
445+
static colors: ("anchor" | "dark-red" | "cranberry" | "red" | "pumpkin" | "peach" | "marigold" | "gold" | "brass" | "brown" | "forest" | "seafoam" | "dark-green" | "light-teal" | "teal" | "steel" | "blue" | "royal-blue" | "cornflower" | "navy" | "lavender" | "purple" | "grape" | "lilac" | "pink" | "magenta" | "plum" | "beige" | "mink" | "platinum")[];
446+
// (undocumented)
447+
connectedCallback(): void;
448+
// (undocumented)
449+
disconnectedCallback(): void;
450+
// @internal
451+
elementInternals: ElementInternals;
452+
// @internal
453+
generateColor(): void;
454+
// @internal
455+
generateInitials(): string | void;
456+
// @internal
457+
handleChange(source: any, propertyName: string): void;
458+
initials?: string | undefined;
459+
name?: string | undefined;
460+
size?: AvatarSize | undefined;
461+
}
462+
459463
// @public
460464
export class BaseButton extends FASTElement {
461465
constructor();

Diff for: packages/web-components/src/avatar/avatar.ts

+29-21
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
* The base class used for constructing a fluent-avatar custom element
1515
* @public
1616
*/
17-
export class Avatar extends FASTElement {
17+
export class BaseAvatar extends FASTElement {
1818
/**
1919
* The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
2020
*
@@ -59,16 +59,6 @@ export class Avatar extends FASTElement {
5959
@attr({ converter: nullableNumberConverter })
6060
public size?: AvatarSize | undefined;
6161

62-
/**
63-
* The avatar can have a circular or square shape.
64-
*
65-
* @public
66-
* @remarks
67-
* HTML Attribute: shape
68-
*/
69-
@attr
70-
public shape?: AvatarShape | undefined;
71-
7262
/**
7363
* Optional activity indicator
7464
* * active: the avatar will be decorated according to activeAppearance
@@ -82,16 +72,6 @@ export class Avatar extends FASTElement {
8272
@attr
8373
public active?: AvatarActive | undefined;
8474

85-
/**
86-
* The appearance when `active="active"`
87-
*
88-
* @public
89-
* @remarks
90-
* HTML Attribute: appearance
91-
*/
92-
@attr
93-
public appearance?: AvatarAppearance | undefined;
94-
9575
/**
9676
* The color when displaying either an icon or initials.
9777
* * neutral (default): gray
@@ -201,6 +181,34 @@ export class Avatar extends FASTElement {
201181
public static colors = Object.values(AvatarNamedColor);
202182
}
203183

184+
/**
185+
* An Avatar Custom HTML Element.
186+
* Based on BaseAvatar and includes style and layout specific attributes
187+
*
188+
* @public
189+
*/
190+
export class Avatar extends BaseAvatar {
191+
/**
192+
* The avatar can have a circular or square shape.
193+
*
194+
* @public
195+
* @remarks
196+
* HTML Attribute: shape
197+
*/
198+
@attr
199+
public shape?: AvatarShape | undefined;
200+
201+
/**
202+
* The appearance when `active="active"`
203+
*
204+
* @public
205+
* @remarks
206+
* HTML Attribute: appearance
207+
*/
208+
@attr
209+
public appearance?: AvatarAppearance | undefined;
210+
}
211+
204212
// copied from React avatar
205213
const getHashCode = (str: string): number => {
206214
let hashCode = 0;

Diff for: packages/web-components/src/avatar/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { Avatar } from './avatar.js';
1+
export { BaseAvatar, Avatar } from './avatar.js';
22
export {
33
AvatarActive,
44
AvatarAppearance,

Diff for: packages/web-components/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export {
2626
AvatarSize,
2727
AvatarStyles,
2828
AvatarTemplate,
29+
BaseAvatar,
2930
} from './avatar/index.js';
3031
export {
3132
Badge,

0 commit comments

Comments
 (0)