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: rework the DOM of audits #5045

Merged
merged 3 commits into from
Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ConsistentlyInteractive extends MetricArtifact {
}

/**
* @param {Map<Node, LH.Gatherer.Simulation.NodeTiming>} nodeTimings
Copy link
Member

Choose a reason for hiding this comment

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

any chance you can rebase? :)

Copy link
Member

Choose a reason for hiding this comment

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

oh, jk, this is additional updates?

Copy link
Member Author

Choose a reason for hiding this comment

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

ya additional.

* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
* @return {number}
*/
static getLastLongTaskEndTime(nodeTimings, duration = 50) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LanternFirstCPUIdle extends LanternConsistentlyInteractive {

/**
*
* @param {Map<Node, LH.Gatherer.Simulation.NodeTiming>} nodeTimings
* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
* @param {number} fmpTimeInMs
*/
static getFirstCPUIdleWindowStart(nodeTimings, fmpTimeInMs, longTaskLength = 50) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SpeedIndex extends MetricArtifact {
* different methods. Read more in the evaluation doc.
*
* @see https://docs.google.com/document/d/1qJWXwxoyVLVadezIp_Tgdk867G3tDNkkVRvUJSH3K1E/edit#
* @param {Map<Node, LH.Gatherer.Simulation.NodeTiming>} nodeTimings
* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
* @param {number} fcpTimeInMs
* @return {number}
*/
Expand Down
32 changes: 11 additions & 21 deletions lighthouse-core/report/html/renderer/category-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ class CategoryRenderer {
* @param {!ReportRenderer.AuditJSON} audit
* @return {!Element}
*/
_renderAuditScore(audit) {
const tmpl = this.dom.cloneTemplate('#tmpl-lh-audit-score', this.templateContext);
renderAudit(audit) {
const tmpl = this.dom.cloneTemplate('#tmpl-lh-audit', this.templateContext);
const auditEl = this.dom.find('.lh-audit', tmpl);

const scoreDisplayMode = audit.result.scoreDisplayMode;
const description = audit.result.helpText;
Expand All @@ -39,25 +40,24 @@ class CategoryRenderer {
}

if (audit.result.debugString) {
const debugStrEl = tmpl.appendChild(this.dom.createElement('div', 'lh-debug'));
const debugStrEl = auditEl.appendChild(this.dom.createElement('div', 'lh-debug'));
debugStrEl.textContent = audit.result.debugString;
}

// Append audit details to header section so the entire audit is within a <details>.
const header = /** @type {!HTMLDetailsElement} */ (this.dom.find('.lh-score__header', tmpl));
const header = /** @type {!HTMLDetailsElement} */ (this.dom.find('.lh-audit__header', auditEl));
if (audit.result.details && audit.result.details.type) {
header.appendChild(this.detailsRenderer.render(audit.result.details));
}

const scoreEl = this.dom.find('.lh-score', tmpl);
if (audit.result.informative) {
scoreEl.classList.add('lh-score--informative');
auditEl.classList.add('lh-audit--informative');
}
if (audit.result.manual) {
scoreEl.classList.add('lh-score--manual');
auditEl.classList.add('lh-audit--manual');
}

return this._populateScore(tmpl, audit.result.score, scoreDisplayMode, title, description);
return this._populateScore(auditEl, audit.result.score, scoreDisplayMode, title, description);
}

/**
Expand All @@ -76,9 +76,9 @@ class CategoryRenderer {
valueEl.classList.add(`lh-score__value--${Util.calculateRating(score)}`,
`lh-score__value--${scoreDisplayMode}`);

this.dom.find('.lh-score__title', element).appendChild(
this.dom.find('.lh-audit__title, .lh-category-header__title', element).appendChild(
this.dom.convertMarkdownCodeSnippets(title));
this.dom.find('.lh-score__description', element)
this.dom.find('.lh-audit__description, .lh-category-header__description', element)
.appendChild(this.dom.convertMarkdownLinkSnippets(description));

return /** @type {!Element} **/ (element);
Expand All @@ -89,7 +89,7 @@ class CategoryRenderer {
* @return {!Element}
*/
renderCategoryScore(category) {
const tmpl = this.dom.cloneTemplate('#tmpl-lh-category-score', this.templateContext);
const tmpl = this.dom.cloneTemplate('#tmpl-lh-category-header', this.templateContext);

const gaugeContainerEl = this.dom.find('.lh-score__gauge', tmpl);
const gaugeEl = this.renderScoreGauge(category);
Expand All @@ -99,16 +99,6 @@ class CategoryRenderer {
return this._populateScore(tmpl, score, 'numeric', name, description);
}

/**
* @param {!ReportRenderer.AuditJSON} audit
* @return {!Element}
*/
renderAudit(audit) {
const element = this.dom.createElement('div', 'lh-audit');
element.appendChild(this._renderAuditScore(audit));
Copy link
Member

Choose a reason for hiding this comment

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

lol

return element;
}

/**
* Renders the group container for a group of audits. Individual audit elements can be added
* directly to the returned element.
Expand Down
67 changes: 20 additions & 47 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.

4 changes: 3 additions & 1 deletion lighthouse-core/report/html/report-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

<div id="lh-log"></div>

<script>%%LIGHTHOUSE_JAVASCRIPT%%</script>
<script>%%LIGHTHOUSE_JAVASCRIPT%%
//# sourceURL=report-renderer-js.js
Copy link
Member

Choose a reason for hiding this comment

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

does this work with anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

it enables a few things in devtools. like code coverage some other features that are wonky with inline <script> tags.
you can also just ctrl-p into the JS rather than jump to some line in the big huge HTML.

</script>
<script>window.__LIGHTHOUSE_JSON__ = %%LIGHTHOUSE_JSON%%;</script>
<script>
window.addEventListener('DOMContentLoaded', _ => {
Expand Down
Loading