@fluentui/react-avatar 9.2.5 → 9.2.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/SPEC.md DELETED
@@ -1,172 +0,0 @@
1
- # Avatar
2
-
3
- **GitHub Epic issue** - [Avatar Convergence #16373](https://github.com/microsoft/fluentui/issues/16373)
4
-
5
- ## Background
6
-
7
- The Avatar component represents a person or entity. It displays the person's image, initials, or an icon, and can be either circular or square.
8
-
9
- Note: The Avatar control has been mostly implemented already. Visit [Avatar Storybook Examples](https://fluentuipr.z22.web.core.windows.net/heads/master/react-components/storybook/index.html?path=/docs/components-avatar--default) to see the current state of the implementation.
10
-
11
- ## Prior Art
12
-
13
- ### Open UI
14
-
15
- The Open UI [Avatar Research](https://open-ui.org/components/avatar.research) page (currently in PR: https://github.com/WICG/open-ui/pull/250), shows how the Avatar component is used in UI platforms across the web. There is a good consensus about the basic features such as displaying an image, initials, or an icon; as well as the shape being either a square or circle.
16
-
17
- ### Comparison of v8 and v0
18
-
19
- The existing components are:
20
-
21
- - v8 - [Persona](https://developer.microsoft.com/en-us/fluentui#/controls/web/persona)
22
- - v0 - [Avatar](https://fluentsite.z22.web.core.windows.net/0.51.4/components/avatar/definition)
23
-
24
- #### Display
25
-
26
- Both the v8 and v0 components support displaying an image, initials, and an icon.
27
-
28
- The v8 `Persona` also supports the full name and extra detail text to the right of the image. The extra detail text is specifically out of scope for the `Avatar` control, and may be added to a future component that makes use of Avatar.
29
-
30
- The v8 `Persona` appears to not support a custom icon, and can only show the default person icon, or a "?" icon
31
-
32
- #### Status/Presence Badge
33
-
34
- Both components support showing a badge to indicate status, but they have different APIs. The v8 `Persona` has an enum of preset options for the presence badge. The v0 `Avatar` supports rendering a `Status` component, which is more customizable and can render an icon, and specify different sizes and colors.
35
-
36
- ## Sample Code
37
-
38
- Display a user's initials:
39
-
40
- ```jsx
41
- <Avatar name="Miguel Garcia" />
42
- ```
43
-
44
- Display a user's image:
45
-
46
- ```jsx
47
- <Avatar size={72} name="Mona Kane" image={{ src: './MonaKane.jpg' }} />
48
- ```
49
-
50
- Display an icon only:
51
-
52
- ```jsx
53
- <Avatar aria-label="Team" icon={<PeopleTeamRegular />} shape="square" />
54
- ```
55
-
56
- Display a badge:
57
-
58
- ```jsx
59
- <Avatar name="Allan Munger" badge={{ status: 'busy' }} />
60
- ```
61
-
62
- With active state indication:
63
-
64
- ```jsx
65
- <Avatar name="Daisy Phillips" active={isUserActive ? 'active' : 'inactive'} activeAppearance="ring-shadow" />
66
- ```
67
-
68
- ## Variants
69
-
70
- ### Color
71
-
72
- The Avatar supports color variants when displaying initials or an icon:
73
-
74
- - **Neutral** - Gray (default)
75
- - **Brand** - Brand colors from the theme
76
- - **Colorful** - Pick from a list of pre-defined Avatar colors. The color will be assigned based on a hash of the name
77
- (to "randomly" assign a person a color). The color name (like `darkRed`) can also be specified explicitly in case the use case
78
- requires a different algorithm to pick the color.
79
-
80
- ### Shape
81
-
82
- The Avatar supports a circular and square (with rounded corners) shape.
83
-
84
- ## API
85
-
86
- From [Avatar.types.tsx](https://github.com/microsoft/fluentui/blob/master/packages/react-avatar/src/components/Avatar/Avatar.types.tsx):
87
-
88
- ### Slots
89
-
90
- - `root` - The root element of the Avatar.
91
- - `image` - The Avatar's image, if provided.
92
- - `initials` - The text shown when there's no image. Defaults to the initials derived from `name`.
93
- - `icon` - Icon displayed when there's no image or intials available.
94
- - `badge` - PresenceBadge to show the avatar's status.
95
-
96
- ### Props
97
-
98
- See API at [Avatar.types.ts](./src/components/Avatar/Avatar.types.ts).
99
-
100
- ## Structure
101
-
102
- JSX Tree:
103
-
104
- ```jsx
105
- <slots.root {...slotProps.root}>
106
- {slots.initials && <slots.initials {...slotProps.initials} />}
107
- {slots.icon && <slots.icon {...slotProps.icon} />}
108
- {slots.image && <slots.image {...slotProps.image} />}
109
- {slots.badge && <slots.badge {...slotProps.badge} />}
110
- </slots.root>
111
- ```
112
-
113
- Resulting HTML (in this example, "avatar-42" is an ID generated by `useId`):
114
-
115
- ```html
116
- <span class="{root}" id="avatar-42" aria-label="Miguel Garcia" aria-labelledby="avatar-42 avatar-42__badge">
117
- <!-- Only one of initials OR icon will be rendered, never both -->
118
- <span class="{initials}" aria-hidden="true">MG</span>
119
- <span class="{icon}" aria-hidden="true"><svg>...</svg></span>
120
-
121
- <!-- The Image -->
122
- <img class="{image}" src="..." aria-hidden="true" role="presentation" alt="" />
123
-
124
- <!-- The PresenceBadge's HTML is rendered here -->
125
- <span class="{PresenceBadge}" id="avatar-42__badge" aria-hidden="true">...</span>
126
- </span>
127
- ```
128
-
129
- ## Migration
130
-
131
- See [MIGRATION.md](./MIGRATION.md).
132
-
133
- ## Behaviors
134
-
135
- ### States
136
-
137
- - **Display** - The Avatar will use the following priority:
138
-
139
- - The `image` property, if provided.
140
- - Initials derived from the `name` property (this is always displayed, so it is visible while the image is loading, and if the image fails to load).
141
- - The `icon` property, if provided.
142
- - If no `image`, `icon`, or `name` is provided, the default "person" icon will be used.
143
-
144
- - **Active** - The `active` property affects the display of the avatar if set. There will be an animation when switching between active and inactive.
145
- - `unset` - Display at normal size/opacity.
146
- - `inactive` - Reduce to 80% opacity, and 87.5% size.
147
- - `active` - Adorn with an extra visual such as a ring and/or shadow, based on the `activeAppearance` property.
148
-
149
- ### Interaction
150
-
151
- The Avatar is non-interactive.
152
-
153
- - **Keyboard** - Not keyboard focusable.
154
- - **Mouse** - Nothing
155
- - **Touch** - Nothing
156
-
157
- ## Accessibility
158
-
159
- The Avatar presents as a single img element to accessibility tools, regardless of what it is displaying (image, initials, or icon).
160
-
161
- - The Avatar's root has `role="img"`
162
- - All other slots have `aria-hidden="true"`.
163
- - The `<img>` additionally has `alt="" role="presentation"`
164
-
165
- The Avatar root's label is determined using the following priority:
166
-
167
- - If `aria-label` and/or `aria-labelledby` is provided on props, do not add anything else.
168
- - If `name` is provided, set the root's `aria-label={name}`.
169
- - If a badge is present, _also_ set the root's `aria-labelledby={root.id + ' ' + badge.id}`.
170
- - This means the Avatar is labelled by both its root and badge slots, and results in a label like "Miguel Garcia Busy".
171
- - If there's no `name`, but `initials` are provided, set the root's `aria-labelledby={initials.id}`.
172
- - If a badge is present, _instead_ set the root's `aria-labelledby={initials.id + ' ' + badge.id}`.