Skip to content

Commit

Permalink
report: set minimum width of element screenshot preview (#13856)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Apr 19, 2022
1 parent fafe5b3 commit d8ec876
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 29 deletions.
7 changes: 5 additions & 2 deletions report/assets/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions report/assets/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -893,16 +893,17 @@
<template id="elementScreenshot">
<div class="lh-element-screenshot">
<div class="lh-element-screenshot__content">
<div class="lh-element-screenshot__mask">
<svg height="0" width="0">
<defs>
<clipPath clipPathUnits="objectBoundingBox"></clipPath>
<!-- clipPath filled by ElementScreenshotRenderer.renderClipPath -->
</defs>
</svg>
<div class="lh-element-screenshot__image">
<div class="lh-element-screenshot__mask">
<svg height="0" width="0">
<defs>
<clipPath clipPathUnits="objectBoundingBox"></clipPath>
<!-- clipPath filled by ElementScreenshotRenderer.renderClipPath -->
</defs>
</svg>
</div>
<div class="lh-element-screenshot__element-marker"></div>
</div>
<div class="lh-element-screenshot__image"></div>
<div class="lh-element-screenshot__element-marker"></div>
</div>
</div>
</template>
Expand Down
25 changes: 13 additions & 12 deletions report/renderer/components.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions report/renderer/element-screenshot-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ export class ElementScreenshotRenderer {
{width: screenshot.width, height: screenshot.height}
);

const contentEl = dom.find('div.lh-element-screenshot__content', containerEl);
contentEl.style.top = `-${elementPreviewSizeDC.height}px`;

const imageEl = dom.find('div.lh-element-screenshot__image', containerEl);
imageEl.style.width = elementPreviewSizeDC.width + 'px';
imageEl.style.height = elementPreviewSizeDC.height + 'px';
Expand Down
6 changes: 3 additions & 3 deletions report/test/renderer/element-screenshot-renderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ describe('ElementScreenshotRenderer', () => {
/* eslint-disable max-len */
expect(htmlFormatted).toMatchInlineSnapshot(`
"
<div class=\\"lh-element-screenshot__content\\" style=\\"top: -500px;\\">
<div class=\\"lh-element-screenshot__content\\">
<div class=\\"lh-element-screenshot__image\\" style=\\"width: 500px; height: 500px; background-position-y: 0px; background-position-x: 0px; background-size: 1000px 1000px;\\">
<div class=\\"lh-element-screenshot__mask\\" style=\\"width: 500px; height: 500px; clip-path: url(#clip-0);\\">
<svg height=\\"0\\" width=\\"0\\"> <defs>
<clipPath clipPathUnits=\\"objectBoundingBox\\" id=\\"clip-0\\">
<polygon points=\\"0,0 1,0 1,0.1 0,0.1\\"></polygon>
<polygon points=\\"0,0.7 1,0.7 1,1 0,1\\"></polygon>
<polygon points=\\"0,0.1 0.1,0.1 0.1,0.7 0,0.7\\"></polygon>
<polygon points=\\"0.5,0.1 1,0.1 1,0.7 0.5,0.7\\"></polygon></clipPath> </defs> </svg> </div>
<div class=\\"lh-element-screenshot__image\\" style=\\"width: 500px; height: 500px; background-position-y: 0px; background-position-x: 0px; background-size: 1000px 1000px;\\"></div>
<div class=\\"lh-element-screenshot__element-marker\\" style=\\"width: 200px; height: 300px; left: 50px; top: 50px;\\"></div> </div> "
<div class=\\"lh-element-screenshot__element-marker\\" style=\\"width: 200px; height: 300px; left: 50px; top: 50px;\\"></div> </div> </div> "
`);
/* eslint-enable max-len */
});
Expand Down

0 comments on commit d8ec876

Please sign in to comment.