Skip to content

Pattern page width (scaling live preview) #7966

@jesstelford

Description

@jesstelford

(forked from #7948): "Narrow page with to match figma prototype"

tl;dr: There's a mismatch between the page sizes used in Figma vs the actual website which have significant impact on how examples render.

The final rendered width of an example on a detail page on the docs site has a bunch of inputs:

  1. The main column (including ToC) has a max width of 1240px (including 128px of padding, so content can only be 1112px).
  2. The nav column has a hard-coded width of 288px*.
  3. The Table of Contents (ToC) has a hard-coded width of 336px**. The ToC can be disabled on a per-page basis with showTOC: true/false
  4. What breakpoint currently matches? This effects visibility of both the nav and the ToC.
  5. The examples have a 1px border + 64px of padding.

* Including the padding
** Including the padding and gap separating it from the main column

To put it a different way, let's list out all the possible widths with the relevant breakpoints to determine how wide the content area can ever be:

With showTOC: true

Screen width Content width Example render width
hitting the max-width: 1240px
ie; >= 1528
1240[maxw] - 128[pad] - 336[toc]
= 776px
776 - 64[pad] - 2[border]
= 710px
thinnest before ToC media query
ie; > 1400
1401[scr] - 288[nav] - 128[pad] - 336[toc]
= 649px
649 - 64[pad] - 2[border]
= 583px

With showTOC: false

Screen width Content width Example render width
hitting the max-width: 1240px
ie; >= 1528
1240[maxw] - 128[pad]
= 1112px
1112 - 64[pad] - 2[border]
= 1046px
thinnest before ToC media query
ie; > 1400
1401[scr] - 288[nav] - 128[pad]
= 985px
985 - 64[pad] - 2[border]
= 919px

ToC always hidden by media query

Screen width Content width Example render width
ToC hidden by media query
ie; = 1400
1400[scr] - 288[nav] - 128[pad]
= 984px
984 - 64[pad] - 2[border]
= 918px
thinnest while nav still visible
ie; > 769
769[scr] - 288[nav] - 128[pad]
= 353px
353 - 64[pad] - 2[border]
= 287px
Nav hidden by media query
ie; = 768
768[scr] - 128[pad]
= 640px
640 - 64[pad] - 2[border]
= 574px

The Figma designs are currently using a screen resolution of 1540px, which puts them firmly in the "hitting the max-width: 1240px" row, BUT... it uses different padding:

Screenshot 2022-12-22 at 5 12 06 pm

This padding is defined site-wide, so couldn't/shouldn't be changed without serious consideration and work.

Another thing to consider is how the site behaves on common screen widths. Interestingly, on my personal 13" MacBook Air, the ToC is automatically hidden (because the screen is slightly smaller), which results in more physical space for the text and demo, making it a better experience using the docs site!

It also means that on my 14" with ToC open, the live code preview width is thinner, pushing it just under the threshold for a smaller breakpoint size, meaning on my 14" I see a different (mobile) rendered preview than I do on my 13" (tablet) 😱
See these photos of the laptops side-by-side (13" in front, 14" behind).

PXL_20221214_231442876 MP

One final point is thinking about how the rendered examples behave with respect to breakpoints: anything above our two smallest breakpoints (320px & 490px) will never be fully visible without horizontally scrolling (the next breakpoint up is 768px - never visible when the ToC is rendered above 1400px).

Suggested actions

  1. Update the Figma designs to use the correct padding
  2. Consider the above tables of information with respect to how much width each example has to render when the ToC is visible / at different screen sizes

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions