8000 feat(page): use subgrid to align masthead to page by srambach · Pull Request #6870 · patternfly/patternfly · GitHub
[go: up one dir, main page]

Skip to content

feat(page): use subgrid to align masthead to page#6870

Merged
mcoker merged 14 commits intopatternfly:v6from
srambach:6420-masthead-subgrid
Jul 25, 2024
Merged

feat(page): use subgrid to align masthead to page#6870
mcoker merged 14 commits intopatternfly:v6from
srambach:6420-masthead-subgrid

Conversation

@srambach
Copy link
Member
@srambach srambach commented Jul 10, 2024

This uses subgrid to align the 3 parts of the masthead to the page sidebar and main container. Fixes #6420

Question: Do we want the space along the sides to be larger on xl breakpoint? That was built in but we don't have a token for that. Should we just use the page inset spacer token for all breakpoints? @lboehling

Question: Is it ok for a divider in the navigation to be the width of the nav items rather than all the way across? @lboehling

Note: If the logo is wide, it will force the sidebar column to be wider

Issue: The grid is still giving too much space to the toggle as a result of (navigation - logo) > toggle

@patternfly-build
Copy link
Collaborator
patternfly-build commented Jul 10, 2024

@srambach
Copy link
Member Author

Showing scroll in sidebar and divider:
image

@srambach srambach force-pushed the 6420-masthead-subgrid branch from 77aa949 to 0360296 Compare July 15, 2024 20:28
@srambach srambach marked this pull request as ready for review July 16, 2024 13:28
@mattnolting
Copy link
Collaborator

Through debugging, I found that --pf-v6-c-page__sidebar--Width alters grid column fitting adversely. This example demonstrates how grid column definitions (min-content minmax(200px, max-content) 1fr) can be used to manage sidebar width, with or without the inclusion of masthead__main or the logo therein.

@srambach
Copy link
Member Author

Through debugging, I found that --pf-v6-c-page__sidebar--Width alters grid column fitting adversely. This example demonstrates how grid column definitions (min-content minmax(200px, max-content) 1fr) can be used to manage sidebar width, with or without the inclusion of masthead__main or the logo therein.

I think what you are saying is to use this?

.pf-v6-c-page {
    grid-template-columns: min-content minmax(200px, max-content) 1fr;
}

This will make the sidebar no less than 200px - so we need to know what the min desired width is. @lboehling ?
It will also cause the sidebar to grow with long menu items. I wonder if that's ok?
image

If we use grid-template-columns: min-content minmax(200px, min-content) 1fr; I think it might be a little better?
image

WDYT? @mattnolting @mcoker

@mattnolting
Copy link
Collaborator

I think what you are saying is to use this?

.pf-v6-c-page {
    grid-template-columns: min-content minmax(200px, max-content) 1fr;
}

@srambach Yes, also removing width from page__sidebar

grid-template-columns: min-content minmax(200px, min-content) 1fr;

I think it might be a little better?

I agree, @lboehling what should the min-width of the sidebar be?

@mattnolting
Copy link
Collaborator

@srambach I also modified page layout.

Gave page gap property and padding

:root {
  --pf-v6-c-page--Gap: var(--pf-t--global--spacer--lg);
  --pf-v6-c-page--PaddingInline: var(--pf-t--global--spacer--lg);
  --pf-v6-c-page--ColumnGap: var(--pf-t--global--spacer--lg);
}

Added padding to page

.pf-v6-c-page {
  padding-inline: var(--pf-v6-c-page--PaddingInline);
}

Removed margins from nav, masthead, and page elements and removed grid-areas. This approach was more understandable to me, although you could stick with grid-area.

.pf-v6-c-nav,
.pf-v6-c-page > .pf-v6-c-masthead,
.pf-v6-c-page > .pf-v6-c-masthead .pf-v6-c-masthead__brand,
.pf-v6-c-page__sidebar,
.pf-v6-c-page__main-container {
  --pf-v6-c-page__main-container--MarginInlineStart: 0;
  --pf-v6-c-page__main-container--MarginInlineEnd: 0;

  padding-inline: 0; // remove padding
  margin-inline: 0; // remove padding
  grid-area: unset;
}

Added border to masthead__main in favor of using divider

// masthead border
.pf-v6-c-masthead__main {
  position: relative;
  border: none;
}

.pf-v6-c-masthead__main::before {
  content: "";
  inset-block: 100%;
  inset-inline: calc(var(--pf-v6-c-page--PaddingInline) * -1);
  position: absolute;
  border-bottom: 1px solid gray;
}

Removed width from and added negative margin to sidebar, then applied the same inline padding to sidebar__body to accommodate scrolling for the entire sidebar.

.pf-v6-c-page__sidebar {
  width: unset;
  margin-inline-start: calc(var(--pf-v6-c-page--PaddingInline) * -1);
  margin-inline-end: calc(var(--pf-v6-c-page--ColumnGap) / 2);
}

.pf-v6-c-page__sidebar-body {
  padding-inline-start: var(--pf-v6-c-page--PaddingInline);
  padding-inline-end: calc(var(--pf-v6-c-page--ColumnGap) / 2);
}

Updated grid-template-columns and column spans for tablet layout

@media screen and (min-width: 768px) {
  .pf-v6-c-page {
    grid-template-columns: min-content minmax(200px, max-content) 1fr;
  }

  .pf-v6-c-page__sidebar {
    grid-column: 1 / 3;
  }

  .pf-v6-c-page > .pf-v6-c-masthead,
  .pf-v6-c-page__main-container {
    grid-column: 1 / 4;
  }

  .pf-v6-c-page > .pf-v6-c-masthead {
    grid-template-columns: subgrid;
    column-gap: inhert; // or whatever value needed
  }

  .pf-v6-c-page > .pf-v6-c-masthead .pf-v6-c-masthead__main::before {
    display: none; // this applies to desktop presentation
  }
}

Updated grid-template-columns and column spans for desktop layout

@media screen and (min-width: 1200px) {
  .pf-v6-c-page > .pf-v6-c-masthead .pf-v6-c-masthead__main {
    grid-column-start: 2;
  }

  .pf-v6-c-page > .pf-v6-c-masthead {
    grid-column-start: 1;
    grid-column-end: 5;
  }

  .pf-v6-c-page__main-container {
    grid-column-start: 3;
    grid-column-end: 5;
  }
}

@srambach
Copy link
Member Author

This update does a few things - it's a little confusing because names were reused so I'll try to spell it out:

  • Wraps the toggle and what used to be main in a container and names that container main
masthead
  __toggle
  __main
    a.__brand
      // logo file (masthead-logo.hbs)
  __content

updated to:
masthead
  __main
    __toggle
    __brand
      a.__logo
	// svg (in masthead-image.hbs)
  __content

So -

  • the SVG in masthead-logo.hbs was renamed to be masthead-image.hbs
  • __brand was renamed to be __logo
  • __main was renamed to be __brand
  • Then wraps __toggle and __brand in __main

Also

  • Removes the adjustment to the page margin for xl
  • Removes a couple of old modifiers in the hbs

@srambach srambach requested review from mattnolting and mcoker July 17, 2024 17:51
.#{$masthead}__logo {
align-items: var(--#{$masthead}__logo--AlignItems, var(--#{$masthead}--AlignItems));
max-height: var(--#{$masthead}__logo--MaxHeight);
margin-inline-end: var(--#{$masthead}__logo--MarginInlineEnd);
Copy link
Contributor

Choose a reason for hiding this comment

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

A style like this will keep any kind of image from growing larger than this container.

  > * {
    max-width: 100%;
    max-height: 100%;
    vertical-align: middle;
 }

IMO we should not make __logo a flex parent, especially if we're relying on align-items: stretch because it can cause the image to stretch. Here is what happens if you put an image in this box now that's super wide - the height is stretching from the parent's flex align-items

Screenshot 2024-07-17 at 1 22 49 PM

The vertical-align property above will be needed if __logo isn't a flex layout since by default, images have a small gap underneath them to account for characters that have a tail (like j, p, q, y, etc).

.#{$masthead}__logo {
align-items: var(--#{$masthead}__logo--AlignItems, var(--#{$masthead}--AlignItems));
max-height: var(--#{$masthead}__logo--MaxHeight);
margin-inline-end: var(--#{$masthead}__logo--MarginInlineEnd);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this margin?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we need space there so if there's something left aligned in the content area it doesn't butt against - but I will move it to masthead__main
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, that's a good place for it 👍

.#{$masthead}__logo,
.#{$masthead}__content {
display: flex;
align-self: stretch;
Copy link
Contributor

Choose a reason for hiding this comment

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

I might change this to align-self: center just for __logo. This will center the image relative to the toggle and make __logo hug the image instead of potentially being taller than the image if the image is shorter than __logo

before (with the logo height adjusted to 25px instead of 37px)
Screenshot 2024-07-17 at 1 37 41 PM

after
Screenshot 2024-07-17 at 1 39 10 PM

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 pretty good to me. Want to review the visual regression screenshots. And not a result of this PR, but looks like we're missing --#{$page}__sidebar--PaddingInlineEnd, can you add it back and set it to "0" like --#{$page}__sidebar--PaddingInlineStart below?

--#{$page}__sidebar--PaddingInlineStart: 0;

Comment on lines -3 to -7
{{~#ifEquals masthead--ColorVariant "light"}}
pf-m-light
{{else ifEquals masthead--ColorVariant "light-200"}}
pf-m-light-200
{{/ifEquals}}
Copy link
Contributor

Choose a reason for hiding this comment

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

🥳

Comment on lines +44 to +45
--#{$masthead}--m-display-inline__brand--GridColumn: unset;
--#{$masthead}--m-display-inline__brand--Order: unset;
Copy link
Contributor

Choose a reason for hiding this comment

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

This may work but unset is a special keyword that applies to the property its being used on, and in this case the properties are the vars. You can see here that --d: unset does something different than display: unset https://codepen.io/mcoker/pen/NWZrmWb

I would probably do it this way:

Suggested change
--#{$masthead}--m-display-inline__brand--GridColumn: unset;
--#{$masthead}--m-display-inline__brand--Order: unset;
--#{$masthead}--m-display-inline__brand--GridColumn: initial;
--#{$masthead}--m-display-inline__brand--Order: initial;

Then update the vars here to add revert as a fallbacks

grid-column: var(--#{$masthead}__brand--GridColumn);

order: var(--#{$masthead}__brand--Order);

Comment on lines +15 to +16
--#{$nav}--PaddingInlineStart: 0; // var(--pf-t--global--spacer--md);
--#{$nav}--PaddingInlineEnd: 0; // var(--pf-t--global--spacer--md);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit to remove comments

Suggested change
--#{$nav}--PaddingInlineStart: 0; // var(--pf-t--global--spacer--md);
--#{$nav}--PaddingInlineEnd: 0; // var(--pf-t--global--spacer--md);
--#{$nav}--PaddingInlineStart: 0;
--#{$nav}--PaddingInlineEnd: 0;

Comment on lines +129 to +131
&.pf-m-inset {
--#{$nav}--PaddingInlineStart: var(--pf-t--global--spacer--md);
--#{$nav}--PaddingInlineEnd: var(--pf-t--global--spacer--md);
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean to leave this in? If so we should document it and make sure it's in react. Though we might chat about the name - I think so far, .pf-m-inset has a size modifier, or it's .pf-m-page-insets, and sometimes we have .pf-m-padding if there is just a single padding value someone would want to apply.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah, I'm fine without it if we don't need it!

grid-area: sidebar;
grid-row-start: 2;
grid-column-start: 1;
width: var(--#{$page}__sidebar--Width);
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to keep this around and used up until the xl breakpoint so that it doesn't consume the viewport width when expanded, then we can just set it to auto or something at the xl breakpoint

< D60E p class="text-center tmp-mt-3" data-hide-on-error>

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we even need to change it at xl because the grid column is set to the same value.

// Sidebar body
--#{$page}__sidebar-body--PaddingInlineEnd: 0;
--#{$page}__sidebar-body--PaddingInlineStart: 0;
--#{$page}__sidebar-body--PaddingInlineEnd: var(--pf-t--global--spacer--gutter--default);
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why we wouldn't use var(--pf-t--global--spacer--inset--page-chrome) here, too, to match --#{$page}__sidebar-body--PaddingInlineStart?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question; I think it's just left over from rearranging things different ways.

@srambach
Copy link
Member Author

@srambach srambach force-pushed the 6420-masthead-subgrid branch from 2c71b33 to 561d032 Compare July 24, 2024 18:43
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.

LPTM! Updated this PR with the visual regression screenshots. Here's the report
BackstopJS Report.pdf

@patternfly-build
Copy link
Collaborator

🎉 This PR is included in version 6.0.0-alpha.202 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Page/masthead logo - should be the same size as the sidebar/vertical nav

5 participants

0