@fluentui/react-persona 0.0.0-nightly-20221007-1237.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +127 -0
- package/CHANGELOG.md +53 -0
- package/LICENSE +15 -0
- package/MIGRATION.md +42 -0
- package/README.md +29 -0
- package/Spec.md +213 -0
- package/dist/index.d.ts +114 -0
- package/lib/Persona.js +2 -0
- package/lib/Persona.js.map +1 -0
- package/lib/components/Persona/Persona.js +16 -0
- package/lib/components/Persona/Persona.js.map +1 -0
- package/lib/components/Persona/Persona.types.js +2 -0
- package/lib/components/Persona/Persona.types.js.map +1 -0
- package/lib/components/Persona/index.js +6 -0
- package/lib/components/Persona/index.js.map +1 -0
- package/lib/components/Persona/renderPersona.js +26 -0
- package/lib/components/Persona/renderPersona.js.map +1 -0
- package/lib/components/Persona/usePersona.js +101 -0
- package/lib/components/Persona/usePersona.js.map +1 -0
- package/lib/components/Persona/usePersonaStyles.js +208 -0
- package/lib/components/Persona/usePersonaStyles.js.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib-commonjs/Persona.js +10 -0
- package/lib-commonjs/Persona.js.map +1 -0
- package/lib-commonjs/components/Persona/Persona.js +27 -0
- package/lib-commonjs/components/Persona/Persona.js.map +1 -0
- package/lib-commonjs/components/Persona/Persona.types.js +6 -0
- package/lib-commonjs/components/Persona/Persona.types.js.map +1 -0
- package/lib-commonjs/components/Persona/index.js +18 -0
- package/lib-commonjs/components/Persona/index.js.map +1 -0
- package/lib-commonjs/components/Persona/renderPersona.js +37 -0
- package/lib-commonjs/components/Persona/renderPersona.js.map +1 -0
- package/lib-commonjs/components/Persona/usePersona.js +113 -0
- package/lib-commonjs/components/Persona/usePersona.js.map +1 -0
- package/lib-commonjs/components/Persona/usePersonaStyles.js +219 -0
- package/lib-commonjs/components/Persona/usePersonaStyles.js.map +1 -0
- package/lib-commonjs/index.js +40 -0
- package/lib-commonjs/index.js.map +1 -0
- package/package.json +49 -0
package/CHANGELOG.json
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
{
|
2
|
+
"name": "@fluentui/react-persona",
|
3
|
+
"entries": [
|
4
|
+
{
|
5
|
+
"date": "Fri, 07 Oct 2022 12:44:22 GMT",
|
6
|
+
"tag": "@fluentui/react-persona_v0.0.0-nightly-20221007-1237.1",
|
7
|
+
"version": "0.0.0-nightly-20221007-1237.1",
|
8
|
+
"comments": {
|
9
|
+
"prerelease": [
|
10
|
+
{
|
11
|
+
"author": "fluentui-internal@service.microsoft.com",
|
12
|
+
"package": "@fluentui/react-persona",
|
13
|
+
"commit": "not available",
|
14
|
+
"comment": "Release nightly v9"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-persona",
|
19
|
+
"comment": "Bump @fluentui/react-avatar to v0.0.0-nightly-20221007-1237.1",
|
20
|
+
"commit": "cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-persona",
|
25
|
+
"comment": "Bump @fluentui/react-badge to v0.0.0-nightly-20221007-1237.1",
|
26
|
+
"commit": "cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-persona",
|
31
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20221007-1237.1",
|
32
|
+
"commit": "cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"author": "beachball",
|
36
|
+
"package": "@fluentui/react-persona",
|
37
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20221007-1237.1",
|
38
|
+
"commit": "cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"author": "beachball",
|
42
|
+
"package": "@fluentui/react-persona",
|
43
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20221007-1237.1",
|
44
|
+
"commit": "cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec"
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"date": "Mon, 03 Oct 2022 22:24:38 GMT",
|
51
|
+
"tag": "@fluentui/react-persona_v9.0.0",
|
52
|
+
"version": "9.0.0",
|
53
|
+
"comments": {
|
54
|
+
"patch": [
|
55
|
+
{
|
56
|
+
"author": "esteban.230@hotmail.com",
|
57
|
+
"package": "@fluentui/react-persona",
|
58
|
+
"commit": "86b3133d97c177cac545b253deb11374ee829574",
|
59
|
+
"comment": "docs: Add migration guide."
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"minor": [
|
63
|
+
{
|
64
|
+
"author": "esteban.230@hotmail.com",
|
65
|
+
"package": "@fluentui/react-persona",
|
66
|
+
"commit": "2e8d044a4ce2c1095f13e08716c3ba13069ebf0d",
|
67
|
+
"comment": "feat: Publishing package."
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"author": "beachball",
|
71
|
+
"package": "@fluentui/react-persona",
|
72
|
+
"comment": "Bump @fluentui/react-avatar to v9.2.0",
|
73
|
+
"commit": "67a8c98b8d53cd2fa14d668cf639b867b68ad18a"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"author": "beachball",
|
77
|
+
"package": "@fluentui/react-persona",
|
78
|
+
"comment": "Bump @fluentui/react-badge to v9.0.7",
|
79
|
+
"commit": "67a8c98b8d53cd2fa14d668cf639b867b68ad18a"
|
80
|
+
}
|
81
|
+
]
|
82
|
+
}
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"date": "Tue, 20 Sep 2022 20:55:45 GMT",
|
86
|
+
"tag": "@fluentui/react-persona_v9.0.0-alpha.0",
|
87
|
+
"version": "9.0.0-alpha.0",
|
88
|
+
"comments": {
|
89
|
+
"patch": [
|
90
|
+
{
|
91
|
+
"author": "beachball",
|
92
|
+
"package": "@fluentui/react-persona",
|
93
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.14",
|
94
|
+
"commit": "4ceba844c804a2f49b0465389100e7a3dabf116e"
|
95
|
+
}
|
96
|
+
]
|
97
|
+
}
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"date": "Thu, 15 Sep 2022 09:50:08 GMT",
|
101
|
+
"tag": "@fluentui/react-persona_v9.0.0-alpha.0",
|
102
|
+
"version": "9.0.0-alpha.0",
|
103
|
+
"comments": {
|
104
|
+
"patch": [
|
105
|
+
{
|
106
|
+
"author": "beachball",
|
107
|
+
"package": "@fluentui/react-persona",
|
108
|
+
"comment": "Bump @fluentui/react-theme to v9.1.0",
|
109
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"author": "beachball",
|
113
|
+
"package": "@fluentui/react-persona",
|
114
|
+
"comment": "Bump @fluentui/react-utilities to v9.1.0",
|
115
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"author": "beachball",
|
119
|
+
"package": "@fluentui/react-persona",
|
120
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13",
|
121
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
122
|
+
}
|
123
|
+
]
|
124
|
+
}
|
125
|
+
}
|
126
|
+
]
|
127
|
+
}
|
package/CHANGELOG.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Change Log - @fluentui/react-persona
|
2
|
+
|
3
|
+
This log was last generated on Fri, 07 Oct 2022 12:44:22 GMT and should not be manually modified.
|
4
|
+
|
5
|
+
<!-- Start content -->
|
6
|
+
|
7
|
+
## [0.0.0-nightly-20221007-1237.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-persona_v0.0.0-nightly-20221007-1237.1)
|
8
|
+
|
9
|
+
Fri, 07 Oct 2022 12:44:22 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-persona_v9.0.0..@fluentui/react-persona_v0.0.0-nightly-20221007-1237.1)
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
+
- Bump @fluentui/react-avatar to v0.0.0-nightly-20221007-1237.1 ([commit](https://github.com/microsoft/fluentui/commit/cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec) by beachball)
|
16
|
+
- Bump @fluentui/react-badge to v0.0.0-nightly-20221007-1237.1 ([commit](https://github.com/microsoft/fluentui/commit/cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec) by beachball)
|
17
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20221007-1237.1 ([commit](https://github.com/microsoft/fluentui/commit/cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec) by beachball)
|
18
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20221007-1237.1 ([commit](https://github.com/microsoft/fluentui/commit/cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec) by beachball)
|
19
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20221007-1237.1 ([commit](https://github.com/microsoft/fluentui/commit/cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec) by beachball)
|
20
|
+
|
21
|
+
## [9.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-persona_v9.0.0)
|
22
|
+
|
23
|
+
Mon, 03 Oct 2022 22:24:38 GMT
|
24
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-persona_v9.0.0-alpha.0..@fluentui/react-persona_v9.0.0)
|
25
|
+
|
26
|
+
### Minor changes
|
27
|
+
|
28
|
+
- feat: Publishing package. ([PR #25008](https://github.com/microsoft/fluentui/pull/25008) by esteban.230@hotmail.com)
|
29
|
+
- Bump @fluentui/react-avatar to v9.2.0 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
|
30
|
+
- Bump @fluentui/react-badge to v9.0.7 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
|
31
|
+
|
32
|
+
### Patches
|
33
|
+
|
34
|
+
- docs: Add migration guide. ([PR #25022](https://github.com/microsoft/fluentui/pull/25022) by esteban.230@hotmail.com)
|
35
|
+
|
36
|
+
## [9.0.0-alpha.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-persona_v9.0.0-alpha.0)
|
37
|
+
|
38
|
+
Tue, 20 Sep 2022 20:55:45 GMT
|
39
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-persona_v9.0.0-alpha.0..@fluentui/react-persona_v9.0.0-alpha.0)
|
40
|
+
|
41
|
+
### Patches
|
42
|
+
|
43
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.14 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
|
44
|
+
|
45
|
+
## [9.0.0-alpha.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-persona_v9.0.0-alpha.0)
|
46
|
+
|
47
|
+
Thu, 15 Sep 2022 09:50:08 GMT
|
48
|
+
|
49
|
+
### Patches
|
50
|
+
|
51
|
+
- Bump @fluentui/react-theme to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
52
|
+
- Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
53
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
package/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
@fluentui/react-persona
|
2
|
+
|
3
|
+
Copyright (c) Microsoft Corporation
|
4
|
+
|
5
|
+
All rights reserved.
|
6
|
+
|
7
|
+
MIT License
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
|
+
|
15
|
+
Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
|
package/MIGRATION.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Badge Migration
|
2
|
+
|
3
|
+
## Migration from v8
|
4
|
+
|
5
|
+
v8 offers a component equivalent to v9's `Persona`. However, the API is slightly different. The main difference is that v9's `Persona` does not handle the functionality of the `presence` and `avatar`. Instead, the `presence` and `avatar` are separate components that can be used in conjunction with `Persona`.
|
6
|
+
|
7
|
+
Here's how the API of v8's `Persona` compares to the one from v9's `Persona` component:
|
8
|
+
|
9
|
+
- `className` => `className`
|
10
|
+
- `coinProps` => Use `avatar`'s or `presence`'s slot props
|
11
|
+
- `componentRef` => NOT SUPPORTED - use `ref` instead
|
12
|
+
- `hidePersonaDetails` => Use the `Avatar` component for this case
|
13
|
+
- ```
|
14
|
+
- `imageShouldFadeIn` => NOT SUPPORTED
|
15
|
+
- `isOutOfOffice` => Use the `outOfOffice` prop of the `presence` slot. E.g.: `presence={{ outOfOffice: true }}`
|
16
|
+
- `presence` => Use the `status` prop of the `presence` slot. E.g.: `presence={{ status: 'away' }}`
|
17
|
+
- `presenceTitle` => NOT SUPPORTED
|
18
|
+
- `showOverflowTooltip` => NOT SUPPORTED
|
19
|
+
- `showUnknownPersonaCoin` => NOT SUPPORTED
|
20
|
+
- `styles` => Use style customization through `className` instead
|
21
|
+
|
22
|
+
## Property Mapping
|
23
|
+
|
24
|
+
| v8 `Persona` | v9 `Persona` |
|
25
|
+
| ------------------------ | -------------------------------------- |
|
26
|
+
| `coinProps` | `avatar` or `badge` slot props |
|
27
|
+
| `coinSize` | `size` in the `badge` or `avatar` slot |
|
28
|
+
| `className` | `className` |
|
29
|
+
| `componentRef` | `ref` |
|
30
|
+
| `hidePersonaDetails` | - |
|
31
|
+
| `imageShouldFadeIn` | - |
|
32
|
+
| `isOutOfOffice` | `status` in `presence` slot props |
|
33
|
+
| `optionalText` | `quaternaryText` |
|
34
|
+
| `presence` | `presence` |
|
35
|
+
| `presenceTitle` | - |
|
36
|
+
| `primaryText` | `primaryText` |
|
37
|
+
| `secondaryText` | `secondaryText` |
|
38
|
+
| `showOverflowTooltip` | - |
|
39
|
+
| `showUnknownPersonaCoin` | - |
|
40
|
+
| `styles` | `className` |
|
41
|
+
| `tertiaryText` | `tertiaryText` |
|
42
|
+
| `text` | `name` |
|
package/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# @fluentui/react-persona
|
2
|
+
|
3
|
+
**React Persona components for [Fluent UI React](https://react.fluentui.dev/)**
|
4
|
+
|
5
|
+
## STATUS: WIP 🚧
|
6
|
+
|
7
|
+
These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
To import Persona:
|
12
|
+
|
13
|
+
```js
|
14
|
+
import { Persona } from '@fluentui/react-persona';
|
15
|
+
```
|
16
|
+
|
17
|
+
Once the Persona component graduates to a production release, the component will be available at:
|
18
|
+
|
19
|
+
```js
|
20
|
+
import { Persona } from '@fluentui/react-components';
|
21
|
+
```
|
22
|
+
|
23
|
+
### Examples
|
24
|
+
|
25
|
+
```jsx
|
26
|
+
const PersonaExample = () => {
|
27
|
+
return <Persona name="Kevin Sturgis" secondaryText="Software Engineer" />;
|
28
|
+
};
|
29
|
+
```
|
package/Spec.md
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
# @fluentui/react-persona Spec
|
2
|
+
|
3
|
+
Convergence epic issue: #24213
|
4
|
+
|
5
|
+
## Background
|
6
|
+
|
7
|
+
A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge, or an Avatar with a PresenceBadge. This composite component is not a card, therefore it will not provide a visual board or a popup when the user hovers the Avatar.
|
8
|
+
|
9
|
+
Persona is used in PeoplePicker, Team's left rail and menus, chiclets, and Card.
|
10
|
+
|
11
|
+
## Prior Art
|
12
|
+
|
13
|
+
- OpenUI research: [Avatar/Persona](https://open-ui.org/components/avatar.research)
|
14
|
+
- v7/v8: [link](https://developer.microsoft.com/en-us/fluentui#/controls/web/persona)
|
15
|
+
- > Note: v8's Persona is a combination of v9's Persona and Avatar (v8's Persona has a sub-component PersonaCoin that would count as Avatar, but is not exposed.). In v9 we've taken the approach of having a single component Avatar and another component Persona.
|
16
|
+
- v0: Does not have equivalent component.
|
17
|
+
|
18
|
+
## Anatomy
|
19
|
+
|
20
|
+
![Anatomy](./etc/images/anatomy.png)
|
21
|
+
|
22
|
+
### Avatar, PresenceBadge, and Avatar + PresenceBadge
|
23
|
+
|
24
|
+
v8's Persona has a sub-component `PersonaCoin`, the equivalent in v9 is an Avatar. Currently Avatar is able to display a PresenceBadge, but this behavior will be deprecated in favor of Persona having this behavior.
|
25
|
+
|
26
|
+
Persona has a slot for an `Avatar` and `PresenceBadge`, giving the user the ability to display an Avatar, a PresenceBadge, or Combine them into an Avatar with presence.
|
27
|
+
|
28
|
+
## Sample Code
|
29
|
+
|
30
|
+
![Avatar](./etc/images/avatar.png)
|
31
|
+
|
32
|
+
Persona with Avatar:
|
33
|
+
|
34
|
+
```jsx
|
35
|
+
<Persona name="Kevin Sturgis" secondaryText="Software Engineer" />
|
36
|
+
```
|
37
|
+
|
38
|
+
![PresenceBadge](./etc/images/badge.png)
|
39
|
+
|
40
|
+
Persona with PresenceBadge:
|
41
|
+
|
42
|
+
```jsx
|
43
|
+
<Persona presenceOnly name="Kevin Sturgis" presence={{ status: 'offline', outOfOffice: true }} />
|
44
|
+
```
|
45
|
+
|
46
|
+
![Avatar and PresenceBadge](./etc/images/avatar_badge.png)
|
47
|
+
|
48
|
+
Persona with Avatar + PresenceBadge:
|
49
|
+
|
50
|
+
```jsx
|
51
|
+
<Persona
|
52
|
+
name="Kevin Sturgis"
|
53
|
+
secondaryText="Software Engineer"
|
54
|
+
tertiaryText="Offline"
|
55
|
+
presence={{ status: 'offline', outOfOffice: true }}
|
56
|
+
/>
|
57
|
+
```
|
58
|
+
|
59
|
+
## Variants
|
60
|
+
|
61
|
+
> I will refer to the avatar and presence as content.
|
62
|
+
|
63
|
+
There are three alignment variants:
|
64
|
+
|
65
|
+
- after: Content on the left and text on the right.
|
66
|
+
- below: Content on top and text on the bottom.
|
67
|
+
- before: Content on the right and text on the left.
|
68
|
+
|
69
|
+
There are 3 content variants:
|
70
|
+
|
71
|
+
- Avatar
|
72
|
+
- PresenceBadge
|
73
|
+
- Avatar + PresenceBadge
|
74
|
+
|
75
|
+
There are 2 sizing variants:
|
76
|
+
|
77
|
+
- scaled: When there is no specified size in the props of either `avatar` or `presence`, the content is resized based on the number of text lines used.
|
78
|
+
- fixed: When there is a specified size of either `avatar` or `presence`, the text lines are styled based on the size of the content.
|
79
|
+
|
80
|
+
## API
|
81
|
+
|
82
|
+
**Slots**
|
83
|
+
|
84
|
+
- `root`: The root slot for Persona.
|
85
|
+
- `avatar`: The Avatar to display and Persona's primary slot.
|
86
|
+
- `presence`: The PresenceBadge to display.
|
87
|
+
- `primaryText`: First line of text in Persona. By default its content will be the content of the `name` prop. It is highly encouraged to only use the `name` prop and only specify the content of `primaryText` when it is not a name.
|
88
|
+
- `secondaryText`: Second line of text in Persona.
|
89
|
+
- `tertiaryText`: Third line of text in Persona.
|
90
|
+
- `quaternaryText`: Fourth line of text in Persona.
|
91
|
+
|
92
|
+
**Types**
|
93
|
+
|
94
|
+
```ts
|
95
|
+
export type PersonaSlots = {
|
96
|
+
root: NonNullable<Slot<'div'>>;
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Avatar to display.
|
100
|
+
*/
|
101
|
+
avatar?: Slot<typeof Avatar>;
|
102
|
+
|
103
|
+
/**
|
104
|
+
* PresenceBadge to display.
|
105
|
+
*/
|
106
|
+
presence?: Slot<typeof PresenceBadge>;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* The first line of text in the Persona, larger than the rest of the lines.
|
110
|
+
*
|
111
|
+
* This defaults to the `name` prop, and it is recomended that you only set its value if it should be different from
|
112
|
+
* from the `name` prop.
|
113
|
+
*/
|
114
|
+
primaryText?: Slot<'span'>;
|
115
|
+
|
116
|
+
/**
|
117
|
+
* The second line of text in the Persona.
|
118
|
+
*/
|
119
|
+
secondaryText?: Slot<'span'>;
|
120
|
+
|
121
|
+
/**
|
122
|
+
* The third line of text in the Persona.
|
123
|
+
*/
|
124
|
+
tertiaryText?: Slot<'span'>;
|
125
|
+
|
126
|
+
/**
|
127
|
+
* The fourth line of text in the Persona.
|
128
|
+
*/
|
129
|
+
quaternaryText?: Slot<'span'>;
|
130
|
+
};
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Persona Props
|
134
|
+
*/
|
135
|
+
export type PersonaProps = Omit<ComponentProps<PersonaSlots>, 'badge'> &
|
136
|
+
Pick<AvatarProps, 'name'> & {
|
137
|
+
/**
|
138
|
+
* Whether to display only the presence.
|
139
|
+
*
|
140
|
+
* @default false
|
141
|
+
*/
|
142
|
+
presenceOnly?: boolean;
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Position the text will be rendered in.
|
146
|
+
*
|
147
|
+
* @default after
|
148
|
+
*/
|
149
|
+
textPosition?: 'before' | 'after' | 'below';
|
150
|
+
};
|
151
|
+
```
|
152
|
+
|
153
|
+
## Structure
|
154
|
+
|
155
|
+
To avoid the [issue](https://github.com/microsoft/fluentui/issues/23386) v8 has, a css grid will be used instead of a flexbox that requires a general wrapper and a text container wrapper.
|
156
|
+
|
157
|
+
- _**Internal**_
|
158
|
+
|
159
|
+
```jsx
|
160
|
+
const coin = (
|
161
|
+
<>
|
162
|
+
{!presenceOnly && slots.avatar && <slots.avatar {...slotProps.avatar} />}
|
163
|
+
{presenceOnly && slots.presence && <slots.presence {...slotProps.presence} />}
|
164
|
+
</>
|
165
|
+
);
|
166
|
+
|
167
|
+
return (
|
168
|
+
<slots.root {...slotProps.root}>
|
169
|
+
{(textPosition === 'after' || textPosition === 'below') && coin}
|
170
|
+
{slots.primaryText && <slots.primaryText {...slotProps.primaryText} />}
|
171
|
+
{slots.secondaryText && <slots.secondaryText {...slotProps.secondaryText} />}
|
172
|
+
{slots.tertiaryText && <slots.tertiaryText {...slotProps.tertiaryText} />}
|
173
|
+
{slots.quaternaryText && <slots.quaternaryText {...slotProps.quaternaryText} />}
|
174
|
+
{textPosition === 'before' && coin}
|
175
|
+
</slots.root>
|
176
|
+
);
|
177
|
+
```
|
178
|
+
|
179
|
+
- _**DOM**_
|
180
|
+
|
181
|
+
```html
|
182
|
+
<div class="fui-Persona">
|
183
|
+
<div {/* Avatar, PresenceBadge, or Avatar with PresenceBadge */} />
|
184
|
+
<span class="fui-Persona__primaryText">{/* name */}</span>
|
185
|
+
<span class="fui-Persona__secondaryText">Secondary Text</span>
|
186
|
+
<span class="fui-Persona__tertiaryText">Tertiary Text</span>
|
187
|
+
<span class="fui-Persona__quaternaryText">Quaternary Text</span>
|
188
|
+
</div>
|
189
|
+
```
|
190
|
+
|
191
|
+
## Migration
|
192
|
+
|
193
|
+
See [MIGRATION.md](./MIGRATION.md) for details.
|
194
|
+
|
195
|
+
## Behaviors
|
196
|
+
|
197
|
+
_Explain how the component will behave in use, including:_
|
198
|
+
|
199
|
+
- _Component States_
|
200
|
+
- There are no states for this component, it's a visual representation.
|
201
|
+
- _Interaction_
|
202
|
+
- _Keyboard_
|
203
|
+
- Doesn't receive focus.
|
204
|
+
- _Cursor_
|
205
|
+
- Doesn't interact with cursor.
|
206
|
+
- _Touch_
|
207
|
+
- Doesn't interact with touch.
|
208
|
+
- _Screen readers_
|
209
|
+
- Contents will be read based on dom order.
|
210
|
+
|
211
|
+
## Accessibility
|
212
|
+
|
213
|
+
- There's no need for `aria-*` or/and`role`. Avatar and Badge already accessible and the text labels won't need anything as well.
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
|
3
|
+
import { Avatar } from '@fluentui/react-avatar';
|
4
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
5
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
6
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
7
|
+
import { PresenceBadge } from '@fluentui/react-badge';
|
8
|
+
import * as React_2 from 'react';
|
9
|
+
import type { Slot } from '@fluentui/react-utilities';
|
10
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
|
14
|
+
* or an Avatar with a PresenceBadge.
|
15
|
+
*/
|
16
|
+
export declare const Persona: ForwardRefComponent<PersonaProps>;
|
17
|
+
|
18
|
+
export declare const personaClassNames: SlotClassNames<PersonaSlots>;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Persona Props
|
22
|
+
*/
|
23
|
+
export declare type PersonaProps = ComponentProps<PersonaSlots> & {
|
24
|
+
/**
|
25
|
+
* The name of the person or entity represented by the Persona.
|
26
|
+
*
|
27
|
+
* When `primaryText` is not provided, this will be used as the default value for `primaryText`.
|
28
|
+
*/
|
29
|
+
name?: string;
|
30
|
+
/**
|
31
|
+
* Whether to display only the presence.
|
32
|
+
*
|
33
|
+
* @default false
|
34
|
+
*/
|
35
|
+
presenceOnly?: boolean;
|
36
|
+
/**
|
37
|
+
* The position of the text relative to the avatar/presence.
|
38
|
+
*
|
39
|
+
* @default after
|
40
|
+
*/
|
41
|
+
textPosition?: 'before' | 'after' | 'below';
|
42
|
+
};
|
43
|
+
|
44
|
+
export declare type PersonaSlots = {
|
45
|
+
root: NonNullable<Slot<'div'>>;
|
46
|
+
/**
|
47
|
+
* Avatar to display.
|
48
|
+
*
|
49
|
+
* If a PresenceBadge and an Avatar are provided, the Avatar will display the PresenceBadge as its presence.
|
50
|
+
*/
|
51
|
+
avatar?: Slot<typeof Avatar>;
|
52
|
+
/**
|
53
|
+
* PresenceBadge to display.
|
54
|
+
*
|
55
|
+
* If `presenceOnly` is true, the PresenceBadge will be displayed instead of the Avatar.
|
56
|
+
*/
|
57
|
+
presence?: Slot<typeof PresenceBadge>;
|
58
|
+
/**
|
59
|
+
* The first line of text in the Persona, larger than the rest of the lines.
|
60
|
+
*
|
61
|
+
* This defaults to the `name` prop, and it is recomended that you only set its value if it should be different from
|
62
|
+
* from the `name` prop.
|
63
|
+
*/
|
64
|
+
primaryText?: Slot<'span'>;
|
65
|
+
/**
|
66
|
+
* The second line of text in the Persona.
|
67
|
+
*/
|
68
|
+
secondaryText?: Slot<'span'>;
|
69
|
+
/**
|
70
|
+
* The third line of text in the Persona.
|
71
|
+
*/
|
72
|
+
tertiaryText?: Slot<'span'>;
|
73
|
+
/**
|
74
|
+
* The fourth line of text in the Persona.
|
75
|
+
*/
|
76
|
+
quaternaryText?: Slot<'span'>;
|
77
|
+
};
|
78
|
+
|
79
|
+
/**
|
80
|
+
* State used in rendering Persona
|
81
|
+
*/
|
82
|
+
export declare type PersonaState = ComponentState<PersonaSlots> & Required<Pick<PersonaProps, 'textPosition' | 'presenceOnly'>> & {
|
83
|
+
/**
|
84
|
+
* Whether the sizing type is fixed or not.
|
85
|
+
*/
|
86
|
+
fixed: boolean;
|
87
|
+
/**
|
88
|
+
* The number of text lines used.
|
89
|
+
*/
|
90
|
+
numTextLines: number;
|
91
|
+
};
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Render the final JSX of Persona
|
95
|
+
*/
|
96
|
+
export declare const renderPersona_unstable: (state: PersonaState) => JSX.Element;
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Create the state required to render Persona.
|
100
|
+
*
|
101
|
+
* The returned state can be modified with hooks such as usePersonaStyles_unstable,
|
102
|
+
* before being passed to renderPersona_unstable.
|
103
|
+
*
|
104
|
+
* @param props - props from this instance of Persona
|
105
|
+
* @param ref - reference to root HTMLElement of Persona
|
106
|
+
*/
|
107
|
+
export declare const usePersona_unstable: (props: PersonaProps, ref: React_2.Ref<HTMLElement>) => PersonaState;
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Apply styling to the Persona slots based on the state
|
111
|
+
*/
|
112
|
+
export declare const usePersonaStyles_unstable: (state: PersonaState) => PersonaState;
|
113
|
+
|
114
|
+
export { }
|
package/lib/Persona.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Persona.js","sourceRoot":"","sources":["../src/Persona.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from './components/Persona/index';\n"]}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { renderPersona_unstable } from './renderPersona';
|
3
|
+
import { usePersona_unstable } from './usePersona';
|
4
|
+
import { usePersonaStyles_unstable } from './usePersonaStyles';
|
5
|
+
/**
|
6
|
+
* A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
|
7
|
+
* or an Avatar with a PresenceBadge.
|
8
|
+
*/
|
9
|
+
|
10
|
+
export const Persona = /*#__PURE__*/React.forwardRef((props, ref) => {
|
11
|
+
const state = usePersona_unstable(props, ref);
|
12
|
+
usePersonaStyles_unstable(state);
|
13
|
+
return renderPersona_unstable(state);
|
14
|
+
});
|
15
|
+
Persona.displayName = 'Persona';
|
16
|
+
//# sourceMappingURL=Persona.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Persona/Persona.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AACA,SAAS,mBAAT,QAAoC,cAApC;AACA,SAAS,yBAAT,QAA0C,oBAA1C;AAIA;;;AAGG;;AACH,OAAO,MAAM,OAAO,gBAAsC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EACxF,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAD,EAAQ,GAAR,CAAjC;EAEA,yBAAyB,CAAC,KAAD,CAAzB;EACA,OAAO,sBAAsB,CAAC,KAAD,CAA7B;AACD,CALyD,CAAnD;AAOP,OAAO,CAAC,WAAR,GAAsB,SAAtB","sourcesContent":["import * as React from 'react';\nimport { renderPersona_unstable } from './renderPersona';\nimport { usePersona_unstable } from './usePersona';\nimport { usePersonaStyles_unstable } from './usePersonaStyles';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { PersonaProps } from './Persona.types';\n\n/**\n * A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,\n * or an Avatar with a PresenceBadge.\n */\nexport const Persona: ForwardRefComponent<PersonaProps> = React.forwardRef((props, ref) => {\n const state = usePersona_unstable(props, ref);\n\n usePersonaStyles_unstable(state);\n return renderPersona_unstable(state);\n});\n\nPersona.displayName = 'Persona';\n"],"sourceRoot":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Persona.types.js","sourceRoot":"","sources":["../../../src/components/Persona/Persona.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Avatar } from '@fluentui/react-avatar';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type PersonaSlots = {\n root: NonNullable<Slot<'div'>>;\n\n /**\n * Avatar to display.\n *\n * If a PresenceBadge and an Avatar are provided, the Avatar will display the PresenceBadge as its presence.\n */\n avatar?: Slot<typeof Avatar>;\n\n /**\n * PresenceBadge to display.\n *\n * If `presenceOnly` is true, the PresenceBadge will be displayed instead of the Avatar.\n */\n presence?: Slot<typeof PresenceBadge>;\n\n /**\n * The first line of text in the Persona, larger than the rest of the lines.\n *\n * This defaults to the `name` prop, and it is recomended that you only set its value if it should be different from\n * from the `name` prop.\n */\n primaryText?: Slot<'span'>;\n\n /**\n * The second line of text in the Persona.\n */\n secondaryText?: Slot<'span'>;\n\n /**\n * The third line of text in the Persona.\n */\n tertiaryText?: Slot<'span'>;\n\n /**\n * The fourth line of text in the Persona.\n */\n quaternaryText?: Slot<'span'>;\n};\n\n/**\n * Persona Props\n */\nexport type PersonaProps = ComponentProps<PersonaSlots> & {\n /**\n * The name of the person or entity represented by the Persona.\n *\n * When `primaryText` is not provided, this will be used as the default value for `primaryText`.\n */\n name?: string;\n\n /**\n * Whether to display only the presence.\n *\n * @default false\n */\n presenceOnly?: boolean;\n\n /**\n * The position of the text relative to the avatar/presence.\n *\n * @default after\n */\n textPosition?: 'before' | 'after' | 'below';\n};\n\n/**\n * State used in rendering Persona\n */\nexport type PersonaState = ComponentState<PersonaSlots> &\n Required<Pick<PersonaProps, 'textPosition' | 'presenceOnly'>> & {\n /**\n * Whether the sizing type is fixed or not.\n */\n fixed: boolean;\n /**\n * The number of text lines used.\n */\n numTextLines: number;\n };\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Persona/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './Persona';\nexport * from './Persona.types';\nexport * from './renderPersona';\nexport * from './usePersona';\nexport * from './usePersonaStyles';\n"]}
|