feat(Page): add high contrast border - #7718
Conversation
|
Preview: https://pf-pr-7718.surge.sh A11y report: https://pf-pr-7718-a11y.surge.sh |
|
Updated to prevent the layout shift -
|
| --#{$page}__main-container--BorderRadius: var(--pf-t--global--border--radius--medium); | ||
| --#{$page}__main-container--BorderWidth: #{pf-size-prem(4px)}; // TODO Change to be a page outline token | ||
| --#{$page}__main-container--BorderColor: var(--#{$page}__main-container--BackgroundColor); // TODO Border should match the background to blend in - change to be a page outline token | ||
| --#{$page}__main-container--BorderOffset: var(--#{$page}__main-container--BorderWidth); |
There was a problem hiding this comment.
Since there isn't a css attribute called border-offset, wdyt about calling this --#{$page}__main-container--Padding--offset? It looks like we've used that pattern once or twice before. @mcoker ?
714bff0 to
7901993
Compare
| --#{$page}__main-container--BorderWidth: var(--pf-t--global--border--width--strong); | ||
| --#{$page}__main-container--BorderColor: var(--pf-t--global--border--color--high-contrast); | ||
| --#{$page}__main-container--Padding--offset: #{pf-size-prem(4px)}; |
There was a problem hiding this comment.
@lboehling @mcoker We have a comment in the code saying that we should create page border outline width and color tokens. Is this a good time to do that? Then it could adjust in the high-contrast tokens. Trying to see if we could get rid of this media query! Since the offset is 4px either way, maybe that would do it?
There was a problem hiding this comment.
I like that! @lboehling do you have any issues with adding that to figma?
There was a problem hiding this comment.
That would also let us use that token value to offset any component padding/insets that might need to take into consideration that border width to align properly with other page chrome elements. I haven't looked too much into it, but I'm wondering if that might help resolve this issue with tabs not aligning properly with the page chrome gutter #7376
mcoker
left a comment
There was a problem hiding this comment.
@kmcfaul design added tokens for the page border color (--pf-t--global--border--color--page--default) and border width (--pf-t--global--border--width--page--default) in #7761.
Would you mind rebasing and dropping that token in here where appropriate? I'm hoping it can get rid of the custom @media (prefers-contrast) styles like @srambach mentioned in https://github.com/patternfly/patternfly/pull/7718/files#r2289094152
7901993 to
1cdf818
Compare
|
@mcoker Rebased and updated to use the new tokens, but the media-query may still be required to account for the border width/padding issue. And speaking of that, I'm seeing a small layout shift again even though the calculated sizes should be the same as the previous implementation. Do you have any ideas for addressing this shift? |
@kmcfaul are you referring to a shift in either the subnav or breadcrumb container? That's where I'm seeing a shift. Assuming that's the case, I believe it's because of a scoping issue with the change of patternfly/src/patternfly/components/Page/page.scss Lines 388 to 392 in 1cdf818 If you update the value of a CSS var, you'll need to update it in the same scope of where it's declared/used. Meaning you'd want to move the The reason the main-section padding doesn't shift is because patternfly/src/patternfly/components/Page/page.scss Lines 502 to 503 in 1cdf818 |
|
Update - the layout shift must be something with the examples page / seeing the various inline page examples. In a full page example in a new tab, there is no layout shift. So this PR should be good to go unless anyone finds any other gotchas. |
| --#{$page}__main-container--BorderWidth: var(--pf-t--global--border--width--page--default); | ||
| --#{$page}__main-container--BorderColor: var(--pf-t--global--border--color--page--default); | ||
| --#{$page}__main-container--Padding--offset: 4px; |
There was a problem hiding this comment.
| --#{$page}__main-container--BorderWidth: var(--pf-t--global--border--width--page--default); | |
| --#{$page}__main-container--BorderColor: var(--pf-t--global--border--color--page--default); | |
| --#{$page}__main-container--Padding--offset: 4px; | |
| --#{$page}__main-container--BorderWidth: var(--pf-t--global--border--width--page--default); | |
| --#{$page}__main-container--BorderColor: var(--pf-t--global--border--color--page--default); |
I think that we can just make this change and revert all the other changes to the file. I don't think we need the offset because subtracting the border width from the page section(s) padding (which was already done) will give the correct spacing and avoid the 2px gap between the high-contrast border and a section with a secondary background. There will be a slight vertical shift as the top border goes from 4 to 2px, but I think that's acceptable as we currently don't try to vertically align the main area with anything else.
If we want to avoid the vertical shift, we can select the first page group/section and adjust, but it's a bit messy and perhaps not worth it.
There was a problem hiding this comment.
I don't hate the idea of that 😄 But I don't consider it a blocker to this.
There was a problem hiding this comment.
I like it. We could then use page areas as names - "header", "sidebar", possibly "nav" if needed, and "main". Not a blocker to this PR, which I'd like to get merged ASAP but we'd want to make that change this sprint before code freeze.
There was a problem hiding this comment.
sounds good -- i'll make that change in figma so it's ready the next time we export the tokens.
Closes #7590.
@mcoker / @srambach Would this approach of updating the existing border on the page main container work for this use case or would the
before/afterapproach still be preferred? I had initially run into some z-indexing issues on the border & page content as well as seeing the two borders concurrently, before I changed track and updated the current border instead because it already existed. But I can definitely keep adjusting theafterblock if that's still preferred, I think I just need to disable the current border and then resolve the z-indexes.With the current approach, there is also a 2px difference in the border widths (4px on the normal border and 2px on the high contrast border) that's causing a small layout shift and I'm unsure the best way to solve it. Maybe adding additional padding when high contrast is on?