Skip to content

Conversation

@omar-sr88
Copy link
Contributor

WHY are these changes introduced?

I work in Vault Tools and recently with the launch of Debrief the need for a new Avatar sizing came up.
In section Prototypes being reviewed in (exhibit A) we use an Avatar size of 24px to condense the list and reduce whitespace.
Screen Shot 2021-08-05 at 10 12 11 AM

The Avatar small size has the following result (exhibit B).
Screen Shot 2021-08-05 at 10 16 38 AM

Our designer, @ChrisHS, has also envisioned smaller avatar for single line text components (exhibit C)

128158697-1f8e8004-3015-48c9-8d91-44c53c76abb6

Opening this contribution to extend applications of Avatar

WHAT is this pull request doing?

  1. Adds a new css variable for the extrasmall size at 24px
  2. Created the .sizeExtraSmall css class and added an extra min-width so it doesn't affect the base value for that attr (currently $sizeSmall)
  3. Added extraSmall to Size prop

Sizes for comparrison
Screen Shot 2021-08-09 at 11 54 36 AM

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Copy-paste this code in playground/Playground.tsx:
import React from 'react';
import {Page} from '../src';

export function Playground() {
  return (
     <Page title="Playground">
      <Avatar size="extraSmall" initials="XS" />
      <Avatar size="small" initials="SM" />
      <Avatar initials="MD" />
      <Avatar size="large" initials="LG" />
    </Page>
  );
}

Additional question:

  • While testing with initials I saw that the Avatar component does not do any sort of control on that prop. It is clearly designed to handle 2 letters, but if for some reason someone enters 3+ this starts happening:

Screen Shot 2021-08-09 at 12 06 20 PM

I wonder if we shouldn't have some extra check or control for that. Added a 2nd commit with a suggestion to always crop initials to the first and last in case more than 2 characters are present. It was an arbitrary choice, btw.

Screen Shot 2021-08-09 at 1 21 48 PM

🎩 checklist

@omar-sr88 omar-sr88 requested a review from kyledurand August 9, 2021 17:24
@ghost
Copy link

ghost commented Aug 9, 2021

👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2021

size-limit report

Path Size
cjs 142.52 KB (+0.01% 🔺)
esm 96.28 KB (+0.01% 🔺)
esnext 139.47 KB (+0.02% 🔺)
css 33.75 KB (+0.02% 🔺)

Copy link
Member

@kyledurand kyledurand left a comment

Choose a reason for hiding this comment

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

This looks good just a couple of questions. Can you also add an example for extra small in the avatar readme?

And don't forget to add to UNRELEASED.md

@omar-sr88
Copy link
Contributor Author

Can you also add an example for extra small in the avatar readme?

I've got the UNRELEASED.md updated and wanted to ask about the Best practices section of the README.md

I can add the example, but I don't have a best practice direction to go with.
Eg:

 Extra small (24 x 24 px): use when small size is too big
 Small (32 × 32 px): use when the medium size is too big for the layout, or when the avatar has less importance

@omar-sr88 omar-sr88 force-pushed the avatar-extra-small branch 3 times, most recently from 87fbe4c to 8808589 Compare August 9, 2021 17:48
@omar-sr88 omar-sr88 force-pushed the avatar-extra-small branch from 8808589 to f0681d2 Compare August 9, 2021 17:49
@omar-sr88 omar-sr88 marked this pull request as ready for review August 17, 2021 14:59
@omar-sr88 omar-sr88 changed the title [WIP] [Avatar] Add new sizing 'extra-small' [Avatar] Add new sizing 'extra-small' Aug 17, 2021
Copy link
Member

@chloerice chloerice left a comment

Choose a reason for hiding this comment

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

🚀 :shipit:

@omar-sr88 omar-sr88 merged commit a2e422c into main Aug 18, 2021
@omar-sr88 omar-sr88 deleted the avatar-extra-small branch August 18, 2021 13:54
@ghost
Copy link

ghost commented Aug 18, 2021

🎉 Thanks for your contribution to Polaris React!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants