Skip to content

Commit ac1ae56

Browse files
author
DanielRyanSmith
committed
lint
1 parent 1adf48c commit ac1ae56

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

webapp/components/interop-dashboard.js

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
547547
<a href$="[[getTestsURL(rowName, stable)]]">[[getRowInfo(rowName, 'description')]]</a>
548548
<span
549549
class="interop-score-mobile"
550-
style$="[[_getScoreStyle(rowName, stable)]]"
550+
style$="[[getScoreStyle(rowName, stable)]]"
551551
>[[getInteropScoreForFeature(rowName, stable)]]</span>
552552
</div>
553553
</td>
@@ -566,7 +566,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
566566
<td>
567567
<div class="card-header-mobile">
568568
<strong>TOTAL</strong>
569-
<span class="interop-score-mobile">[[getInteropSubtotalScore(section, stable)]]</span>
569+
<span
570+
class="interop-score-mobile"
571+
style$="[[getSubtotalScoreStyle(section, stable)]]"
572+
>[[getInteropSubtotalScore(section, stable)]]</span>
570573
</div>
571574
</td>
572575
<template is="dom-repeat" items="{{getYearProp('browserInfo')}}" as="browserInfo">
@@ -768,7 +771,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
768771
afterNextRender(this, this.addSortEvents);
769772
}
770773

771-
calculateColor(score) {
774+
calculateColor(score) {
772775
const gradient = [
773776
// Red.
774777
{ scale: 0, color: [250, 0, 0] },
@@ -801,15 +804,16 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
801804
];
802805
}
803806

804-
/**
805-
* Generates a complete CSS style string for a score badge.
806-
* @param {number} score The numerical score.
807-
* @return {string} A CSS style string.
808-
*/
809-
_getScoreStyle(feature, _stable) {
810-
console.log('getting here?');
807+
getSubtotalScoreStyle(section, stable) {
808+
const interopIndex = this.dataManager.getYearProp('numBrowsers');
809+
const score = this.getNumericalSubtotalScore(interopIndex, section, stable);
810+
const colors = this.calculateColor(score);
811+
return `color: color-mix(in lch, ${colors[0]} 70%, black); background-color: ${colors[1]}`;
812+
}
813+
814+
getScoreStyle(feature, stable) {
811815
const interopIndex = this.dataManager.getYearProp('numBrowsers');
812-
const score = this.getNumericalBrowserScoreByFeature(interopIndex, feature);
816+
const score = this.getNumericalBrowserScoreByFeature(interopIndex, feature, stable);
813817
const colors = this.calculateColor(score);
814818
return `color: color-mix(in lch, ${colors[0]} 70%, black); background-color: ${colors[1]}`;
815819
}
@@ -914,23 +918,27 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
914918
return `${(total / 10).toFixed(1)}%`;
915919
}
916920

917-
getSubtotalScore(browserIndex, section, stable) {
921+
getNumericalSubtotalScore(browserIndex, section, stable) {
918922
const scores = stable ? this.scores.stable : this.scores.experimental;
919923
const totalScore = section.rows.reduce((sum, rowName) => {
920924
return sum + scores[browserIndex][rowName];
921925
}, 0);
922926
const avg = Math.floor(totalScore / section.rows.length) / 10;
927+
return avg;
928+
}
929+
930+
getSubtotalScore(browserIndex, section, stable) {
931+
const score = this.getNumericalSubtotalScore(browserIndex, section, stable);
923932
// Don't display decimal places for a 100% score.
924-
if (avg >= 100) {
933+
if (score >= 100) {
925934
return '100%';
926935
}
927-
return `${avg.toFixed(1)}%`;
936+
return `${score.toFixed(1)}%`;
928937
}
929938

930939
getInteropSubtotalScore(section, isStable) {
931940
const numBrowsers = this.getYearProp('numBrowsers');
932-
const score = this.getSubtotalScore(numBrowsers, section, isStable);
933-
return score;
941+
return this.getSubtotalScore(numBrowsers, section, isStable);
934942
}
935943

936944
getSummaryOptionText() {
@@ -949,8 +957,8 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
949957
return !scoreAsGroup && !this.showBrowserIcons(index);
950958
}
951959

952-
getBrowserScoreForFeature(browserIndex, feature) {
953-
const scores = this.stable ? this.scores.stable : this.scores.experimental;
960+
getBrowserScoreForFeature(browserIndex, feature, stable) {
961+
const scores = stable ? this.scores.stable : this.scores.experimental;
954962
const score = scores[browserIndex][feature];
955963
// Don't display decimal places for a 100% score.
956964
if (score / 10 >= 100) {
@@ -961,12 +969,12 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
961969

962970
getInteropScoreForFeature(feature, stable) {
963971
const numBrowsers = this.getYearProp('numBrowsers');
964-
return this.getBrowserScoreForFeature(numBrowsers, feature);
972+
return this.getBrowserScoreForFeature(numBrowsers, feature, this.stable);
965973
}
966974

967975
// getNumericalBrowserScoreByFeature returns the same score as
968976
// getBrowserScoreForFeature but as a number instead of a string
969-
getNumericalBrowserScoreByFeature(browserIndex, feature) {
977+
getNumericalBrowserScoreByFeature(browserIndex, feature, stable) {
970978
const scores = this.stable ? this.scores.stable : this.scores.experimental;
971979
const score = scores[browserIndex][feature];
972980
const roundedScore = Math.round(score * 100) / 100;
@@ -991,9 +999,9 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
991999
}
9921000

9931001
const summaryFeatureName = this.getYearProp('summaryFeatureName');
994-
this.totalChromium = this.getBrowserScoreForFeature(0, summaryFeatureName);
995-
this.totalFirefox = this.getBrowserScoreForFeature(1, summaryFeatureName);
996-
this.totalSafari = this.getBrowserScoreForFeature(2, summaryFeatureName);
1002+
this.totalChromium = this.getBrowserScoreForFeature(0, summaryFeatureName, this.stable);
1003+
this.totalFirefox = this.getBrowserScoreForFeature(1, summaryFeatureName, this.stable);
1004+
this.totalSafari = this.getBrowserScoreForFeature(2, summaryFeatureName, this.stable);
9971005
}
9981006

9991007
updateUrlParams(embedded, stable, feature, isMobileScoresView) {
@@ -1158,7 +1166,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
11581166
const individualScores = [];
11591167
for (let i = 0; i < rows.length; i++) {
11601168
const feature = rows[i];
1161-
individualScores[i] = [feature, this.getNumericalBrowserScoreByFeature(browserIndex, feature)];
1169+
individualScores[i] = [
1170+
feature,
1171+
this.getNumericalBrowserScoreByFeature(browserIndex, feature, this.stable)
1172+
];
11621173
}
11631174
individualScores.sort((a, b) => a[1] - b[1]);
11641175
for (let i = 0; i < individualScores.length; i++) {

0 commit comments

Comments
 (0)