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(redesign): score icons, audit group headers, colors #8222

Merged
merged 44 commits into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c00d6f1
renderer: update gauges
connorjclark Apr 10, 2019
3b42a26
unsticky for now
connorjclark Apr 10, 2019
7dd6eb4
score scale
connorjclark Apr 10, 2019
75881d3
tweak score scale
connorjclark Apr 10, 2019
80579e9
tweak gauge outline
connorjclark Apr 10, 2019
459afd2
font size and line height for doc
connorjclark Apr 10, 2019
fad00c9
narrow header width
connorjclark Apr 10, 2019
1d9d2ac
add wrapper to category so that line sep spans width of page
connorjclark Apr 10, 2019
0fb2be2
better cat wrapper. meow
connorjclark Apr 10, 2019
86fbabf
fix paddinng in header
connorjclark Apr 10, 2019
6db4bee
Section header text
connorjclark Apr 10, 2019
9e68ea5
section header margin
connorjclark Apr 10, 2019
1846132
make score scale round
connorjclark Apr 10, 2019
743ed49
fix gauge width
connorjclark Apr 10, 2019
b3da26b
fix gauge size and arc
connorjclark Apr 10, 2019
6ce6bcf
Merge branch 'master' into report-ui-gauges
paulirish Apr 12, 2019
3a037c3
first pass
connorjclark Apr 12, 2019
a952a09
metric rows
connorjclark Apr 12, 2019
acb2db4
slightly better metric/audit coloring
connorjclark Apr 12, 2019
d4137ba
orange
connorjclark Apr 12, 2019
91702bf
use more new colors
connorjclark Apr 12, 2019
23f30a1
add score icon for opps
connorjclark Apr 12, 2019
0a8b6ea
manual and na
connorjclark Apr 12, 2019
5cb289d
remove some unused vars
connorjclark Apr 12, 2019
f624b71
contrast colors and antialias
connorjclark Apr 12, 2019
e60a367
Merge branch 'master' into report-ui-audit-results
connorjclark Apr 13, 2019
76f8e62
show description for clump audit groups. refactor header components
connorjclark Apr 16, 2019
21bca9d
fix failing cat render tests
connorjclark Apr 16, 2019
623f5fd
fix failing psi tests
connorjclark Apr 16, 2019
c16f08b
fix lints
connorjclark Apr 16, 2019
157c7c9
fix tsc error
connorjclark Apr 16, 2019
bfe560d
regex
connorjclark Apr 16, 2019
c52892e
pr changes
connorjclark Apr 17, 2019
0c094a3
move em dash outside description span
connorjclark Apr 17, 2019
da242e5
Merge branch 'master' into report-ui-audit-results
connorjclark Apr 18, 2019
b642dac
square
connorjclark Apr 18, 2019
0dfe4c3
triangle
connorjclark Apr 18, 2019
d9203cc
--color-(average, pass, fail)
connorjclark Apr 18, 2019
357292f
pr changes
connorjclark Apr 19, 2019
6b563f5
gauge circle size
connorjclark Apr 19, 2019
a171abe
--icon-shape-size
connorjclark Apr 19, 2019
dbf1a72
--score-shape-margin
connorjclark Apr 19, 2019
c35403a
dedupe some -big stuff
connorjclark Apr 19, 2019
769900a
Merge remote-tracking branch 'origin/master' into report-ui-audit-res…
connorjclark Apr 19, 2019
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
43 changes: 19 additions & 24 deletions lighthouse-core/report/html/renderer/category-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

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

Yay no more numbering!

populateAuditValues(audit, tmpl) {
const auditEl = this.dom.find('.lh-audit', tmpl);
auditEl.id = audit.result.id;
const scoreDisplayMode = audit.result.scoreDisplayMode;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The 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 group class names, nothing weird about that or worth commenting on; it's the clump header using group class names that's the aberration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

const auditGroupHeader = this.dom.createElement('div', 'lh-audit-group__header');
Copy link
Member

Choose a reason for hiding this comment

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

@brendankenny over in templates i think you left

<!-- TODO: group classes shouldn't be reused for clumps. -->

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

// Group header DOM roughly matches the clump header DOM, and that's OK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case I think i'd love it if we just leave a comment like

done

i may try combining these two into the sample template later, in the clean up phase.

Copy link
Member

Choose a reason for hiding this comment

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

i may try combining these two into the sample template later, in the clean up phase.

I was serious about the original TODO :)

TODO: group classes shouldn't be reused for clumps.

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 s/group/clump where that original comment is and be done with it 👍 👍


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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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})`;
Copy link
Member

Choose a reason for hiding this comment

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

i18n here too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@exterkamp help

Copy link
Member

Choose a reason for hiding this comment

The 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?
"17 Audits" becomes "(17)" <- this should be fine.

The concern here is non latin numerics, like ar:
"(17)" -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ class PerformanceCategoryRenderer extends CategoryRenderer {

/**
* @param {LH.ReportResult.AuditRef} audit
* @param {number} index
* @param {number} scale
* @return {Element}
*/
_renderOpportunity(audit, index, scale) {
_renderOpportunity(audit, scale) {
const oppTmpl = this.dom.cloneTemplate('#tmpl-lh-opportunity', this.templateContext);
const element = this.populateAuditValues(audit, index, oppTmpl);
const element = this.populateAuditValues(audit, oppTmpl);
element.id = audit.result.id;

if (!audit.result.details || audit.result.scoreDisplayMode === 'error') {
Expand Down Expand Up @@ -182,8 +181,7 @@ class PerformanceCategoryRenderer extends CategoryRenderer {

const headerEl = this.dom.find('.lh-load-opportunity__header', tmpl);
groupEl.appendChild(headerEl);
opportunityAudits.forEach((item, i) =>
groupEl.appendChild(this._renderOpportunity(item, i, scale)));
opportunityAudits.forEach(item => groupEl.appendChild(this._renderOpportunity(item, scale)));
groupEl.classList.add('lh-audit-group--load-opportunities');
element.appendChild(groupEl);
}
Expand All @@ -199,7 +197,7 @@ class PerformanceCategoryRenderer extends CategoryRenderer {

if (diagnosticAudits.length) {
const groupEl = this.renderAuditGroup(groups['diagnostics']);
diagnosticAudits.forEach((item, i) => groupEl.appendChild(this.renderAudit(item, i)));
diagnosticAudits.forEach(item => groupEl.appendChild(this.renderAudit(item)));
groupEl.classList.add('lh-audit-group--diagnostics');
element.appendChild(groupEl);
}
Expand Down
Loading