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

fix(toolbar): added center and baseline alignments #5201

Merged
merged 11 commits into from Jan 13, 2023

Conversation

mattnolting
Copy link
Contributor

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

@patternfly-build
Copy link

patternfly-build commented Oct 31, 2022

@mattnolting mattnolting requested review from mcoker and srambach and removed request for mcoker November 7, 2022 15:51
@mattnolting mattnolting changed the base branch from main to v5 November 8, 2022 20:16
@mattnolting
Copy link
Contributor Author

@mcoker rebased and ready

Copy link
Contributor

@mcoker mcoker left a 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

.pf-c-toolbar__content,
.pf-c-toolbar__content-section,
.pf-c-toolbar__group,
.pf-c-toolbar__item {
align-self: stretch;
}

src/patternfly/components/Toolbar/toolbar.scss Outdated Show resolved Hide resolved
src/patternfly/components/Toolbar/toolbar.scss Outdated Show resolved Hide resolved
src/patternfly/components/Toolbar/toolbar.scss Outdated Show resolved Hide resolved
@mattnolting
Copy link
Contributor Author

@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;
Copy link
Contributor

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. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `.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. |

Comment on lines 223 to 225
&.pf-m-align-items-baseline {
--pf-c-toolbar__group--AlignItems: baseline;
}
Copy link
Contributor

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?

Comment on lines 396 to 392
&.pf-m-align-items-baseline {
--pf-c-toolbar__content-section--AlignItems: baseline;
}
Copy link
Contributor

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?

@mattnolting mattnolting force-pushed the 5030-fix-toolbar-alignment branch 2 times, most recently from 808cac3 to 716298b Compare November 10, 2022 01:20
Copy link
Contributor

@mcoker mcoker left a 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:

  1. just wanted to confirm we don't want to support align-self-baseline on groups and items anymore. Since their flex parents support align-items-center, I can see using that on the parent, and having a group/item as an exception using baseline alignment via align-self-baseline. Though I'm not sure if that's a real use case.
  2. Since you can nest groups, the alignment will inherit. I'm assuming that isn't ideal?

@mattnolting
Copy link
Contributor Author

@mcoker added baseline mods back as children can inherit variable update

Copy link
Contributor

@mcoker mcoker left a 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();
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, not purposeful

@mattnolting
Copy link
Contributor Author

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;
  }
}

@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.

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

LGTM 🥳

@mcoker mcoker requested a review from srambach November 23, 2022 00:52
@srambach
Copy link
Member

Two questions - what is the criteria for putting modifiers in the top section? Some are there but not all.
Second, is it worth making a demo of this, since it's not necessarily obvious how this alignment is useful in the case of error messages?

@mattnolting
Copy link
Contributor Author

Two questions - what is the criteria for putting modifiers in the top section? Some are there but not all. Second, is it worth making a demo of this, since it's not necessarily obvious how this alignment is useful in the case of error messages?

@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.

Screenshot 2022-12-16 at 10 10 13 AM

Screenshot 2022-12-16 at 10 11 27 AM

@srambach
Copy link
Member

srambach commented Jan 4, 2023

Is it expected that the "toolbar with validation desktop" example doesn't wrap and overflows? It happens at a relative wide width. (around 1245px)
Also, could you fix the title of that and the other desktop demo to be "on desktop" or something like that?
image

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

Nice job 👍

@mcoker mcoker merged commit 895ad50 into patternfly:v5 Jan 13, 2023
@patternfly-build
Copy link

🎉 This PR is included in version 5.0.0-alpha.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

mattnolting added a commit to mattnolting/patternfly that referenced this pull request Feb 15, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Feb 15, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Feb 22, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Feb 22, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Feb 22, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Feb 22, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Mar 2, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Mar 2, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Mar 2, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Mar 2, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Mar 2, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Mar 2, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request May 18, 2023
mattnolting added a commit to mattnolting/patternfly that referenced this pull request Dec 12, 2023
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.

Toolbar - explore alignment; error validation throws off alignment
4 participants