Skip to content
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

report: occupy entire viewport #15664

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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');
}

Check warning on line 66 in report/renderer/report-renderer.js

View check run for this annotation

Codecov / codecov/patch

report/renderer/report-renderer.js#L65-L66

Added lines #L65 - L66 were not covered by tests

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
Loading