-
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(redesign): score icons, audit group headers, colors #8222
Changes from 38 commits
c00d6f1
3b42a26
7dd6eb4
75881d3
80579e9
459afd2
fad00c9
1d9d2ac
0fb2be2
86fbabf
6db4bee
9e68ea5
1846132
743ed49
b3da26b
6ce6bcf
3a037c3
a952a09
acb2db4
d4137ba
91702bf
23f30a1
0a8b6ea
5cb289d
f624b71
e60a367
76f8e62
21bca9d
623f5fd
c16f08b
157c7c9
bfe560d
c52892e
0c094a3
da242e5
b642dac
0dfe4c3
d9203cc
357292f
6b563f5
a171abe
dbf1a72
c35403a
769900a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,22 +54,20 @@ class CategoryRenderer { | |
|
||
/** | ||
* @param {LH.ReportResult.AuditRef} audit | ||
* @param {number} index | ||
* @return {Element} | ||
*/ | ||
renderAudit(audit, index) { | ||
renderAudit(audit) { | ||
const tmpl = this.dom.cloneTemplate('#tmpl-lh-audit', this.templateContext); | ||
return this.populateAuditValues(audit, index, tmpl); | ||
return this.populateAuditValues(audit, tmpl); | ||
} | ||
|
||
/** | ||
* Populate an DOM tree with audit details. Used by renderAudit and renderOpportunity | ||
* @param {LH.ReportResult.AuditRef} audit | ||
* @param {number} index | ||
* @param {DocumentFragment} tmpl | ||
* @return {Element} | ||
*/ | ||
populateAuditValues(audit, index, tmpl) { | ||
populateAuditValues(audit, tmpl) { | ||
const auditEl = this.dom.find('.lh-audit', tmpl); | ||
auditEl.id = audit.result.id; | ||
const scoreDisplayMode = audit.result.scoreDisplayMode; | ||
|
@@ -109,7 +107,6 @@ class CategoryRenderer { | |
header.appendChild(elem); | ||
} | ||
} | ||
this.dom.find('.lh-audit__index', auditEl).textContent = `${index + 1}`; | ||
|
||
// Add chevron SVG to the end of the summary | ||
this.dom.find('.lh-chevron-container', auditEl).appendChild(this._createChevron()); | ||
|
@@ -193,16 +190,18 @@ class CategoryRenderer { | |
*/ | ||
renderAuditGroup(group) { | ||
const groupEl = this.dom.createElement('div', 'lh-audit-group'); | ||
const summaryEl = this.dom.createChildOf(groupEl, 'div'); | ||
const summaryInnerEl = this.dom.createChildOf(summaryEl, 'div', 'lh-audit-group__summary'); | ||
const headerEl = this.dom.createChildOf(summaryInnerEl, 'div', 'lh-audit-group__header'); | ||
|
||
// Group header DOM roughly matches the clump header DOM, and that's OK. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should remove this comment. See reasoning in earlier thread, but, more importantly, this wouldn't be the place to put the comment anyways :) This group header is using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
const auditGroupHeader = this.dom.createElement('div', 'lh-audit-group__header'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brendankenny over in templates i think you left
right here we're recreating a bit of dom which is nearly the same as the DOM we see in the clump template. I suppose that's OK at this point, but i just wanted to call it out. (These days I dont think we have any groups within non-passed clumps anymore so its a bit different) In this case I think i'd love it if we just leave a comment like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
done i may try combining these two into the sample template later, in the clean up phase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I was serious about the original TODO :)
They don't need to be the same thing, and we don't win anything by creating a grand unified clump-group theorem except a new headache for every point where they're almost but not quite the same thing :P Seriously, we'll save like two total lines of code and gain some extra conditionals and a bunch of head scratching later about why groups are sometimes what we call groups everywhere else and why they're sometimes something completely different. Rather than make a comment here, the clean up phase should just |
||
|
||
this.dom.createChildOf(auditGroupHeader, 'span', 'lh-audit-group__title') | ||
.textContent = group.title; | ||
if (group.description) { | ||
const auditGroupDescription = this.dom.createElement('div', 'lh-audit-group__description'); | ||
auditGroupDescription.appendChild(this.dom.convertMarkdownLinkSnippets(group.description)); | ||
groupEl.appendChild(auditGroupDescription); | ||
const descriptionEl = this.dom.convertMarkdownLinkSnippets(group.description); | ||
descriptionEl.classList.add('lh-audit-group__description'); | ||
auditGroupHeader.appendChild(descriptionEl); | ||
} | ||
headerEl.textContent = group.title; | ||
groupEl.appendChild(auditGroupHeader); | ||
|
||
return groupEl; | ||
} | ||
|
@@ -232,14 +231,12 @@ class CategoryRenderer { | |
|
||
/** @type {Array<Element>} */ | ||
const auditElements = []; | ||
// Continuous numbering across all groups. | ||
let index = 0; | ||
|
||
for (const [groupId, groupAuditRefs] of grouped) { | ||
if (groupId === notAGroup) { | ||
// Push not-grouped audits individually. | ||
for (const auditRef of groupAuditRefs) { | ||
auditElements.push(this.renderAudit(auditRef, index++)); | ||
auditElements.push(this.renderAudit(auditRef)); | ||
} | ||
continue; | ||
} | ||
|
@@ -248,7 +245,7 @@ class CategoryRenderer { | |
const groupDef = groupDefinitions[groupId]; | ||
const auditGroupElem = this.renderAuditGroup(groupDef); | ||
for (const auditRef of groupAuditRefs) { | ||
auditGroupElem.appendChild(this.renderAudit(auditRef, index++)); | ||
auditGroupElem.appendChild(this.renderAudit(auditRef)); | ||
} | ||
auditGroupElem.classList.add(`lh-audit-group--${groupId}`); | ||
auditElements.push(auditGroupElem); | ||
|
@@ -292,17 +289,15 @@ class CategoryRenderer { | |
|
||
const headerEl = this.dom.find('.lh-audit-group__header', clumpElement); | ||
const title = this._clumpTitles[clumpId]; | ||
headerEl.textContent = title; | ||
this.dom.find('.lh-audit-group__title', headerEl).textContent = title; | ||
if (description) { | ||
const markdownDescriptionEl = this.dom.convertMarkdownLinkSnippets(description); | ||
const auditGroupDescription = this.dom.createElement('div', 'lh-audit-group__description'); | ||
auditGroupDescription.appendChild(markdownDescriptionEl); | ||
clumpElement.appendChild(auditGroupDescription); | ||
const descriptionEl = this.dom.convertMarkdownLinkSnippets(description); | ||
descriptionEl.classList.add('lh-audit-group__description'); | ||
headerEl.appendChild(descriptionEl); | ||
} | ||
|
||
const itemCountEl = this.dom.find('.lh-audit-group__itemcount', clumpElement); | ||
// TODO(i18n): support multiple locales here | ||
itemCountEl.textContent = `${auditRefs.length} audits`; | ||
itemCountEl.textContent = `(${auditRefs.length})`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i18n here too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @exterkamp help There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one looks A-Okay because the final output is all numeric, correct? The concern here is non latin numerics, like ar: But afaik we already don't support that yet in LH or PSI consistently so I'd leave in the i18n TODO, but LGTM for now. |
||
|
||
// Add all audit results to the clump. | ||
const auditElements = auditRefs.map(this.renderAudit.bind(this)); | ||
|
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.
Yay no more numbering!