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(dom-size): right-align the value column #6372

Merged
merged 2 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion lighthouse-core/audits/dobetterweb/dom-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class DOMSize extends Audit {
const headings = [
{key: 'statistic', itemType: 'text', text: str_(UIStrings.columnStatistic)},
{key: 'element', itemType: 'code', text: str_(UIStrings.columnElement)},
{key: 'value', itemType: 'text', text: str_(UIStrings.columnValue)},
{key: 'value', itemType: 'numeric', text: str_(UIStrings.columnValue)},
];

/** @type {Array<Object<string, LH.Audit.DetailsItem>>} */
Expand Down
12 changes: 12 additions & 0 deletions lighthouse-core/report/html/renderer/details-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class DetailsRenderer {
case 'opportunity':
// @ts-ignore - TODO(bckenny): Fix type hierarchy
return this._renderOpportunityTable(details);
case 'numeric':
return this._renderNumeric(/** @type {StringDetailsJSON} */ (details));
default: {
throw new Error(`Unknown type: ${details.type}`);
}
Expand Down Expand Up @@ -181,6 +183,16 @@ class DetailsRenderer {
return element;
}

/**
* @param {{value: string}} text
* @return {Element}
*/
_renderNumeric(text) {
const element = this._dom.createElement('div', 'lh-numeric');
element.textContent = text.value;
return element;
}

/**
* Create small thumbnail with scaled down image asset.
* If the supplied details doesn't have an image/* mimeType, then an empty span is returned.
Expand Down
3 changes: 2 additions & 1 deletion lighthouse-core/report/html/report-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,8 @@

.lh-table-column--bytes,
.lh-table-column--timespanMs,
.lh-table-column--ms {
.lh-table-column--ms,
.lh-table-column--numeric {
text-align: right;
}

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@
},
{
"key": "value",
"itemType": "text",
"itemType": "numeric",
"text": "Value"
}
],
Expand Down
2 changes: 1 addition & 1 deletion proto/sample_v2_round_trip.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@
"text": "Element"
},
{
"itemType": "text",
"itemType": "numeric",
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 I had to manually edit this one :'(

"key": "value",
"text": "Value"
}
Expand Down