yari icon indicating copy to clipboard operation
yari copied to clipboard

fix: live sample scrollbar due to the iframe border

Open OnkarRuikar opened this issue 3 years ago • 1 comments

Summary

The PR #6506 removed padding from the live sample iframe. But the scrollbars still remain: scrollbars

Problem

The scrollbar issue hasn't been completely fixed due to 1px border.

Solution

Use outline instead of border. Setting outline-offset gives feeling of padding.

Screenshots

Before

scrollbars

After

Light mode light

Dark mode dark The box-shadow fills the gap between the outline and iframe edges.

How did you test this change?

In Firefox and chromium browsers on Fedora

OnkarRuikar avatar Jun 18 '22 03:06 OnkarRuikar

Signed the commit.

OnkarRuikar avatar Jun 27 '22 12:06 OnkarRuikar

cc/ @caugner

OnkarRuikar avatar Aug 29 '22 13:08 OnkarRuikar

@OnkarRuikar Is it intentional that the live samples now stand a bit out on the left? Could we fix this by adding horizontal margin?

caugner avatar Sep 01 '22 11:09 caugner

Is it intentional that the live samples now stand a bit out on the left? Could we fix this by adding horizontal margin?

The element is visually bigger now due to the outline.

I've reduced the width and shifted it to the right: realigned

OnkarRuikar avatar Sep 01 '22 14:09 OnkarRuikar

Thank you! Could you please rebase once more on the latest main and run yarn stylelint --fix once to make stylelint happy? 🙏 Sorry about that!

caugner avatar Sep 01 '22 18:09 caugner

FWIW The screenshots were taken from https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/isPointInStroke#examples.

caugner avatar Sep 02 '22 16:09 caugner

Looking at the latest version of this branch (before my changes that I have meanwhile reverted, as they didn't work as expected), the result is not the same as before the removal of the padding (live samples used to be aligned with the code samples).

  • This branch: image
  • Previously with padding: image

(Source: http://localhost:3000/en-US/docs/Web/HTML/Element/label#examples)

Even though this box-shadow/outline workaround is very clever, it doesn't look like it can restore the previous visual state. Therefore I will go ahead and close this PR for now.

The way forward is:

  1. Restore the iframe padding of 1rem,
  2. Add 2rem to the height in EmbedLiveSample.ejs (i.e. style="height: calc(${height}px + 2rem)").

Naturally, this will cause some live samples to be too high, but those live samples definitely don't have the right height now, as they shouldn't account for padding added by yari.

/cc @fiji-flo @wbamberg

caugner avatar Sep 06 '22 19:09 caugner