-
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: link to calculator w/ values #10754
Conversation
|
lighthouse-core/report/html/renderer/performance-category-renderer.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(); |
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.
wouldnt this make a super good score for errors?
what happens if we pass along a null instead?
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.
sg. null!
lighthouse-core/report/html/renderer/performance-category-renderer.js
Outdated
Show resolved
Hide resolved
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.
very slick calc, this is going to be awesome!
lighthouse-core/report/html/renderer/performance-category-renderer.js
Outdated
Show resolved
Hide resolved
return [audit.id, value]; | ||
}); | ||
const params = new URLSearchParams(metricPairs); | ||
const url = new URL('https://googlechrome.github.io/lighthouse/scorecalc/'); |
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.
what the... where was the PR for this how does it work already? 😆
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.
what the... where was the PR for this how does it work already? 😆
Brendan turns on gh-pages
branch protection 😆
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.
@@ -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. ', |
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.
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.', |
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.
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 :)
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.
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
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.
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.
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.
@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 :)
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.
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 :)
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.
(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. :)
category.auditRefs.find(m => m.id === 'first-meaningful-paint'), | ||
]); | ||
const metricPairs = v5andv6metrics.map(audit => { | ||
const value = (audit.result.numericValue || 0).toString(); |
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.
// Add link to score calculator | ||
const calculatorLink = this.dom.createChildOf(estValuesEl, 'a'); | ||
calculatorLink.textContent = strings.calculatorLink; | ||
const v5andv6metrics = /** @type {LH.ReportResult.AuditRef[]} */ ([ |
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.
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 :)
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.
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. ', |
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.
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. */ |
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'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?
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.
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 |
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.
wdyt about splitting out into a function getScoringCalculatorHref(auditRefs): string
?
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.
done
Co-authored-by: Connor Clark <[email protected]> Co-authored-by: Patrick Hulce <[email protected]>
i'd like the url to specify the scoring guide ( 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 |
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. |
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.
LGTM 🎉
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.
otherwise LGTM
const href = renderer._getScoringCalculatorHref(categoryClone.auditRefs); | ||
expect(href).toContain('largest-contentful-paint=null'); | ||
}); | ||
}); |
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.
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)
this link needs to open in a new window |
@@ -614,6 +614,10 @@ | |||
color: var(--color-gray-700); | |||
} | |||
|
|||
.lh-calclink::before { | |||
content: ' '; |
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.
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.
ref #10726