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
fix(toolbar): added center and baseline alignments #5201
fix(toolbar): added center and baseline alignments #5201
Conversation
Preview: https://patternfly-pr-5201.surge.sh A11y report: https://patternfly-pr-5201-a11y.surge.sh |
b87c1be
to
78f6c2d
Compare
@mcoker rebased and ready |
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.
Looks good! Left some comments. Also curious if we should update these to use the new vars
align-items: baseline; |
patternfly/src/patternfly/components/Toolbar/toolbar.scss
Lines 170 to 175 in 78f6c2d
.pf-c-toolbar__content, | |
.pf-c-toolbar__content-section, | |
.pf-c-toolbar__group, | |
.pf-c-toolbar__item { | |
align-self: stretch; | |
} |
@mcoker updated |
@@ -13,9 +13,12 @@ $pf-c-toolbar--inset-map: build-spacer-map("none", "sm", "md", "lg", "xl", "2xl" | |||
// Item | |||
--pf-c-toolbar__item--Display: block; | |||
--pf-c-toolbar__item--MinWidth--base: auto; | |||
--pf-c-toolbar__item--AlignSelf: baseline; |
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.
should this be auto
? otherwise, setting align-items
on the group doesn't seem like it will ever work, since align-self
on the items will always override that.
@@ -664,6 +664,10 @@ As the toolbar component is a hybrid layout and component, some of its elements | |||
| `.pf-m-visible{-on-[breakpoint]}` | `.pf-c-toolbar__content`, `.pf-c-toolbar__content-section`, `.pf-c-toolbar__item`, `.pf-c-toolbar__group` | Modifies toolbar element to be shown, at optional [breakpoint](/developer-resources/global-css-variables#breakpoint-variables-and-class-suffixes). | | |||
| `.pf-m-align-right{-on-[breakpoint]}` | `.pf-c-toolbar > *` | Modifies toolbar element to align right, at optional [breakpoint](/developer-resources/global-css-variables#breakpoint-variables-and-class-suffixes). | | |||
| `.pf-m-align-left{-on-[breakpoint]}` | `.pf-c-toolbar > *` | Modifies toolbar element to align left, at optional [breakpoint](/developer-resources/global-css-variables#breakpoint-variables-and-class-suffixes). | | |||
| `.pf-m-align-items-center` | `.pf-c-toolbar__content-section`, `.pf-c-toolbar__group` | Modifies toolbar element to vertically align children to center. | | |||
| `.pf-m-align-items-baseline` | `.pf-c-toolbar__content-section`, `.pf-c-toolbar__group` | Modifies toolbar element to vertically align children to center. | |
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.
| `.pf-m-align-items-baseline` | `.pf-c-toolbar__content-section`, `.pf-c-toolbar__group` | Modifies toolbar element to vertically align children to center. | | |
| `.pf-m-align-items-baseline` | `.pf-c-toolbar__content-section`, `.pf-c-toolbar__group` | Modifies toolbar element to vertically align children to baseline. | |
&.pf-m-align-items-baseline { | ||
--pf-c-toolbar__group--AlignItems: baseline; | ||
} |
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 this is the default, is there ever a use case for this class?
&.pf-m-align-items-baseline { | ||
--pf-c-toolbar__content-section--AlignItems: baseline; | ||
} |
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.
Same question here as for the group - since it's the default, what's the use case for this class?
808cac3
to
716298b
Compare
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.
As mentioned on slack, 2 remaining questions:
- just wanted to confirm we don't want to support
align-self-baseline
on groups and items anymore. Since their flex parents supportalign-items-center
, I can see using that on the parent, and having a group/item as an exception using baseline alignment viaalign-self-baseline
. Though I'm not sure if that's a real use case. - Since you can nest groups, the alignment will inherit. I'm assuming that isn't ideal?
cfbbd0e
to
38da709
Compare
@mcoker added baseline mods back as children can inherit variable update |
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.
Looks good, everything works well.
One potential issue - if everything is set to baseline by default, baseline is going to try and align with stuff around it, meaning "baseline" could result in "center" alignment (visually) if the other items in the layout are center aligned. Is that expected? https://codepen.io/mcoker/pen/QWxOJZQ
I wonder if the alignment properties should inherit. I don't think I would expect them to. Looking at the flex layout, the alignment mods redefine the regular property, not custom property, so the changes aren't inherited. That might be the most clean, tho if we want to manage everything with custom properties, we could use a --base
var to set the default within each element that takes an alignment selector. Here's an example - https://codepen.io/mcoker/pen/jOKaQXx?editors=1100
Or in this PR, something like:
.pf-c-toolbar {
--pf-c-toolbar__group--AlignItems--base: baseline;
}
.pf-c-toolbar__group {
--pf-c-toolbar__group--AlignItems: var(--pf-c-toolbar__group--AlignItems--base);
align-items: var(--pf-c-group__AlignItems);
&.pf-m-center {
--pf-c-toolbar__group--AlignItems: center;
}
}
@@ -1,7 +1,7 @@ | |||
// Don't remove this magic comment. See gulpfile.js. | |||
// @import "../../sass-utilities/all"; | |||
$pf-c-toolbar--breakpoint-map: build-breakpoint-map("base", "sm", "md", "lg", "xl", "2xl"); | |||
$pf-c-toolbar--spacer-map: build-spacer-map("none", "sm", "md", "lg"); | |||
$pf-c-toolbar--spacer-map: build-spacer-map(); |
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.
Just want to verify this is on purpose?
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.
No, not purposeful
@mcoker I think updating the property (not custom property) is the way to go here. It's the simplest solution and it works well. Updated. |
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.
LGTM 🥳
Two questions - what is the criteria for putting modifiers in the top section? Some are there but not all. |
@srambach I think the current alignment is a misimplementation. Center alignment would be the edge case for anything that doesn't share a height with selects, buttons, text inputs, etc. If we add a demo, it should highlight center alignment, rather than baseline. I would expect for that to be necessary for custom implementations, like including an icons, logos, text, etc. |
21a4dd4
to
2b5e336
Compare
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.
Nice job 👍
🎉 This PR is included in version 5.0.0-alpha.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
closes #5030
This PR adds:
.pf-m-align-items-center
to.pf-c-toolbar__content-section
and.pf-c-toolbar__group
.pf-m-align-self-center
to.pf-c-toolbar__group
and.pf-c-toolbar__item
.pf-m-align-self-baseline
to.pf-c-toolbar__group
and.pf-c-toolbar__item