Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

ui-components: Avatar #48

Merged
merged 3 commits into from
May 26, 2020
Merged

Conversation

koorosh
Copy link
Contributor

@koorosh koorosh commented May 6, 2020

ui-components // Avatar

Issue #22

  • Includes base implementation of component which includes
    the ability to modify intent, size, disable, and set selectable props
    to component.
  • It is a starting point to extend this implementation for more
    custom representations as StepAvatar and Validation which require
    customization of styles.
  • Storybook is updated with one more story to show component in different
    states, it is a draft version to validate current implementation only.

Checklist

  • I have written or updated test for the changes I made
  • I have updated the README of the package I'm working in to reflect my changes
  • I have added or updated Storybook if appropriate for my changes

@koorosh koorosh changed the title ui-components: Avatar component ui-components: Avatar May 6, 2020
@koorosh koorosh force-pushed the avatar-component branch from 0740bd8 to 89a557f Compare May 6, 2020 12:32
Copy link
Contributor

@j-low j-low left a comment

Choose a reason for hiding this comment

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

Looking great so far @koorosh! I'm still working on the TS integration so I couldn't pull this down to test live (since it currently breaks); I may have more feedback at that point but there are a few items in here that can be addressed.

onClick?: () => void;
}

export type AvatarSize = "16" | "24" | "32" | "40";
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer we use t-shirt sizing; something like: export type AvatarSize = "s" | "m" | "l" | "xl";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, 👍🏽 the only thing, I would start from "xs" as the smallest one for 16px.

@@ -0,0 +1,89 @@
import React from "react";
import { shallow } from "enzyme";
Copy link
Contributor

Choose a reason for hiding this comment

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

@laurenbarker not an issue for this PR, but given the favorable reception of React Testing Lib, would you be onboard if I create an issue to migrate over from Enzyme?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Was thinking the same thing! Created one this morning #49

align-items: center;
justify-content: center;
flex-shrink: 0;
font-family: Source Sans Pro, sans-serif; // TODO (koorosh): replace with fonts from tokes
Copy link
Contributor

Choose a reason for hiding this comment

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

flagging to update

Comment on lines 3 to 7
@mixin selectable-border($n) {
box-sizing: border-box;
border: 2px solid $n;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it would be a good candidate to be added to our tokens, probably with a default color value. It might not be the right time to do so now (i.e. when we have more use cases) but let's add a TODO comment above this to call it out.

Also the let's make var name something descriptive; for example $color... $n has connotations with mathematics as relating to an integer count value so it makes it slightly (though not fatally) confusing.


.intent-info {
background: $crl-blue-1;
color: $crl-blue-3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wherever possible (or unless there's a specific reason not to do so) let's refer to the base aliases, in this case $crl-base-blue. The reason being the base aliases will be the most common colors seen in the codebase and, conversely, the explicit numerical values should be uncommon enough to call themselves out as a idiosyncratic use case when they do show up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha!

}

&.intent-info {
@include selectable-border($crl-blue-3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment re: base colors from above applies here too.

}

&.intent-warning {
@include selectable-border($crl-yellow-4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Our warning color is $crl-base-yellow/$crl-yellow-3; comment re: base colors from above applies here too.

}

&.intent-danger {
@include selectable-border($crl-red-4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Our warning color is $crl-base-red/$crl-red-3; comment re: base colors from above applies here too.

Comment on lines 52 to 57
Avatar.defaultProps = {
size: "40",
intent: "default",
selectable: false,
disabled: false,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as setting default props, I kind of like this pattern here but I know in other places we've specified them in function signature itself. @laurenbarker do you have an opinion on this at all?

Copy link
Collaborator

Choose a reason for hiding this comment

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

defaultProps is deprecated for function components (facebook/react#16210) which is why we decided to go with default parameters elsewhere.

@koorosh koorosh force-pushed the avatar-component branch 2 times, most recently from 158a389 to cb27604 Compare May 7, 2020 10:45
@koorosh koorosh requested a review from j-low May 8, 2020 10:32
j-low
j-low previously requested changes May 12, 2020
Copy link
Contributor

@j-low j-low left a comment

Choose a reason for hiding this comment

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

Just the one issue re: orange vs. yellow and updating intent labels but otherwise looks great

@celiala celiala linked an issue May 12, 2020 that may be closed by this pull request
@koorosh koorosh force-pushed the avatar-component branch from cb27604 to 43e96ac Compare May 12, 2020 18:23
@koorosh koorosh requested a review from j-low May 12, 2020 18:26
@koorosh koorosh force-pushed the avatar-component branch from 43e96ac to a7c6146 Compare May 12, 2020 22:36
@koorosh
Copy link
Contributor Author

koorosh commented May 12, 2020

Just the one issue re: orange vs. yellow and updating intent labels but otherwise looks great

Fixed!

@nathanstilwell nathanstilwell added the ✨ candidate-component A component to either reduce duplication or provide planned functionality across applications. label May 18, 2020
Copy link
Contributor

@nathanstilwell nathanstilwell left a comment

Choose a reason for hiding this comment

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

LGTM.

selectable = false,
onClick,
}) => {
const classnames = useMemo(
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the use of useMemo here 👍

@nathanstilwell nathanstilwell dismissed j-low’s stale review May 19, 2020 20:12

The requested change was made.

@Annebirzin
Copy link
Collaborator

@koorosh Rachel and I were able to review the avatar component and had some feedback:

  • force the text to be all-caps (no lowercase)
  • the font weight 600 doesn't look bold as it does in Figma, is there an issue there?
  • Remove the Small avatar size (24 x24). We decided the use case for this size outlined in avatars & badges section of design system is not an avatar but more of a step component like seen in ant design. Will update the component in Figma to remove the 24x24 and 16x16 size.

koorosh added 2 commits May 22, 2020 12:28
- Includes base implementation of <Avatar> component which includes
ability to modify intent, size, disable, and set selectable props
to component.
- It is a starting point to extend this implementation for more
custom representations as StepAvatar and Validation which require
customization of styles.
- One more story is added to show <Avatar> component in different
states, it is draft version to validate current implementation only.
Avatar component has to be forced to display text with upper-case.

Added `transformCase` prop with the same styles
as in `Badge` component to follow the same styles.
@koorosh koorosh force-pushed the avatar-component branch from a7c6146 to 407133a Compare May 22, 2020 10:26
Avatar component sizing is changed to have only
two options: default and small sizes.
Very small sizes are removed (xs, and s sizes)

Also size naming are changed to reflect that only two
options are available for now.
@koorosh
Copy link
Contributor Author

koorosh commented May 22, 2020

@koorosh Rachel and I were able to review the avatar component and had some feedback:

  • force the text to be all-caps (no lowercase)
  • the font weight 600 doesn't look bold as it does in Figma, is there an issue there?
  • Remove the Small avatar size (24 x24). We decided the use case for this size outlined in avatars & badges section of design system is not an avatar but more of a step component like seen in ant design. Will update the component in Figma to remove the 24x24 and 16x16 size.

@Annebirzin , thanks for your feedback!
Following changes were made:

  • By default, text transformed to upper-case. It uses the same logic as Badge component where user still have an option to explicitly indicate to keep text with original casing.
  • Double checked font weights, it is 600 and has all the same styles as Figma designs.
  • Only two sizes are left (40px and 32px)

@Annebirzin
Copy link
Collaborator

thanks @koorosh!

@koorosh koorosh merged commit 2181a15 into cockroachdb:master May 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✨ candidate-component A component to either reduce duplication or provide planned functionality across applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avatar Component
5 participants