-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Rename .flex-item-equal
to .flex-1
#966
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/primer/primer-css/puatm5zo9 |
.flex#{$variant}-auto { flex: 1 1 auto !important; } | ||
.flex#{$variant}-grow-0 { flex-grow: 0 !important; } | ||
.flex#{$variant}-1 { flex: 1 !important; } | ||
.flex#{$variant}-auto { flex: auto !important; } |
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.
flex-grow: 1; | ||
flex-basis: 0; |
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.
Replacing
.flex-item-equal {
flex-grow: 1;
flex-basis: 0;
}
with
.flex-1 { flex: 1; }
should be ok, since flex-shrink: 1
is the default for flex items and flex: 1
gets computed as:
.flex-1 {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0%;
}
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.
This is great. Thanks for documenting the initial values of the other flex properties; that makes me much more confident about rolling this out! There are only a couple dozen instances of flex-item-equal
(and responsive variants; looks like just flex-md-item-equal
) to replace in github/github.
This renames the
.flex-item-equal
utility to.flex-1
.Motivation
Currently when using
.flex-auto
and a sibling element is an image or icon, the image or icon can start to shrink. A workaround is to add.flex-shrink-0
to the sibling element.Another workaround would be to use
flex: 1
instead offlex: auto
. It's similar but has aflex-basis
value of0%
. It seems to be less "aggressive" and respect the min-width of sibling elements. And thus no.flex-shrink-0
is necessary on the avatar:Turns out that
.flex-item-equal
could be used. Becauseflex-shrink: 1
is the default, is has the same computed values as using the shorthandflex: 1
->flex: 1 1 0%
->flex-grow: 1; flex-shrink: 1; flex-basis: 0%
. Maybe it doesn't get used as much because:flex-auto
.!important
and can't be used to override.So renaming the utility might help. The recommendation would be:
.flex-1
. In most situations it should be enough..flex-auto
if a flex item should take up space based on its content. Add.flex-shrink-0
to sibling elements that are images or icons.👀 See docs preview.
TODO
.flex-item-equal
.flex-1
TODO in
release-14.0.0
.flex-item-equal
classTODO on dotcom
.flex-item-equal
with.flex-1
/cc @primer/ds-core