Skip to content

Commit

Permalink
report(metrics): [revert] use css grid so metrics are aligned (#10695) (
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish authored May 13, 2020
1 parent 8369a08 commit 5f372ea
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,19 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
metricAuditsEl.append(..._toggleEl.childNodes);

const metricAudits = category.auditRefs.filter(audit => audit.group === 'metrics');
const metricsBoxesEl = this.dom.createChildOf(metricAuditsEl, 'div', 'lh-metrics-container');

metricAudits.forEach(item => {
metricsBoxesEl.appendChild(this._renderMetric(item));
const keyMetrics = metricAudits.slice(0, 3);
const otherMetrics = metricAudits.slice(3);

const metricsBoxesEl = this.dom.createChildOf(metricAuditsEl, 'div', 'lh-columns');
const metricsColumn1El = this.dom.createChildOf(metricsBoxesEl, 'div', 'lh-column');
const metricsColumn2El = this.dom.createChildOf(metricsBoxesEl, 'div', 'lh-column');

keyMetrics.forEach(item => {
metricsColumn1El.appendChild(this._renderMetric(item));
});
otherMetrics.forEach(item => {
metricsColumn2El.appendChild(this._renderMetric(item));
});

// 'Values are estimated and may vary' is used as the category description for PSI
Expand Down
51 changes: 34 additions & 17 deletions lighthouse-core/report/html/report-styles.css

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

Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ describe('PerfCategoryRenderer', () => {
let toggle;
const metricsSelector = '.lh-audit-group--metrics';
const toggleSelector = '.lh-metrics-toggle__input';
const magicSelector =
'.lh-metrics-toggle__input:checked ~ .lh-metrics-container .lh-metric__description';
const magicSelector = '.lh-metrics-toggle__input:checked ~ .lh-columns .lh-metric__description';
let getDescriptionsAfterCheckedToggle;

describe('works if there is a performance category', () => {
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-viewer/test/viewer-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe('Lighthouse Viewer', () => {
await viewerPage.goto(url);

// Wait for report to render.
await viewerPage.waitForSelector('.lh-metrics-container');
await viewerPage.waitForSelector('.lh-columns');

const interceptedUrl = new URL(interceptedRequest.url());
expect(interceptedUrl.origin + interceptedUrl.pathname)
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('Lighthouse Viewer', () => {
await viewerPage.goto(url);

// Wait for report to render.call out to PSI with specified categories
await viewerPage.waitForSelector('.lh-metrics-container');
await viewerPage.waitForSelector('.lh-columns');

const interceptedUrl = new URL(interceptedRequest.url());
expect(interceptedUrl.origin + interceptedUrl.pathname)
Expand Down

0 comments on commit 5f372ea

Please sign in to comment.