-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Avatar] Use inner shadow for border #4261
Conversation
border: `solid 1px ${avatar.borderColor}`, | ||
height: size - 2, | ||
width: size - 2, | ||
boxShadow: `inset 0px 0px 0px 1px ${avatar.borderColor}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's just a single property, we may as well assign it directly instead of using Object.assign()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I know that looked wrong. :)
@mbrookes one tiny change, looks good otherwise |
On hold for a 0.16.0 branch or pre-release. |
@@ -22,6 +22,7 @@ function getStyles(props, context) { | |||
borderRadius: '50%', | |||
height: size, | |||
width: size, | |||
boxShadow: src ? `inset 0px 0px 0px 1px ${avatar.borderColor}` : 'none', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried this path in the past. But we ended up reverting this change for painting performances reasons #1204 (comment).
I'm not sure it worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting, I compared the current and new implementation, and couldn't see a meaningful difference, but perhaps I'm not testing correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about the visual impact of this property? It seems to me that it has no impact and that backgroundColor
seems to be relevant here (I have no idea why).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The impact of boxShadow
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the visual impact. I can't see any difference with or without the property on Chome v50 OSX.
@oliviertassinari what about a border on a pseudo element? What's the perf like? I think being able to use an |
@oliviertassinari FWIW Google don't use the border in any of their products from android contacts book to desktop inbox app. I don't mind keeping it (it looks good on white avatars etc) but I'd like to see a solution that lets us use an IMG tag |
@nathanmarks I definitely agree with you. Using an
Either way, we should consider performances vs the spec perfect implementation ✨. |
@oliviertassinari BTW, the border is not even detailed in the spec -- it's just visually present in the examples (perhaps why it isn't in any of the products) |
After some quick benchmark with 30+ displayed |
@oliviertassinari, you're right, there's something odd going on here. The Also, from a bit of googling, it seems a boxshadow over an image doesn't work 'out of the box' (hoho). However under some circumstances, Unless I'm imagining this, there a difference, which is what led me to believe this was working. However, when changing the border size to something more visible, it's clear that this isn't actually working as expected as the border doesn't get bigger, and even though it sort of works here, it's unlikely to be consistent across browsers, so we need a different solution... |
@mbrookes I usually have to use a pseudo element to achieve it. |
@mbrookes at which point, for this use case, may as well have a border. But I use shadows over images often for vignetting etc |
Okay, I went the overlay div route. 😢 I did try a border on the overlay (with |
I'll fix the test after we agree on the approach. |
As pointed out by @nathanmarks Google isn't adding a border on their apps. On my project, I do neither. I would go with option 3 and remove the border. |
@oliviertassinari That was my gut instinct 👍 |
Avatar images with a white background against a white background look pretty awful (@nathanmarks posted a good example in chat), but perhaps they're not common enough to worry about. I think the border overlay is the right design choice, but the code (and possible performance) overhead might not be worth it from an engineering standpoint. |
@mbrookes No borders lets you do this (note the non-round avatars here) |
I found borders in the wild!! |
IMO, I think borderless actually looks better 99.9% of the time in that application due to the technique. |
Closing in favour of #4265. |
Use an inner shadow for the border to allow the image to be an
<img>
notbackgroundImage
.Closes #4254.