From 6b376a5d9b62369343191cbb5bb66ceb65043235 Mon Sep 17 00:00:00 2001 From: Eric Bidelman Date: Fri, 24 Feb 2017 22:27:02 -1000 Subject: [PATCH] Open aggregations when score < 1. Use orange for average rating --- lighthouse-core/report/handlebar-helpers.js | 4 ++-- lighthouse-core/report/styles/report.css | 6 ++++-- lighthouse-core/report/templates/report-template.html | 5 +++-- lighthouse-core/test/report/handlebar-helpers-test.js | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lighthouse-core/report/handlebar-helpers.js b/lighthouse-core/report/handlebar-helpers.js index fb7a40d441cf..285ba9bcb301 100644 --- a/lighthouse-core/report/handlebar-helpers.js +++ b/lighthouse-core/report/handlebar-helpers.js @@ -63,9 +63,9 @@ const handlebarHelpers = { return calculateRating(totalScore); }, - // Converts an aggregation's score to a pass/fail rating. + // Converts an aggregation's score to a rating that can be used for styling. getAggregationScoreRating: score => { - return score === 1 ? 'good' : 'poor'; + return calculateRating(Math.round(score * 100)); }, // Converts a value to a rating string, which can be used inside the report diff --git a/lighthouse-core/report/styles/report.css b/lighthouse-core/report/styles/report.css index 0f23c34f76e6..c5ea449d3afa 100644 --- a/lighthouse-core/report/styles/report.css +++ b/lighthouse-core/report/styles/report.css @@ -795,7 +795,7 @@ summary { align-items: flex-end; } -.subitem-result__good, .subitem-result__poor, .subitem-result__unknown { +.subitem-result__good, .subitem-result__average, .subitem-result__poor, .subitem-result__unknown { position: relative; display: block; overflow: hidden; @@ -807,7 +807,7 @@ summary { background-color: #000; } -.subitem-result__good::after, .subitem-result__poor::after, .subitem-result__unknown::after { +.subitem-result__good::after, .subitem-result__average:after, .subitem-result__poor::after, .subitem-result__unknown::after { content: ''; position: absolute; left: 0; @@ -821,6 +821,8 @@ summary { background: url('data:image/svg+xml;utf8,good') no-repeat 50% 50%; background-size: 12px; } + +.subitem-result__average:after, .subitem-result__poor::after { background: url('data:image/svg+xml;utf8,poor') no-repeat 50% 50%; background-size: 12px; diff --git a/lighthouse-core/report/templates/report-template.html b/lighthouse-core/report/templates/report-template.html index b89b6c166083..0c530b47c762 100644 --- a/lighthouse-core/report/templates/report-template.html +++ b/lighthouse-core/report/templates/report-template.html @@ -136,10 +136,11 @@

{{ this.name }}

{{#each this.score as |aggregation|}} -
+
{{#if aggregation.name }} -
+
diff --git a/lighthouse-core/test/report/handlebar-helpers-test.js b/lighthouse-core/test/report/handlebar-helpers-test.js index c0a1577cbd06..04e4a055500b 100644 --- a/lighthouse-core/test/report/handlebar-helpers-test.js +++ b/lighthouse-core/test/report/handlebar-helpers-test.js @@ -46,8 +46,8 @@ describe('Handlebar helpers', () => { it('`getAggregationScoreRating` calculates rating', () => { assert.equal(handlebarHelpers.getAggregationScoreRating(undefined), 'poor'); assert.equal(handlebarHelpers.getAggregationScoreRating(1), 'good'); - assert.equal(handlebarHelpers.getAggregationScoreRating(0.95), 'poor'); - assert.equal(handlebarHelpers.getAggregationScoreRating(0.50), 'poor'); + assert.equal(handlebarHelpers.getAggregationScoreRating(0.95), 'good'); + assert.equal(handlebarHelpers.getAggregationScoreRating(0.50), 'average'); assert.equal(handlebarHelpers.getAggregationScoreRating(0.10), 'poor'); }); });