-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: final metrics display, icons, whitespace polish #5130
Conversation
ah this branch is lacking a rebase. let me take care of that before trying to review it. :/ |
Looking good, LGTM on the UI side. QQ: is it normal for the tooltip to lag a bit? i.e. I hover for a few seconds, and then the tooltip shows up? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conflict party ahead 😭
const metricAudits = category.audits.filter(audit => audit.group === 'metrics'); | ||
const metricAuditsEl = this.renderAuditGroup(groups['metrics'], {expandable: false}); | ||
const estValuesEl = this.dom.createChildOf(metricAuditsEl, 'div', | ||
'lh-metrics__disclaimer lh-metrics__disclaimer--head'); | ||
estValuesEl.textContent = 'Values are estimated and may vary. '; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aw I liked Estimated values may vary
, I guess it doesn't necessarily convey that all the values you see are estimated though 🤔
is the space at the end necessary? :)
const metricAudits = category.audits.filter(audit => audit.group === 'metrics'); | ||
const metricAuditsEl = this.renderAuditGroup(groups['metrics'], {expandable: false}); | ||
const estValuesEl = this.dom.createChildOf(metricAuditsEl, 'div', | ||
'lh-metrics__disclaimer lh-metrics__disclaimer--head'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent
all sorted now. |
@vinamratasingal
I'm set them to be only show up after your cursor has been hovering there for 900ms. When the number is too low, you get unintentional tooltips. I think the animation should take a little longer though. It's currently 150ms which is too fast given the long delay. Of course, all these parameters are tweakable. I do agree the tooltips feel a little funny atm. Hopefully we can tweak them to success. |
@paulirish thanks for the explanation! SGTM on tweaking :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good overall! hoping we can shrink some lines with defaulting :)
@@ -64,7 +64,7 @@ class CategoryRenderer { | |||
const tooltip = this.dom.createChildOf(textEl, 'div', 'lh-error-tooltip-content tooltip'); | |||
tooltip.textContent = audit.result.debugString || 'Report error: no audit information'; | |||
} else if (audit.result.debugString) { | |||
const debugStrEl = auditEl.appendChild(this.dom.createElement('div', 'lh-debug')); | |||
const debugStrEl = this.dom.createChildOf(titleEl, 'div', 'lh-debug'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive by restructuring? seems unrelated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -189,7 +190,7 @@ class CategoryRenderer { | |||
const notApplicableElem = this.renderAuditGroup({ | |||
title: `Not applicable`, | |||
}, {expandable: true, itemCount: this._getTotalAuditsLength(elements)}); | |||
notApplicableElem.classList.add('lh-audit-group--notapplicable'); | |||
notApplicableElem.classList.add('lh-audit-group--adorned', 'lh-audit-group--notapplicable'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a11y audits are the only unadorned audit-groups now then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a11y and seo audit groups don't get icons, yeah.
try { | ||
return audit.result.details.summary.wastedMs; | ||
} catch (e) { | ||
return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this return undefined? it doesn't seem like the undefined case is really handled well now though, this is only for errors anyhoo right? maybe it always returns wastedMs
or MIN_VALUE
to force it to bottom or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is all about oppos that have errored.
I don't return undefined because of:
lighthouse/lighthouse-core/report/html/renderer/performance-category-renderer.js
Lines 153 to 154 in cc5434b
const wastedMsValues = opportunityAudits.map(audit => this._getWastedMs(audit)); | |
const maxWaste = Math.max(...wastedMsValues); |
min_value wfm!
@@ -159,9 +177,11 @@ class PerformanceCategoryRenderer extends CategoryRenderer { | |||
const groupEl = this.renderAuditGroup(groups['diagnostics'], {expandable: false}); | |||
diagnosticAudits.forEach((item, i) => groupEl.appendChild(this.renderAudit(item, i))); | |||
groupEl.open = true; | |||
groupEl.classList.add('lh-audit-group--adorned', 'lh-audit-group--diagnostics'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like the unadorned case is far more common, WDYT about it being the default to avoid this churn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but i'll give it a shot.
@@ -425,7 +425,7 @@ <h1 class="leftnav__header__title">Lighthouse</h1> | |||
<template id="tmpl-lh-gauge"> | |||
<style> | |||
.lh-gauge__wrapper { | |||
--circle-size: calc(2.5 * var(--header-font-size)); | |||
--circle-size: calc(3 * var(--header-font-size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK Paul I'm feelin' a multiple more like 2.7350215
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hwi and I spent ~2 mins tweaking this one. :)
We use base-font-size to scale everything so devtools is just tighter by changing like 1 number. As such, this sorta thing happens. but it seems to work out.
@@ -89,7 +89,7 @@ class CategoryRenderer { | |||
* @param {!ReportRenderer.CategoryJSON} category | |||
* @return {!Element} | |||
*/ | |||
renderCategoryScore(category) { | |||
renderCategoryHeader(category) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
@@ -113,22 +113,6 @@ describe('CategoryRenderer', () => { | |||
category.description = prevDesc; | |||
}); | |||
|
|||
it('renders audits with debugString as failed', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a test for this that handles rendering of the new modes? e.g. I don't see an error one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh i'm not sure. :)
i'd like to do a followup once we have the 3 PRs landed (this one, scoreDisplayMode, and debugString -> warnings/errors/explanations) where we can try all the possibilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd like to do a followup
add to #5008?
sg. done.
|
@brendankenny @patrickhulce rebased. can you rereview since this is front of the rest? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some clarifying questions around Number.MIN_VALUE
:)
@@ -86,18 +85,30 @@ class PerformanceCategoryRenderer extends CategoryRenderer { | |||
return element; | |||
} | |||
|
|||
/** | |||
* @param {!ReportRenderer.AuditJSON} audit | |||
* @return {number|undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not |undefined
anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a comment why it's returning Number.MIN_VALUE
? Seems bizarre even with context :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure sg
*/ | ||
_getWastedMs(audit) { | ||
try { | ||
return audit.result.details.summary.wastedMs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the case where this won't be defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of one, but I'm okay adding a typeof check
like adding this on the line above?:
if (typeof audit.result.details.summary.wastedMs !== 'number') return Number.MIN_VALUE;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of one, but I'm okay adding a typeof check
oh, I'm just wondering how you end up in the catch block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't opportunities with an error not have a summary block?
(looks like it to me)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, cool, so only in those cases? I was worried there were other weird cases where we were inconsistent. Maybe add a note that this is for fallback for errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, maybe a more explicit if (audit.result.details && audit.result.details.summary) {return audit.result.details.summary.wastedMs;} else { return Number.MIN_VALUE;}
then?
if (opportunityAudits.length) { | ||
const maxWaste = Math.max(...opportunityAudits.map(audit => audit.result.rawValue)); | ||
const wastedMsValues = opportunityAudits.map(audit => this._getWastedMs(audit)); | ||
const maxWaste = Math.max(...wastedMsValues); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible for this to be all Number.MIN_VALUE
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my preference for "real fix" would be to explicitly handle error cases separately so we can assume they're all regular sane numbers
but for now, I have no strong preference other than clearly expressing a nonsense number in the error case, MIN_VALUE seemed more obviously nonsense then -1, if it creates too much other noise compared to -1 though, I'm fine with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last suggestion to make more explicit (plus earlier comment about adding a comment), but otherwise LGTM
thanks everyone for the reviews. appreciate it! |
screenshots
example reports:
https://disastrous-bears.surge.sh/cnn.html
https://disastrous-bears.surge.sh/dbwtester.html
https://disastrous-bears.surge.sh/errors.html
https://disastrous-bears.surge.sh/example.html
https://disastrous-bears.surge.sh/paulirish.html
https://disastrous-bears.surge.sh/tinyhouse.html
https://disastrous-bears.surge.sh/z.devtools.cnn.html
https://disastrous-bears.surge.sh/z.devtools.dbwtester.html
https://disastrous-bears.surge.sh/z.devtools.errors.html
https://disastrous-bears.surge.sh/z.devtools.example.html
https://disastrous-bears.surge.sh/z.devtools.paulirish.html
https://disastrous-bears.surge.sh/z.devtools.tinyhouse.html