Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Avatar] Add shape parameter #6103

Merged
merged 11 commits into from Jun 16, 2022
Merged

Conversation

clarkjennings
Copy link
Contributor

WHY are these changes introduced?

Add a way to create a square shaped Avatar for plus stores in Plus Admin Migration
Related to Businesses issues #1391 and #1392.

WHAT is this pull request doing?

Add an optional parameter "shape" to the Avatar component. Defaults to round for no change in behavior or appearance. If square is supplied instead, the Avatar will have a 2px border-radius instead of 50%, resulting in a square shape with slightly rounded corners.

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

export function Playground() {
  return (
       <Page title="Playground">
      {/* Add the code you want to test in here */}
      <Avatar
        name={"Shop 1"}
        initials={"S1"}
        shape='square'
      />
    </Page>
  );
}

馃帺 checklist

@ghost
Copy link

ghost commented Jun 10, 2022

馃憢 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven鈥檛 already, please check out the contributing guidelines.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 10, 2022

size-limit report 馃摝

Path Size
polaris-react-cjs 196.83 KB (+0.04% 馃敽)
polaris-react-esm 132.14 KB (+0.05% 馃敽)
polaris-react-esnext 187.81 KB (+0.05% 馃敽)
polaris-react-css 42.16 KB (+0.04% 馃敽)

@kyledurand
Copy link
Contributor

Comparing this to the screenshot from slack it looks like there's some additional type treatment that's missing here:

image

@clarkjennings
Copy link
Contributor Author

Comparing this to the screenshot from slack it looks like there's some additional type treatment that's missing here:

image

Great eye! I think i've got it fixed. Thanks!

.changeset/yellow-worms-behave.md Outdated Show resolved Hide resolved
polaris-react/src/components/Avatar/Avatar.tsx Outdated Show resolved Hide resolved
clarkjennings and others added 2 commits June 15, 2022 09:47
Copy link
Contributor

@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.

Looking good 馃憤 Just watch out for the spacing issue I pointed out. I'm thinking this could use a test as well. Something like:

describe('shape', () => {
  it('renders a square background when square is passed to shape', () => {
    const avatar = mountWithApp(<Avatar initials="DL" shape="square" />);

    expect(avatar).toContainReactComponent('span', {
      className: expect.stringContaining('shapeSquare'),
    });
  });
});

@@ -96,6 +104,7 @@ export function Avatar({
size && styles[variationName('size', size)],
!customer && styles[variationName('style', styleClass(nameString))],
hasImage && status === Status.Loaded && styles.imageHasLoaded,
shape && styles[variationName('shape',shape)],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
shape && styles[variationName('shape',shape)],
shape && styles[variationName('shape',shape)],

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.

This looks great @clarkjennings!! 馃檶馃徑 Just had a question of the recommended context to use square vs round in the Admin. Thank you for contributing!! 馃帀

.changeset/yellow-worms-behave.md Outdated Show resolved Hide resolved
@@ -115,6 +115,14 @@ function ExtraSmallAvatarExample() {
}
```

### Square avatar

Use to present a square shaped for a merchant, customer, or business.
Copy link
Member

@chloerice chloerice Jun 15, 2022

Choose a reason for hiding this comment

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

Is this the shape we want avatars to be going forward when representing all merchants (and their staff?) once unified Admin launches? Or is this just for Plus merchants?

Suggested change
Use to present a square shaped for a merchant, customer, or business.
Use a `square` `shape` when the avatar represents the merchant.

@clarkjennings clarkjennings merged commit a622544 into main Jun 16, 2022
@clarkjennings clarkjennings deleted the business/square-avatar-for-shops branch June 16, 2022 18:01
@ghost
Copy link

ghost commented Jun 16, 2022

馃帀 Thanks for your contribution to Polaris!

@github-actions github-actions bot mentioned this pull request Jun 16, 2022
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.

None yet

4 participants