@@ -547,7 +547,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
547
547
< a href$ ="[[getTestsURL(rowName, stable)]] "> [[getRowInfo(rowName, 'description')]]</ a >
548
548
< span
549
549
class ="interop-score-mobile "
550
- style$ ="[[_getScoreStyle (rowName, stable)]] "
550
+ style$ ="[[getScoreStyle (rowName, stable)]] "
551
551
> [[getInteropScoreForFeature(rowName, stable)]]</ span >
552
552
</ div >
553
553
</ td >
@@ -566,7 +566,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
566
566
< td >
567
567
< div class ="card-header-mobile ">
568
568
< 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 >
570
573
</ div >
571
574
</ td >
572
575
< template is ="dom-repeat " items ="{{getYearProp('browserInfo')}} " as ="browserInfo ">
@@ -768,7 +771,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
768
771
afterNextRender ( this , this . addSortEvents ) ;
769
772
}
770
773
771
- calculateColor ( score ) {
774
+ calculateColor ( score ) {
772
775
const gradient = [
773
776
// Red.
774
777
{ scale : 0 , color : [ 250 , 0 , 0 ] } ,
@@ -801,15 +804,16 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
801
804
] ;
802
805
}
803
806
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 ) {
811
815
const interopIndex = this . dataManager . getYearProp ( 'numBrowsers' ) ;
812
- const score = this . getNumericalBrowserScoreByFeature ( interopIndex , feature ) ;
816
+ const score = this . getNumericalBrowserScoreByFeature ( interopIndex , feature , stable ) ;
813
817
const colors = this . calculateColor ( score ) ;
814
818
return `color: color-mix(in lch, ${ colors [ 0 ] } 70%, black); background-color: ${ colors [ 1 ] } ` ;
815
819
}
@@ -914,23 +918,27 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
914
918
return `${ ( total / 10 ) . toFixed ( 1 ) } %` ;
915
919
}
916
920
917
- getSubtotalScore ( browserIndex , section , stable ) {
921
+ getNumericalSubtotalScore ( browserIndex , section , stable ) {
918
922
const scores = stable ? this . scores . stable : this . scores . experimental ;
919
923
const totalScore = section . rows . reduce ( ( sum , rowName ) => {
920
924
return sum + scores [ browserIndex ] [ rowName ] ;
921
925
} , 0 ) ;
922
926
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 ) ;
923
932
// Don't display decimal places for a 100% score.
924
- if ( avg >= 100 ) {
933
+ if ( score >= 100 ) {
925
934
return '100%' ;
926
935
}
927
- return `${ avg . toFixed ( 1 ) } %` ;
936
+ return `${ score . toFixed ( 1 ) } %` ;
928
937
}
929
938
930
939
getInteropSubtotalScore ( section , isStable ) {
931
940
const numBrowsers = this . getYearProp ( 'numBrowsers' ) ;
932
- const score = this . getSubtotalScore ( numBrowsers , section , isStable ) ;
933
- return score ;
941
+ return this . getSubtotalScore ( numBrowsers , section , isStable ) ;
934
942
}
935
943
936
944
getSummaryOptionText ( ) {
@@ -949,8 +957,8 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
949
957
return ! scoreAsGroup && ! this . showBrowserIcons ( index ) ;
950
958
}
951
959
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 ;
954
962
const score = scores [ browserIndex ] [ feature ] ;
955
963
// Don't display decimal places for a 100% score.
956
964
if ( score / 10 >= 100 ) {
@@ -961,12 +969,12 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
961
969
962
970
getInteropScoreForFeature ( feature , stable ) {
963
971
const numBrowsers = this . getYearProp ( 'numBrowsers' ) ;
964
- return this . getBrowserScoreForFeature ( numBrowsers , feature ) ;
972
+ return this . getBrowserScoreForFeature ( numBrowsers , feature , this . stable ) ;
965
973
}
966
974
967
975
// getNumericalBrowserScoreByFeature returns the same score as
968
976
// getBrowserScoreForFeature but as a number instead of a string
969
- getNumericalBrowserScoreByFeature ( browserIndex , feature ) {
977
+ getNumericalBrowserScoreByFeature ( browserIndex , feature , stable ) {
970
978
const scores = this . stable ? this . scores . stable : this . scores . experimental ;
971
979
const score = scores [ browserIndex ] [ feature ] ;
972
980
const roundedScore = Math . round ( score * 100 ) / 100 ;
@@ -991,9 +999,9 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
991
999
}
992
1000
993
1001
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 ) ;
997
1005
}
998
1006
999
1007
updateUrlParams ( embedded , stable , feature , isMobileScoresView ) {
@@ -1158,7 +1166,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
1158
1166
const individualScores = [ ] ;
1159
1167
for ( let i = 0 ; i < rows . length ; i ++ ) {
1160
1168
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
+ ] ;
1162
1173
}
1163
1174
individualScores . sort ( ( a , b ) => a [ 1 ] - b [ 1 ] ) ;
1164
1175
for ( let i = 0 ; i < individualScores . length ; i ++ ) {
0 commit comments