Skip to content

Conversation

@ling1726
Copy link
Contributor

This RFC presents the problem of Avatar reuse when trying to follow design guidelines. Several solutions are proposed along with their pros/cons

PREVIEW

This RFC presents the problem of Avatar reuse when trying to follow
design guidelines. Several solutions are proposed along with their
pros/cons
@ling1726 ling1726 added the Type: RFC Request for Feedback label Sep 14, 2022
@ling1726 ling1726 requested review from a team September 14, 2022 13:04
@github-actions github-actions bot added this to the July Project Cycle Q3 2022 milestone Sep 14, 2022
@fabricteam
Copy link
Collaborator

fabricteam commented Sep 14, 2022

📊 Bundle size report

🤖 This report was generated against 48df172dd62d2bc71409c8cdb3967ea500dcd999

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 14, 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 2feea25:

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

@size-auditor
Copy link

size-auditor bot commented Sep 14, 2022

Asset size changes

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

Baseline commit: c37c8714056e1e021ac7da86ca4bec3428e1953a (build)


- Extra code in base component
- Needs prototyping and investigation
- All avatars under this context will be affected
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to add example with Popover there - an Avatar inside a Popover will have size "20" instead of default one

Copy link
Contributor Author

@ling1726 ling1726 Sep 15, 2022

Choose a reason for hiding this comment

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

As I implemented in the prototype, the choice of slot to apply this context can be more 'intelligent' #24807, and honestly it might not be that bad 🤔

@bsunderhus
Copy link
Contributor

bsunderhus commented Sep 15, 2022

I believe the Shared context would be the best solution described here so far.

Pros

  • We also use context for lots of other user cases - it works
  • Can be targeted to the specific slot that needs these overrides

Cons

  • Extra code in base component ⚠️ (Minimal extra code, not even enough to consider this as an actual con IMO)
  • Needs prototyping and investigation (feat: Implement shared AvatarContext #24807)
  • If the slot is not specific enough -> all avatars under this context will be affected (that's a valid real problem)
  • This might not scale - AvatarContext, IconContext... (Honestly, definitely a painful to have to define every single edge case on an upper context, but still... it works)

@Hotell Hotell requested a review from marcosmoura September 15, 2022 12:13
- Cannot ship design updates i.e. users will need to upgrade all usages if design decides that "64px" will be new size
- Extra work for users

### Style override
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we considered the usage of CSS variables for the style overrides proposal? This solves the "Does not handle props" con. If the size prop of the avatar adds styles with the CSS variable, it'll have priority over the overriden style by the Table.

A con to this approach is to document well the CSS variable.

Copy link
Contributor Author

@ling1726 ling1726 Sep 15, 2022

Choose a reason for hiding this comment

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

The problem with style overrides (I tried it this morning) is that for Avatar the size actually controls multiple css properties:

  • width
  • height
  • icon slot size
  • font size
  • font weight

I don't think a single css var will actually help and it's a problem that @behowell highlighted offline during tech sync. Furthermore, if designers decide to update the styles with size, it's harder to know what properties to have to update

ling1726 added a commit to ling1726/fluentui that referenced this pull request Sep 27, 2022
ling1726 added a commit that referenced this pull request Sep 27, 2022
@layershifter
Copy link
Member

layershifter commented Sep 29, 2022

I am for the React context option 👍

@ling1726 ling1726 enabled auto-merge (squash) September 29, 2022 15:57
@github-actions github-actions bot removed this from the July Project Cycle Q3 2022 milestone Sep 29, 2022
@ling1726 ling1726 merged commit cdd0445 into microsoft:master Sep 29, 2022
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
* RFC: Reusing Avatar in other components

This RFC presents the problem of Avatar reuse when trying to follow
design guidelines. Several solutions are proposed along with their
pros/cons

* update

* update

* Update rfcs/react-components/convergence/reusing-avatar-in-components.md

Co-authored-by: Oleksandr Fediashov <[email protected]>

* add prototype implemenentation of context solution

* update code sample

* update preferred solution

Co-authored-by: Oleksandr Fediashov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: RFC Request for Feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants