Skip to content

docs(react-persona): Adding Persona spec#24436

Merged
sopranopillow merged 13 commits intomicrosoft:masterfrom
sopranopillow:persona/spec
Sep 28, 2022
Merged

docs(react-persona): Adding Persona spec#24436
sopranopillow merged 13 commits intomicrosoft:masterfrom
sopranopillow:persona/spec

Conversation

@sopranopillow
Copy link
Contributor

@sopranopillow sopranopillow commented Aug 19, 2022

This is the initial spec, I would love some feedback!

Preview

fixes: #24237

@fabricteam
Copy link
Collaborator

fabricteam commented Aug 19, 2022

📊 Bundle size report

🤖 This report was generated against 94a5fdd63f23649e1a0d1e7c3bcaf7d3226386e3

@size-auditor
Copy link

size-auditor bot commented Aug 19, 2022

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 94a5fdd63f23649e1a0d1e7c3bcaf7d3226386e3 (build)

@sopranopillow sopranopillow mentioned this pull request Aug 19, 2022
22 tasks
@sopranopillow sopranopillow requested review from a team August 19, 2022 21:19
@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 22, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 90da9d2:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

Comment on lines +126 to +129
- `primaryText`: Primary text, this is the only required slot. I decided to have at least this slot required since it doesn't make sense to have just the coin without the text. ⚠️ Open to feedback though.
- `secondaryText`: Secondary text, if provided.
- `tertiaryText`: Tertiary text, if provided.
- `quaternaryText`: Quaternary text, if provided.
Copy link
Member

@layershifter layershifter Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Persona as a name is opinionated (compared even to ItemLayout), are there reasons no not use semantic naming like title, description, etc.?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. As the slots can accept a breaadcrumbs component in the future, it seems a bit odd to pass it to a primaryText slot for example.

Copy link
Contributor Author

@sopranopillow sopranopillow Aug 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to go with Persona over EntityLayout due to Entity/Item being too generic. Persona layout gives a little of context on what to expect of the component and is more familiar since v8 has the same name. For the semantic naming, there's no big reason. Though changing it to description, for example, would make it weird if a breadcrumb is used instead of simple text.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to go with Persona over EntityLayout due to Entity/Item being too generic.

But we use too generic *text slots then 😸 IMO as we went with more semantic name (Persona) it's better to use semantic names for slots. description was just an example, feel free to suggest/use own options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about primarySlot, secondarySlot, ...? I feel like primary, secondary, and so on should be kept, but I do agree that Text won't work. Especially if we want to use breadcrumbs and such.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sopranopillow this component looks very similar to https://react.semantic-ui.com/views/item/#types-props. You can consider to grab some naming ideas from there, for example header, meta, extra.

@sopranopillow sopranopillow requested review from a team, layershifter and smhigley and removed request for a team August 30, 2022 21:54
Comment on lines +126 to +129
- `primaryText`: Primary text, this is the only required slot. I decided to have at least this slot required since it doesn't make sense to have just the coin without the text. ⚠️ Open to feedback though.
- `secondaryText`: Secondary text, if provided.
- `tertiaryText`: Tertiary text, if provided.
- `quaternaryText`: Quaternary text, if provided.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. As the slots can accept a breaadcrumbs component in the future, it seems a bit odd to pass it to a primaryText slot for example.

- PersonaAvatar
- Image

PersonaPresenceBadge, PersonaIcon, and PersonaAvatar are needed for the sizing behavior. PersonaContextProvider is provided by Persona and then consumed by these sub-components to update the persona's media state. This media state allows Persona to correctly style the text slots based on the media's type and size. See API section for more details on the context structure.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying it 👍

I am wondering if PersonaIcon is really needed:

function App() {
  return (
    <>
      {/* We can't apply sizing to sized icons */}
      <Persona media={< AccessTime24Filled />} />
      {/* For unsized we can specify `fontSize` to scale them */}
      <Persona media={< AccessTimeFilled />} />
    </>
   )
}

WDYT about it?


@ling1726 AFAIR you mentioned a similar problem with Avatar & Table sizing. Did you figure out a solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main thing PersonaIcon does is to add a font size and let Persona know that the media is an icon. If we were to remove PersonaIcon, we then drop support of the sizing styles for icons as well. Only Avatars and PresenceBadges would have the sizing behavior.

I think adding a disclaimer about sized icons vs non-sized icons would be better in this case. I think it's worth having the sizing functionality for the icons if possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main thing PersonaIcon does is to add a font size and let Persona know that the media is an icon. If we were to remove PersonaIcon, we then drop support of the sizing styles for icons as well

Can we specify fontSize in styles for media slot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that's the case, I still need to know if the media type is an icon. While I could size it with a selector like & > svg, I still need to know that it's an icon to size the text lines correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that's the case, I still need to know if the media type is an icon. While I could size it with a selector like & > svg, I still need to know that it's an icon to size the text lines correctly.

Sorry, but I didn't get why... Is something except avatar, image, badge and icon can be specified in media slot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the possible types the media slot can have are: images, avatars, badges, and icons.

The problem is mainly that whenever an icon is used, we need to support the fixed and scaled sizing. To support the fixed sizing I need to know the icon size so I can set the correct styles for the text slots. This is the main problem since to be able to know the icon size I need to use PersonaContext to let persona know the size of the icon.

For the scaled sizing, it's easier since as you mentioned I could just add the fontSize directly to the media slot, but what keeps us from doing this is the scaled size.

One option we could do is do the same to icon as we are doing with image and let the user deal with the sizing and just have a general size for icons. While I think it's worth having the PersonaIcon, I also think that not being able to fully control the icon's size might set wrong expectations on what PersonaIcon can do. I can talk to design about only supporting the sizing prop for Avatar and PresenceBadge. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think?

TBH I am a bit lost at this point and it will be easier for me to understand the implementation. Will it be okay to keep going as it is for now and then follow up on this based on the implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll merge this PR #24704 and make a draft PR with the implementation! Sorry for the confusion, but I agree that it'll all make sense in the Implementation.

Copy link
Contributor Author

@sopranopillow sopranopillow Sep 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@layershifter one last major change, I swear 😥😥 I've updated the spec to reflect a discussion we had offline. The new trajectory of this component will be to have a strict persona that aligns with v8's persona for partners. This will ensure that we have the same persona across products.

For the extra functionality that included images, icons and other content, we are exploring two options but leaning towards option 1:

  1. We will add a recipes section to the docs and give guidance on building a media object with the components we currently have.
  2. We will provide building blocks for a MediaObject and make it flexible for the user.

Thanks so much for being attentive to this PR and I really appreciate all the feedback you've provided!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but it does not seem to be aligned with the spec in Figma. Complicating usage for images/icons does not seem for like a futureproof approach 🤔


IMO the latest changes also return the problem with priorities and mutually exclusive slots:

<Persona
  avatar={{ name: 'Kevin Sturgis', badge: { status: 'online' } }}
  presence={{ status: 'offline', outOfOffice: true }}
 />

For me, it's the same case as appearance with Button: we don't want users to do <Button secondary primary />, so we have <Button appearance="primary" />. This follows the principle "do the right thing by default".

/**
* A button can have its content and borders styled for greater emphasis or to be subtle.
* - 'secondary' (default): Gives emphasis to the button in such a way that it indicates a secondary action.
* - 'primary': Emphasizes the button as a primary action.
* - 'outline': Removes background styling.
* - 'subtle': Minimizes emphasis to blend into the background until hovered or focused.
* - 'transparent': Removes background and border styling.
*
* @default 'secondary'
*/
appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent';

@ling1726 ling1726 added the Type: Spec Component spec PR label Sep 14, 2022
sopranopillow and others added 3 commits September 16, 2022 15:22
Co-authored-by: Ben Howell <48106640+behowell@users.noreply.github.com>
Co-authored-by: Ben Howell <48106640+behowell@users.noreply.github.com>
Copy link
Contributor

@behowell behowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for making all the updates!


- _Migration from v8_
- _Migration from v0_
See [MIGRATION.md](./MIGRATION.md) for details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like MIGRATION.md exists yet. Do you plan to add it in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I was planning on adding it with this issue: #24956

@sopranopillow sopranopillow merged commit 0f74ad4 into microsoft:master Sep 28, 2022
@sopranopillow sopranopillow deleted the persona/spec branch September 28, 2022 17:03
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
* docs: Adding Persona spec.

* Adding requested changes

* adding requested changes

* adding requested changes

* adding sub-component explanation

* adding more disclaimers

* updating spec to only include a simple persona

* Removing responsive part

* updating position prop

* adding requested changes

* Update packages/react-components/react-persona/Spec.md

Co-authored-by: Ben Howell <48106640+behowell@users.noreply.github.com>

* Update packages/react-components/react-persona/Spec.md

Co-authored-by: Ben Howell <48106640+behowell@users.noreply.github.com>

* adding requested changeS:

Co-authored-by: Ben Howell <48106640+behowell@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persona: Write up spec

8 participants