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: final metrics display, icons, whitespace polish #5130

Merged
merged 19 commits into from
May 7, 2018

Conversation

@paulirish
Copy link
Member Author

ah this branch is lacking a rebase. let me take care of that before trying to review it. :/

@vinamratasingal-zz
Copy link

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?

Copy link
Collaborator

@patrickhulce patrickhulce left a 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. ';
Copy link
Collaborator

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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent

@paulirish
Copy link
Member Author

conflict party ahead 😭

all sorted now.

@paulirish
Copy link
Member Author

@vinamratasingal

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?

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.

@vinamratasingal-zz
Copy link

@paulirish thanks for the explanation! SGTM on tweaking :)

Copy link
Collaborator

@patrickhulce patrickhulce left a 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');
Copy link
Collaborator

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Kinda separate but hey. I mentioned it on chat yesterday

before:
image

after:

image

@@ -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');
Copy link
Collaborator

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?

Copy link
Member Author

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;
Copy link
Collaborator

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?

Copy link
Member Author

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:

const wastedMsValues = opportunityAudits.map(audit => this._getWastedMs(audit));
const maxWaste = Math.max(...wastedMsValues);

image

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');
Copy link
Collaborator

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?

Copy link
Member Author

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));
Copy link
Collaborator

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 ;)

Copy link
Member Author

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) {
Copy link
Member

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', () => {
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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?

@paulirish
Copy link
Member Author

paulirish commented May 7, 2018 via email

@paulirish
Copy link
Member Author

@brendankenny @patrickhulce rebased. can you rereview since this is front of the rest?

@paulirish
Copy link
Member Author

And FWIW #5151 #5137 #5136 are rebased against imaginary branches right now because the conflicts just got REAL and i'll have to do the squash merge technique for them. :)

Copy link
Member

@brendankenny brendankenny left a 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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not |undefined anymore

Copy link
Member

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 :)

Copy link
Member Author

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;
Copy link
Member

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?

Copy link
Member Author

@paulirish paulirish May 7, 2018

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;

Copy link
Member

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

Copy link
Member Author

@paulirish paulirish May 7, 2018

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)

Copy link
Member

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?

Copy link
Member

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);
Copy link
Member

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_VALUEs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. only 1 visible opportunity and it was an error.

but it works out:

image

well. i guess we'd eventually set elem.style.width = NaN%`

:)

Copy link
Collaborator

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

Copy link
Member

@brendankenny brendankenny left a 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

@paulirish paulirish merged commit 1750799 into master May 7, 2018
@paulirish
Copy link
Member Author

thanks everyone for the reviews. appreciate it!

@paulirish paulirish deleted the metricsdisplay branch May 7, 2018 21:48
@paulirish paulirish restored the metricsdisplay branch May 7, 2018 21:48
@paulirish paulirish deleted the metricsdisplay branch June 15, 2018 23:23
kdzwinel pushed a commit to kdzwinel/lighthouse that referenced this pull request Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants