- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.2k
[new DL][Skeleton Page] Ensure Skeleton Page title is the same font size as title rendered in Page component #3449
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
Conversation
| 🟢 This pull request modifies 4 files and might impact 1 other files. Details:All files potentially affected (total: 1)📄  | 
| Does anyone know why small Display Text is being rendered when the navigation is collapsed, even though we're passing in "large" as the size prop? cc @kyledurand | 
| 
 I wonder if this is because the media query provider doesn't yet know the size of the viewport. @BPScott would probably know the answer for sure. Ben could this be caused by SSR? @francinen does this ever get display text large when the nav is collapsed? Or does it flash small and then switch to large? | 
| @kyledurand When the navigation is collapsed, the display text switches from small to large as the Skeleton Page is replaced by the Page component. | 
| 
 Yeah this sounds right to me. When the HTML is rendered on the server-side it doesn't doesn't have any concept of media-queries or  If our aim here is to match what the Page Header Title component does then it looks like we're good as that uses useMediaQuery to toggle the size of the  To get up on a pedestal for a moment: IMO MediaQueryProvider is an anti-pattern because it causes issues like this where there ends up being html mismatches between the client and the server. Changing html content based upon browser width has the potential to make the browser do lots of work and we should trry to avoid it where possible, instead we should rely on good old CSS, and where feasible always render the same HTML but show/hide it with CSS media queries. Ideally instead of doing  .TitleText {
  @include text-style-display-large;
  .newDesignLanguage  {
    @include frame-when-nav-displayed {
      @include text-style-display-small;
  }
}and then something similar in SkeletonPage to mimic those box heights. | 
| @BPScott The CSS approach sounds a lot more scalable. I can give that a try later today. Thank you! | 
| Related: #3468. Looks like that's ended up with a similar approach to what I talked about above (though it seems the breakpoint we want to use has changed) | 
9bfa34f    to
    ff48392      
    Compare
  
    | @kyledurand @BPScott This PR is officially ready for review | 
1fc6369    to
    3a4adb8      
    Compare
  
    | return <div className={styles.Title}>{titleContent}</div>; | ||
| } | ||
|  | ||
| return <SkeletonDisplayText size="large" />; | 
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.
Does this <SkeletonDisplayText size="large"> have the same visual height as the new design language title at all viewport sizes?
I've not confirmed this but I'm guessing it doesn't as <DisplayText size="large"> matches <SkeletonDisplayText size="large"> and @alex-page wrote custom css instead of using <DisplayText size="large"> in Page. (Alternatively <SkeletonDisplayText size="large"> and thus <DisplayText size="large"> matches the new header css in Page in which case we should just use DisplayText instead of writing custom css in Page)
We should make sure this Skeleton content is the same height so we don't trigger layout shifts here too.
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.
I have the same concern too, it looks like this change would only match what we have in Title if the title was passed in to skeleton page. Otherwise you'd always be getting display text which I don't think matches perfectly.
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.
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 like <SkeletonDisplayText size="large"> uses the display-large line heights for its heights - 28px base, 32px when-typography-not-condensed, while Page title / newDesignLanguageTitle uses 28px at all sizes) so these are indeed different.
That looks about right with the jump seen in those gifs.
Would you be interested in fixing this up so the Skeleton height matches real content so we don't get page jumps there? (uugh it looks like we currently get a jump in that first gif because the actions are taller than the title but that feels slightly out of scope for this ticket).
A div with a class like this should do the job (written but not tested):
// duplicated from SkeletonDisplayText.scss
$skeleton-display-text-max-width: rem(120px);
.newDesignLanguageSkeletonTitle {
  @include skeleton-shimmer;
  @include skeleton-content;
  max-width: $skeleton-display-text-max-width;
  height: rem(28px);
}
3a4adb8    to
    53cb7f8      
    Compare
  
    53cb7f8    to
    d0b22b9      
    Compare
  
    | @BPScott or @kyledurand Are either of you able to re-review this PR? I responded to the question re: the Skeleton Display Text height here: #3449 (comment) | 
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.
Code looks good 👍
Looks like there might still be some content jumpiness in the second gif but this is definitely a solid improvement 👏
Thanks @francinen
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.
Add a comment inline about Skeleton heights with a possible solution.
@kyledurand / @alex-page: Any strong thoughts on if this should be done in this PR or if this can be done in a separate PR?
| return <div className={styles.Title}>{titleContent}</div>; | ||
| } | ||
|  | ||
| return <SkeletonDisplayText size="large" />; | 
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 like <SkeletonDisplayText size="large"> uses the display-large line heights for its heights - 28px base, 32px when-typography-not-condensed, while Page title / newDesignLanguageTitle uses 28px at all sizes) so these are indeed different.
That looks about right with the jump seen in those gifs.
Would you be interested in fixing this up so the Skeleton height matches real content so we don't get page jumps there? (uugh it looks like we currently get a jump in that first gif because the actions are taller than the title but that feels slightly out of scope for this ticket).
A div with a class like this should do the job (written but not tested):
// duplicated from SkeletonDisplayText.scss
$skeleton-display-text-max-width: rem(120px);
.newDesignLanguageSkeletonTitle {
  @include skeleton-shimmer;
  @include skeleton-content;
  max-width: $skeleton-display-text-max-width;
  height: rem(28px);
}
d0b22b9    to
    c716f00      
    Compare
  
    | Thanks, @BPScott! How does this look? | 
…en new design language is enabled
c716f00    to
    d09d172      
    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.
This looks good to me. @BPScott @kyledurand anything stopping us from merging?
| Nope 🚢 ! | 
| There's still a bit of a vertical jump (note the top bar of skeleton tab bar in the gif) but i think that's from the action buttons being taller than the title text now, which feels like a separate issue. Happy to 🚢 as is! Thanks for putting up with us @francinen! | 
…en new design language is enabled (#3449) Co-authored-by: Alex Page <alex@alexpage.com.au>





WHY are these changes introduced?
Fixes #3414
When the new design language is enabled, the page title shrinks when the Skeleton Page component is replaced by the Page component.
The font size for the page title should be consistent between the Skeleton Page component and the Page component.
WHAT is this pull request doing?
This PR implements a solution similar to the one introduced by #3468. Instead of using JavaScript to conditionally render small or large Display Text when the navigation is collapsed, the Skeleton Page component now relies purely on CSS to set different font sizes based on specific breakpoints.
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Testing in Storybook
dev sin the Polaris React repo to open StorybookTesting against a Shopify Web
🎩 checklist
README.mdwith documentation changes