Skip to content

Commit

Permalink
report: occupy entire viewport (#15664)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored Dec 6, 2023
1 parent 4c5e1c2 commit 7cdff76
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions report/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@
--sticky-header-buffer: 0;
}

.lh-max-viewport {
display: flex;
flex-direction: column;
min-height: 100vh;
width: 100%;
}

.lh-devtools.lh-root {
height: 100%;
}
Expand Down
1 change: 1 addition & 0 deletions report/clients/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function __initLighthouseReport__() {
const lhr = window.__LIGHTHOUSE_JSON__;

const reportRootEl = renderReport(lhr, {
occupyEntireViewport: true,
getStandaloneReportHTML() {
return document.documentElement.outerHTML;
},
Expand Down
2 changes: 1 addition & 1 deletion report/renderer/components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions report/renderer/report-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export class ReportRenderer {
this._dom.rootEl.textContent = ''; // Remove previous report.
this._dom.rootEl.append(this._renderReport(report));

if (this._opts.occupyEntireViewport) {
this._dom.rootEl.classList.add('lh-max-viewport');
}

return this._dom.rootEl;
}

Expand Down
2 changes: 2 additions & 0 deletions report/types/report-renderer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ declare module Renderer {
omitTopbar?: boolean;
/** Prevent injection of report styles. Set to true if these styles are already included by the environment. */
omitGlobalStyles?: boolean;
/** Ensure the report occupies the entire viewport. This option should be enabled if the report represents the entire page content (i.e. standalone HTML & viewer app) */
occupyEntireViewport?: boolean;
/**
* Convert report anchor links to a different format.
* Flow report uses this to convert `#seo` to `#index=0&anchor=seo`.
Expand Down
4 changes: 3 additions & 1 deletion viewer/app/src/lighthouse-report-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ export class LighthouseReportViewer {
const dom = new DOM(document);
const renderer = new ReportRenderer(dom);

renderer.renderReport(json, rootEl);
renderer.renderReport(json, rootEl, {
occupyEntireViewport: true,
});

const features = new ViewerUIFeatures(dom, {
saveGist: saveGistCallback,
Expand Down

0 comments on commit 7cdff76

Please sign in to comment.