Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: create avatar base class to abstract style specfic api",
"packageName": "@fluentui/web-components",
"email": "jes@microsoft.com",
"dependentChangeType": "patch"
}
46 changes: 25 additions & 21 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,29 +199,9 @@ export const AnchorTarget: {
export type AnchorTarget = ValuesOf<typeof AnchorTarget>;

// @public
export class Avatar extends FASTElement {
constructor();
active?: AvatarActive | undefined;
export class Avatar extends BaseAvatar {
appearance?: AvatarAppearance | undefined;
color?: AvatarColor | undefined;
colorId?: AvatarNamedColor | undefined;
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")[];
// (undocumented)
connectedCallback(): void;
// (undocumented)
disconnectedCallback(): void;
// @internal
elementInternals: ElementInternals;
// @internal
generateColor(): void;
// @internal
generateInitials(): string | void;
// @internal
handleChange(source: any, propertyName: string): void;
initials?: string | undefined;
name?: string | undefined;
shape?: AvatarShape | undefined;
size?: AvatarSize | undefined;
}

// 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)
Expand Down Expand Up @@ -456,6 +436,30 @@ export const BadgeStyles: ElementStyles;
// @public (undocumented)
export const BadgeTemplate: ElementViewTemplate<Badge>;

// @public
export class BaseAvatar extends FASTElement {
constructor();
active?: AvatarActive | undefined;
color?: AvatarColor | undefined;
colorId?: AvatarNamedColor | undefined;
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")[];
// (undocumented)
connectedCallback(): void;
// (undocumented)
disconnectedCallback(): void;
// @internal
elementInternals: ElementInternals;
// @internal
generateColor(): void;
// @internal
generateInitials(): string | void;
// @internal
handleChange(source: any, propertyName: string): void;
initials?: string | undefined;
name?: string | undefined;
size?: AvatarSize | undefined;
}

// @public
export class BaseButton extends FASTElement {
constructor();
Expand Down
50 changes: 29 additions & 21 deletions packages/web-components/src/avatar/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
* The base class used for constructing a fluent-avatar custom element
* @public
*/
export class Avatar extends FASTElement {
export class BaseAvatar extends FASTElement {
/**
* The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
*
Expand Down Expand Up @@ -59,16 +59,6 @@ export class Avatar extends FASTElement {
@attr({ converter: nullableNumberConverter })
public size?: AvatarSize | undefined;

/**
* The avatar can have a circular or square shape.
*
* @public
* @remarks
* HTML Attribute: shape
*/
@attr
public shape?: AvatarShape | undefined;

/**
* Optional activity indicator
* * active: the avatar will be decorated according to activeAppearance
Expand All @@ -82,16 +72,6 @@ export class Avatar extends FASTElement {
@attr
public active?: AvatarActive | undefined;

/**
* The appearance when `active="active"`
*
* @public
* @remarks
* HTML Attribute: appearance
*/
@attr
public appearance?: AvatarAppearance | undefined;

/**
* The color when displaying either an icon or initials.
* * neutral (default): gray
Expand Down Expand Up @@ -201,6 +181,34 @@ export class Avatar extends FASTElement {
public static colors = Object.values(AvatarNamedColor);
}

/**
* An Avatar Custom HTML Element.
* Based on BaseAvatar and includes style and layout specific attributes
*
* @public
*/
export class Avatar extends BaseAvatar {
/**
* The avatar can have a circular or square shape.
*
* @public
* @remarks
* HTML Attribute: shape
*/
@attr
public shape?: AvatarShape | undefined;

/**
* The appearance when `active="active"`
*
* @public
* @remarks
* HTML Attribute: appearance
*/
@attr
public appearance?: AvatarAppearance | undefined;
}

// copied from React avatar
const getHashCode = (str: string): number => {
let hashCode = 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/src/avatar/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { Avatar } from './avatar.js';
export { BaseAvatar, Avatar } from './avatar.js';
export {
AvatarActive,
AvatarAppearance,
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
AvatarSize,
AvatarStyles,
AvatarTemplate,
BaseAvatar,
} from './avatar/index.js';
export {
Badge,
Expand Down