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: link to calculator w/ values #10754

Merged
merged 14 commits into from
May 13, 2020
Merged

report: link to calculator w/ values #10754

merged 14 commits into from
May 13, 2020

Conversation

paulirish
Copy link
Member

ref #10726

@paulirish paulirish requested a review from a team as a code owner May 12, 2020 06:30
@paulirish paulirish requested review from patrickhulce and removed request for a team May 12, 2020 06:30
@googlebot
Copy link

☹️ Sorry, but only Googlers may change the label cla: yes.

category.auditRefs.find(m => m.id === 'first-meaningful-paint'),
]);
const metricPairs = v5andv6metrics.map(audit => {
const value = (audit.result.numericValue || 0).toString();
Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldnt this make a super good score for errors?

what happens if we pass along a null instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

that
image

which actually isn't bad, something is obviously wrong and score goes to 0, so I agree we pass null and update score calc to show a ? or something when there's a NaN

Copy link
Member Author

Choose a reason for hiding this comment

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

sg. null!

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.

very slick calc, this is going to be awesome!

return [audit.id, value];
});
const params = new URLSearchParams(metricPairs);
const url = new URL('https://googlechrome.github.io/lighthouse/scorecalc/');
Copy link
Collaborator

Choose a reason for hiding this comment

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

what the... where was the PR for this how does it work already? 😆

Copy link
Member

Choose a reason for hiding this comment

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

what the... where was the PR for this how does it work already? 😆

Brendan turns on gh-pages branch protection 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -496,7 +496,9 @@ Util.i18n = null;
*/
Util.UIStrings = {
/** Disclaimer shown to users below the metric values (First Contentful Paint, Time to Interactive, etc) to warn them that the numbers they see will likely change slightly the next time they run Lighthouse. */
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics.',
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics. ',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics. ',
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics.',

Copy link
Collaborator

Choose a reason for hiding this comment

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

if we need spacing between these let's do CSS rather than affect the translations? I'm nearly certain translators would not preserve this space as critical to layout :)

Copy link
Member

Choose a reason for hiding this comment

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

Could we stick these strings together? Slightly more awkward to deal with, but "See calculator" could default link to https://googlechrome.github.io/lighthouse/scorecalc/ and then performance-category-renderer could enhance that by reaching into the string span, finding the calculator link and replacing it with the parameterized link

Copy link
Member Author

Choose a reason for hiding this comment

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

did with css spacing

@brendankenny part 2 of this (mentioned in #10726) is to just reuse the same 'perf score is calculated' link to do all of it.

Copy link
Member

Choose a reason for hiding this comment

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

@brendankenny part 2 of this (mentioned in #10726) is to just reuse the same 'perf score is calculated' link to do all of it.

FWIW we shouldn't really concat these i18n-wise, but I guess everyone will be getting English strings until they're translated anyways :)

Copy link
Member

Choose a reason for hiding this comment

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

FWIW we shouldn't really concat these i18n-wise, but I guess everyone will be getting English strings until they're translated anyways :)

actually I still don't understand how that idea precludes doing my idea or requires the current impl in the meantime (since the base string was just changed in #10725 and won't be translated anyways), but ok :)

Copy link
Member Author

Choose a reason for hiding this comment

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

(since the base string was just changed in #10725 and won't be translated anyways), but ok :)

that change is a noop to the TC pipeline, in fact. :)

lighthouse-core/report/html/renderer/util.js Outdated Show resolved Hide resolved
category.auditRefs.find(m => m.id === 'first-meaningful-paint'),
]);
const metricPairs = v5andv6metrics.map(audit => {
const value = (audit.result.numericValue || 0).toString();
Copy link
Collaborator

Choose a reason for hiding this comment

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

that
image

which actually isn't bad, something is obviously wrong and score goes to 0, so I agree we pass null and update score calc to show a ? or something when there's a NaN

// Add link to score calculator
const calculatorLink = this.dom.createChildOf(estValuesEl, 'a');
calculatorLink.textContent = strings.calculatorLink;
const v5andv6metrics = /** @type {LH.ReportResult.AuditRef[]} */ ([
Copy link
Member

Choose a reason for hiding this comment

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

would be good to not override tsc here and deal with the possible undefineds. The benefit is it'll be backward and forward (when we drop these metrics) compatible :)

Copy link
Member Author

Choose a reason for hiding this comment

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

k done

@@ -496,7 +496,9 @@ Util.i18n = null;
*/
Util.UIStrings = {
/** Disclaimer shown to users below the metric values (First Contentful Paint, Time to Interactive, etc) to warn them that the numbers they see will likely change slightly the next time they run Lighthouse. */
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics.',
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics. ',
Copy link
Member

Choose a reason for hiding this comment

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

Could we stick these strings together? Slightly more awkward to deal with, but "See calculator" could default link to https://googlechrome.github.io/lighthouse/scorecalc/ and then performance-category-renderer could enhance that by reaching into the string span, finding the calculator link and replacing it with the parameterized link

@@ -496,7 +496,9 @@ Util.i18n = null;
*/
Util.UIStrings = {
/** Disclaimer shown to users below the metric values (First Contentful Paint, Time to Interactive, etc) to warn them that the numbers they see will likely change slightly the next time they run Lighthouse. */
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics.',
varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics. ',
/** Text link pointing to the Lighthouse scoring calculator. This link immediately follows a sentence stating the performance score is calculated from the perf metrics. */
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if the second sentence adds much for the translators. Maybe something about it being an "interactive calculator that explains Lighthouse scoring"? Maybe unnecessary. But maybe add a suggestion about keeping it short?

Copy link
Member Author

Choose a reason for hiding this comment

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

thx

@@ -152,6 +152,23 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
const estValuesEl = this.dom.createChildOf(metricAuditsEl, 'div', 'lh-metrics__disclaimer');
const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimer);
estValuesEl.appendChild(disclaimerEl);

// Add link to score calculator
Copy link
Member

Choose a reason for hiding this comment

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

wdyt about splitting out into a function getScoringCalculatorHref(auditRefs): string?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@paulirish paulirish added the 6.0 label May 12, 2020
Co-authored-by: Connor Clark <[email protected]>
Co-authored-by: Patrick Hulce <[email protected]>
@connorjclark
Copy link
Collaborator

connorjclark commented May 12, 2020

i'd like the url to specify the scoring guide (6.0 vs 5.0 vs some future 8.0 ...)

and the device type (which varies the score)

both these features need to be added to the calc but that can come in the following days.


edit: #10763

@paulirish
Copy link
Member Author

i'd like the url to specify the scoring guide (6.0 vs 5.0 vs some future 8.0 ...)

and the device type (which varies the score)

both these features need to be added to the calc but that can come in the following days.

very fair. I'll put in a second PR for review. this feature is a little more invasive than we'd like because the perf renderer otherwise doesnt know about configSettings or the version.

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.

LGTM 🎉

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.

otherwise LGTM

const href = renderer._getScoringCalculatorHref(categoryClone.auditRefs);
expect(href).toContain('largest-contentful-paint=null');
});
});
Copy link
Member

Choose a reason for hiding this comment

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

would be good to add a check to the existing renders the metrics variance disclaimer as markdown test to check the generated DOM as well (beyond just a correct url)

@connorjclark
Copy link
Collaborator

this link needs to open in a new window

@@ -614,6 +614,10 @@
color: var(--color-gray-700);
}

.lh-calclink::before {
content: ' ';
Copy link
Collaborator

Choose a reason for hiding this comment

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

image

can you add a space another way

Copy link
Member Author

Choose a reason for hiding this comment

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

thank for catching. i tried a few ways and thought my padding solution was a bit extra. i remembered content but didnt test it. whoops

back to being extra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants