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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Avatar stack #385

Merged
merged 35 commits into from
Nov 14, 2017
Merged

New Avatar stack #385

merged 35 commits into from
Nov 14, 2017

Conversation

sophshep
Copy link

@sophshep sophshep commented Oct 27, 2017

This PR is the start of adding @califa's updated Avatar Stack pattern to Primer.

Here is what I've done so far:

  • I copied the CSS from @califa's newest PR branch in github/github.
  • Renamed from .temp-avatar-stack to .AvatarStack so that this is all ready to switch over to our new naming convention. I'm leaving the existing CSS for avatar-stack so that nothing breaks during testing, but eventually we should 🔥 that class.
  • Added .AvatarStack to Storybook
  • Refactored the component in isolation and removed any CSS that wasn't necessary (mostly in this commit: f0393d7)

What's next?

  • Test this style in GitHub using the alpha release
  • Update docs
  • Incorporate updates to tooltips so that we don't need the temp-tooltipped-align-left class in here
  • Delete old avatar-stack from CSS & docs
  • Add comment to this pr with a brief (one sentence) description of the changes, for inclusion in the Changelog (don't edit the changelog in this pr as it will cause conflicts with v10)

/cc @primer/ds-core @califa

@califa
Copy link
Contributor

califa commented Nov 1, 2017

Hey, I've updated this PR in some ways:

  • The avatar stack's expanded state is now absolutely positioned as intended on this PR. I think this should be carried over to any other app/area that uses avatar stacks, so I've included it here.
  • I've added a wrapper around the absolute div so that its initial state interacts with the content around it. This wrapper is now the AvatarStack and the absolute div is AvatarStack-body
  • I've added classes to tell the container what width it needs to be based on the # of avatars.
    • The current naming scheme is AvatarStack--2 and --3 but I'm not married to this.
    • These classes need to be added manually (or automatically in the markup).
    • The specific widths are based on how the avatar stack appears visually next to adjacent content. They're hard coded, but there's no reason they'll ever have to change.
  • The background is now set to $bg-white so when expanded you can't see content through it. This can be overridden if needed in individual apps.

The PR I mentioned above updates things on the github/github side. It gets rid of most of the css, and only leaves some app-specific styles.

The team is looking to ship multiple attribution in about two weeks, so it'd be nice to get it into Primer before then 🙌

Copy link
Author

@sophshep sophshep left a comment

Choose a reason for hiding this comment

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

Left some questions & thoughts!


// Temp tooltip class to position it correctly

.temp-tooltipped-align-left {
Copy link
Author

Choose a reason for hiding this comment

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

Could we take this out of this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 I can leave this in the temporary github/github css for now.

@@ -43,3 +43,114 @@
}
}
}
Copy link
Author

Choose a reason for hiding this comment

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

I left avatar-stack in here when I started the PR to prevent breaking anything, but ideally we could take it out of Primer in favor of the refactored/redesigned component. Could we take it out here (and in replace it in github/github)?

Copy link
Contributor

Choose a reason for hiding this comment

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

We definitely could (and should!), but I don't think that's feasible by tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

Hey @califa we need to update all the instances of avatar in GitHub for this to ship. As I understand it, this pattern is to replace the current avatar stack, which means we need to ensure this pattern works everywhere it's being used. The best way to test this is to update the locations where this is being used. If you can't do that in time for v10 release, or you need help with that, then we'll need to discuss whether to pull it out of v10 or delay it by a few days. I'd prefer to get it into v10 because I think these changes will require a major release and I don't really want to do v11 straight after v10.

For clarity on timeline, we want all v10 pr's merged in eod tomorrow, so that we can do a naming change on Monday and test, and then intend to ship Monday or Tuesday depending on how long it takes to test.

Copy link
Contributor

Choose a reason for hiding this comment

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

@broccolini 👍 talked to @sophshep. I'm spending all day on this today.

min-width: 36px;
}

&.AvatarStack--3 {
Copy link
Author

Choose a reason for hiding this comment

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

We should avoid using numerals in class names since they have the potential to be confused with spacer variables.

The two variations for avatar stack component are 2 avatars and ≥3 avatars, right? If so, I'd suggest the following:

  • Default .AvatarStack is for two (with width: 36px)
  • There is a modifier for when a stack has more than two items, called .AvatarStack--more. Since the avatar-more div always needs to be used in stacks with ≥3 items, that could be built into this class. This will lead to cleaner markup, which will reduce the chances of the component being implemented incorrectly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think AvatarStack--more would work, though. Everywhere avatar stacks are currently being used (notifications, projects, commit authors), there is often a single avatar.

If avatar stacks had a 2 avatar minimum, we'd have to implement logic every time we used this component to decide whether to use single avatar markup or a stack (as well as make sure the single avatar had the exact same styles/tooltips/etc to match its surrounding avatar stacks). That feels like a bad tradeoff for cleaner markup to me.

We could possibly use AvatarStack--more and AvatarStack--one for these cases, but making the default 2 avatars feels a bit arbitrary. What do you think?

I don't want to create confusion and I'm very open to using different class names, though. Any ideas?

Copy link
Member

Choose a reason for hiding this comment

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

@sophshep @califa and I discussed this in slack and we came to the conclusion that AvatarStack--two and AvatarStack-three-plus is the best solution we can think of!

}
}

.AvatarStack-body {
Copy link
Author

Choose a reason for hiding this comment

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

I'm curious to have @broccolini weigh in here about .AvatarStack as the containing div that .AvatarStack-body is positioned absolutely within.

I spoke to @califa briefly on slack about this and he said that this component will always need to be positioned this way in order to interact with its surroundings as intended. This does, however, go against the principle of "separate container and content" and has the potential to lead to some unnecessary overrides in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sophshep I think this might actually align with that principle.

Separate container and content: Essentially, this means “rarely use location-dependent styles”. A component should look the same no matter where you put it.

If we treat the container as part of the component as we're doing here, then it won't be location dependent. It'll always appear/behave exactly the same no matter where we put it.

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.

I've updated AvatarStack to apply position: absolute; to AvatarStack-body so that it partially addresses mine and @sophshep's concern's (above) re tying the positioning into this component (but not entirely since you have width in the block class).

@califa - might be good if we have a longer discussion in person about our principles, I'd like to ensure they make sense to everyone and I understand how they might be interpreted differently. We haven't really updated them since we first started the design systems team, and I want to review and iterate on them, and ensure they tie back to product design principles so that we can use them as a framework to make decisions on both design and code more easily.

To be honest I expect we'll need to iterate on AvatarStack(like many things). We want to move to more consistent usage around width and height values so they would point to variables or use utilities, have more layout objects (incl. starting to use CSS grid), and I think we'll have other components that will require this same "stack" treatment than just avatars. But I'm fine with this shipping in the interest of having this for your feature, and it will give us an opportunity to test the new version out.

@sophshep sophshep changed the title [WIP] New Avatar stack New Avatar stack Nov 3, 2017
@broccolini
Copy link
Member

Hey folks, I've been thinking about this over the weekend following Friday's discussion with @sophshep @califa. I thought of a way we can pull this out of v10 without putting pressure on our team to do a v11 release earlier than planned. It occurred to me we can ship the avatar stack update in a follow-up minor release (rather than major) because we have different class names for the new styles. This enables us to add a deprecation warning for the old class names when this is ready to be released, and keep that deprecation warning until we're ready to do a new major release and remove the old styles.

Considering all the risks for trying to include this in v10—between stress some folks are feeling, that there is more work still to be done, and reviews needed—I think we should pull avatar stack updates out of the v10 release, and ship in a follow-up minor release with the deprecation warning.

What does this mean in the context of github/github?

When we pull in the minor release with both the old and new styles, we'll see a deprecation warning when we install, but that won't be good prevention at hubbers using instances of the old styles. We need to look into other methods to warn people not to use soon-to-be-deprecated styles anyway, so we'll make that a priority after v10 ships so that we can hopefully come up with something in time for the avatar stack ship. cc @jonrohan who will likely be the person actually writing the scripts.

Why didn't you suggest this earlier?

Initially my concern was having to rush a v11 release or ship one without anything much in it, if the avatar-stack changes didn't make it into v10. But we can avoid that problem with the deprecation warning. We only recently introduced the deprecation warning which was the first part of figuring out what our process should be—basically we're still learning what works best, what we need to do, and what's possible (with 2 people and limited time). We are also still figuring out a good cadence for releases—this is our first major release after doing a string of releases for the new publishing flow, so we're also still learning what's best for our release process. If it's any consolation, the v10 release is proving to be a great learning experience, so following releases and documentation around process should provide more clarity.

Next steps

  • Confirm folks are on board with this proposal, cc @califa @sophshep @jonrohan
  • Confirm timeline for when @califa's team needs this to be shipped (in about 2 weeks I believe), work back from there and prioritize what needs to be done.

I will also be reviewing what else we have on the list for v10 with @jonrohan on Monday, and prioritize what should go into v10 vs a follow-up minor release. I'll write that up and share with everyone currently contributing on Monday for feedback.

@califa
Copy link
Contributor

califa commented Nov 6, 2017

@broccolini Thanks for putting this together! I'm comfortable with this as long as we can definitely hit my team's ship deadline (you're correct about the 2 weeks, I'll get you an exact date tomorrow). I'm free to start working on the changes tomorrow :)

Copy link
Member

@broccolini broccolini left a comment

Choose a reason for hiding this comment

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

Suggested a couple of changes but shouldn't affect you testing on GitHub. Let me know how things go!

min-width: 36px;
}

&.AvatarStack--3 {
Copy link
Member

Choose a reason for hiding this comment

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

@sophshep @califa and I discussed this in slack and we came to the conclusion that AvatarStack--two and AvatarStack-three-plus is the best solution we can think of!

}
}

.AvatarStack-body {
Copy link
Member

Choose a reason for hiding this comment

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

I've updated AvatarStack to apply position: absolute; to AvatarStack-body so that it partially addresses mine and @sophshep's concern's (above) re tying the positioning into this component (but not entirely since you have width in the block class).

@califa - might be good if we have a longer discussion in person about our principles, I'd like to ensure they make sense to everyone and I understand how they might be interpreted differently. We haven't really updated them since we first started the design systems team, and I want to review and iterate on them, and ensure they tie back to product design principles so that we can use them as a framework to make decisions on both design and code more easily.

To be honest I expect we'll need to iterate on AvatarStack(like many things). We want to move to more consistent usage around width and height values so they would point to variables or use utilities, have more layout objects (incl. starting to use CSS grid), and I think we'll have other components that will require this same "stack" treatment than just avatars. But I'm fine with this shipping in the interest of having this for your feature, and it will give us an opportunity to test the new version out.

position: relative;
z-index: 2;
display: flex;
width: 20px;
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I derped! Please leave as is.


```html
<div class="AvatarStack AvatarStack--three-plus tooltipped tooltipped-se temp-tooltipped-align-left" aria-label="jonrohan, aaronshekey, and josh">
<img alt="@jonrohan" class="avatar" height="20" alt="jonrohan" src="/jonrohan.png" width="20">
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned in Slack, we're removing staff avatars from our docs and moving to using the octocat placeholder. Could you update to use this? https://user-images.githubusercontent.com/334891/29999089-2837c968-9009-11e7-92c1-6a7540a594d5.png - let me know if you have trouble or don't have time.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@broccolini should I replace people w/ octocts for this entire readme file?

</div>
```

If you'd like a right-aligned avatar stack, add the `AvatarStack--right` modifier class and switch the tooltips around:
Copy link
Member

Choose a reason for hiding this comment

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

Trying to make our docs a bit more "to the point" and more of a command tense. Suggest:

Use AvatarStack--right to right-align the avatar stack and switch the origin of the tooltips.

"and switch the tooltips around" - it doesn't switch it though right? You have to manually change the tooltip classes? If so, we should make that clear. Suggest:

Use AvatarStack--right to right-align the avatar stack. Remember to switch the alignment of tooltips when making this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@broccolini broccolini removed the v10 label Nov 8, 2017
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.

4 participants