@@ -286,12 +286,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
286
286
display : none;
287
287
}
288
288
289
- @media only screen and (max-width : 800 px ) {
289
+ @media only screen and (max-width : 768 px ) {
290
290
.grid-container {
291
291
margin : 0 1em ;
292
292
}
293
-
294
- /* --- RESPONSIVE TABLE STYLES --- */
295
293
.table-title-mobile {
296
294
display : block;
297
295
}
@@ -327,7 +325,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
327
325
border-radius : 5px ;
328
326
margin-bottom : 1em ;
329
327
box-shadow : 0 2px 4px rgba (0 , 0 , 0 , 0.05 );
330
- overflow : hidden; /* To contain the floated pseudo-elements */
328
+ overflow : hidden;
331
329
}
332
330
.score-table .subtotal-row ,
333
331
.score-table tfoot tr {
@@ -342,7 +340,6 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
342
340
line-height : 1.5 ;
343
341
}
344
342
.score-table td [data-label = "Interop" ] {
345
- /* Hide the separate Interop row in our new layout */
346
343
display : none;
347
344
}
348
345
.score-table td : last-child {
@@ -353,7 +350,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
353
350
font-weight : bold;
354
351
background-color : hsl (0 0% 0% / 5% );
355
352
border-bottom : 1px solid # ddd ;
356
- padding : 0 ; /* Padding is now on the inner element */
353
+ padding : 0 ;
357
354
}
358
355
.score-table td : first-child .card-header-mobile {
359
356
padding : 0.75em ;
@@ -375,7 +372,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
375
372
content : "Progress" ;
376
373
}
377
374
}
378
- @media only screen and (min-width : 801 px ) {
375
+ @media only screen and (min-width : 769 px ) {
379
376
.score-table tbody > tr : nth-child (odd) {
380
377
background : hsl (0 0% 0% / 5% );
381
378
}
@@ -545,7 +542,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
545
542
< td >
546
543
< div class ="card-header-mobile ">
547
544
< a href$ ="[[getTestsURL(rowName, stable)]] "> [[getRowInfo(rowName, 'description')]]</ a >
548
- < span class ="interop-score-mobile "> [[getInteropScoreForFeature(rowName, stable)]]</ span >
545
+ < span
546
+ class ="interop-score-mobile "
547
+ style$ ="[[getScoreStyle(rowName, stable)]] "
548
+ > [[getInteropScoreForFeature(rowName, stable)]]</ span >
549
549
</ div >
550
550
</ td >
551
551
< template is ="dom-repeat " items ="{{getYearProp('browserInfo')}} " as ="browserInfo ">
@@ -563,7 +563,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
563
563
< td >
564
564
< div class ="card-header-mobile ">
565
565
< strong > TOTAL</ strong >
566
- < span class ="interop-score-mobile "> [[getInteropSubtotalScore(section, stable)]]</ span >
566
+ < span
567
+ class ="interop-score-mobile "
568
+ style$ ="[[getSubtotalScoreStyle(section, stable)]] "
569
+ > [[getInteropSubtotalScore(section, stable)]]</ span >
567
570
</ div >
568
571
</ td >
569
572
< template is ="dom-repeat " items ="{{getYearProp('browserInfo')}} " as ="browserInfo ">
@@ -659,10 +662,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
659
662
return {
660
663
year : String ,
661
664
embedded : Boolean ,
662
- stable : {
663
- type : Boolean ,
664
- observer : '_stableChanged' ,
665
- } ,
665
+ stable : Boolean ,
666
666
feature : String ,
667
667
features : {
668
668
type : Array ,
@@ -768,33 +768,51 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
768
768
afterNextRender ( this , this . addSortEvents ) ;
769
769
}
770
770
771
- _stableChanged ( ) {
772
- this . updateSummaryScores ( ) ;
773
- }
771
+ calculateColor ( score ) {
772
+ const gradient = [
773
+ // Red.
774
+ { scale : 0 , color : [ 250 , 0 , 0 ] } ,
775
+ // Orange.
776
+ { scale : 33.33 , color : [ 250 , 125 , 0 ] } ,
777
+ // Yellow.
778
+ { scale : 66.67 , color : [ 220 , 220 , 0 ] } ,
779
+ // Green.
780
+ { scale : 100 , color : [ 0 , 160 , 0 ] } ,
781
+ ] ;
774
782
775
- async updateSummaryScores ( ) {
776
- const scoreElements = this . shadowRoot . querySelectorAll ( '.interop-score-mobile' ) ;
777
- const scores = this . stable ? this . scores . stable : this . scores . experimental ;
778
- const summaryFeatureName = this . dataManager . getYearProp ( 'summaryFeatureName' ) ;
779
- console . log ( this . scores ) ;
780
- // If the elements have not rendered yet, don't update the scores.
781
- if ( ( ! this . isMobileScoresView && scoreElements . length !== scores . length ) ||
782
- ( this . isMobileScoresView && scoreElements . length !== scores . length + 1 ) ) {
783
- return ;
783
+ let color1 , color2 ;
784
+ for ( let i = 1 ; i < gradient . length ; i ++ ) {
785
+ if ( score <= gradient [ i ] . scale ) {
786
+ color1 = gradient [ i - 1 ] ;
787
+ color2 = gradient [ i ] ;
788
+ break ;
789
+ }
784
790
}
785
- // // Update interop summary number first.
786
- // this.updateSummaryScore(scoreElements[0], scores[scores.length - 1][summaryFeatureName]);
787
- // // Update the rest of the browser scores.
788
- // for (let i = 1; i < scores.length; i++) {
789
- // this.updateSummaryScore(scoreElements[i], scores[i - 1][summaryFeatureName]);
790
- // }
791
-
792
- // // Update investigation summary separately.
793
- // if (this.shouldDisplayInvestigationNumber()) {
794
- // const investigationNumber = this.shadowRoot.querySelector('#investigationNumber');
795
- // this.updateSummaryScore(
796
- // investigationNumber, this.dataManager.getYearProp('investigationTotalScore'));
797
- // }
791
+ const colorWeight = ( ( score - color1 . scale ) / ( color2 . scale - color1 . scale ) ) ;
792
+ const color = [
793
+ Math . round ( color1 . color [ 0 ] * ( 1 - colorWeight ) + color2 . color [ 0 ] * colorWeight ) ,
794
+ Math . round ( color1 . color [ 1 ] * ( 1 - colorWeight ) + color2 . color [ 1 ] * colorWeight ) ,
795
+ Math . round ( color1 . color [ 2 ] * ( 1 - colorWeight ) + color2 . color [ 2 ] * colorWeight ) ,
796
+ ] ;
797
+
798
+ return [
799
+ `rgb(${ color [ 0 ] } , ${ color [ 1 ] } , ${ color [ 2 ] } )` ,
800
+ `rgba(${ color [ 0 ] } , ${ color [ 1 ] } , ${ color [ 2 ] } , 0.15)` ,
801
+ ] ;
802
+ }
803
+
804
+ getSubtotalScoreStyle ( section , stable ) {
805
+ const interopIndex = this . dataManager . getYearProp ( 'numBrowsers' ) ;
806
+ const score = this . getNumericalSubtotalScore ( interopIndex , section , stable ) ;
807
+ const colors = this . calculateColor ( score ) ;
808
+ return `color: color-mix(in lch, ${ colors [ 0 ] } 70%, black); background-color: ${ colors [ 1 ] } ` ;
809
+ }
810
+
811
+ getScoreStyle ( feature , stable ) {
812
+ const interopIndex = this . dataManager . getYearProp ( 'numBrowsers' ) ;
813
+ const score = this . getNumericalBrowserScoreByFeature ( interopIndex , feature , stable ) ;
814
+ const colors = this . calculateColor ( score ) ;
815
+ return `color: color-mix(in lch, ${ colors [ 0 ] } 70%, black); background-color: ${ colors [ 1 ] } ` ;
798
816
}
799
817
800
818
// Add the on-click handlers for sorting by a specific table header.
@@ -897,23 +915,27 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
897
915
return `${ ( total / 10 ) . toFixed ( 1 ) } %` ;
898
916
}
899
917
900
- getSubtotalScore ( browserIndex , section , stable ) {
918
+ getNumericalSubtotalScore ( browserIndex , section , stable ) {
901
919
const scores = stable ? this . scores . stable : this . scores . experimental ;
902
920
const totalScore = section . rows . reduce ( ( sum , rowName ) => {
903
921
return sum + scores [ browserIndex ] [ rowName ] ;
904
922
} , 0 ) ;
905
923
const avg = Math . floor ( totalScore / section . rows . length ) / 10 ;
924
+ return avg ;
925
+ }
926
+
927
+ getSubtotalScore ( browserIndex , section , stable ) {
928
+ const score = this . getNumericalSubtotalScore ( browserIndex , section , stable ) ;
906
929
// Don't display decimal places for a 100% score.
907
- if ( avg >= 100 ) {
930
+ if ( score >= 100 ) {
908
931
return '100%' ;
909
932
}
910
- return `${ avg . toFixed ( 1 ) } %` ;
933
+ return `${ score . toFixed ( 1 ) } %` ;
911
934
}
912
935
913
936
getInteropSubtotalScore ( section , isStable ) {
914
937
const numBrowsers = this . getYearProp ( 'numBrowsers' ) ;
915
- const score = this . getSubtotalScore ( numBrowsers , section , isStable ) ;
916
- return score ;
938
+ return this . getSubtotalScore ( numBrowsers , section , isStable ) ;
917
939
}
918
940
919
941
getSummaryOptionText ( ) {
@@ -932,8 +954,8 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
932
954
return ! scoreAsGroup && ! this . showBrowserIcons ( index ) ;
933
955
}
934
956
935
- getBrowserScoreForFeature ( browserIndex , feature ) {
936
- const scores = this . stable ? this . scores . stable : this . scores . experimental ;
957
+ getBrowserScoreForFeature ( browserIndex , feature , stable ) {
958
+ const scores = stable ? this . scores . stable : this . scores . experimental ;
937
959
const score = scores [ browserIndex ] [ feature ] ;
938
960
// Don't display decimal places for a 100% score.
939
961
if ( score / 10 >= 100 ) {
@@ -942,15 +964,15 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
942
964
return `${ ( score / 10 ) . toFixed ( 1 ) } %` ;
943
965
}
944
966
945
- getInteropScoreForFeature ( feature , isStable ) {
967
+ getInteropScoreForFeature ( feature , stable ) {
946
968
const numBrowsers = this . getYearProp ( 'numBrowsers' ) ;
947
- return this . getBrowserScoreForFeature ( numBrowsers , feature , isStable ) ;
969
+ return this . getBrowserScoreForFeature ( numBrowsers , feature , stable ) ;
948
970
}
949
971
950
972
// getNumericalBrowserScoreByFeature returns the same score as
951
973
// getBrowserScoreForFeature but as a number instead of a string
952
- getNumericalBrowserScoreByFeature ( browserIndex , feature ) {
953
- const scores = this . stable ? this . scores . stable : this . scores . experimental ;
974
+ getNumericalBrowserScoreByFeature ( browserIndex , feature , stable ) {
975
+ const scores = stable ? this . scores . stable : this . scores . experimental ;
954
976
const score = scores [ browserIndex ] [ feature ] ;
955
977
const roundedScore = Math . round ( score * 100 ) / 100 ;
956
978
return roundedScore / 10 ;
@@ -974,9 +996,9 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
974
996
}
975
997
976
998
const summaryFeatureName = this . getYearProp ( 'summaryFeatureName' ) ;
977
- this . totalChromium = this . getBrowserScoreForFeature ( 0 , summaryFeatureName ) ;
978
- this . totalFirefox = this . getBrowserScoreForFeature ( 1 , summaryFeatureName ) ;
979
- this . totalSafari = this . getBrowserScoreForFeature ( 2 , summaryFeatureName ) ;
999
+ this . totalChromium = this . getBrowserScoreForFeature ( 0 , summaryFeatureName , this . stable ) ;
1000
+ this . totalFirefox = this . getBrowserScoreForFeature ( 1 , summaryFeatureName , this . stable ) ;
1001
+ this . totalSafari = this . getBrowserScoreForFeature ( 2 , summaryFeatureName , this . stable ) ;
980
1002
}
981
1003
982
1004
updateUrlParams ( embedded , stable , feature , isMobileScoresView ) {
@@ -1141,7 +1163,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
1141
1163
const individualScores = [ ] ;
1142
1164
for ( let i = 0 ; i < rows . length ; i ++ ) {
1143
1165
const feature = rows [ i ] ;
1144
- individualScores [ i ] = [ feature , this . getNumericalBrowserScoreByFeature ( browserIndex , feature ) ] ;
1166
+ individualScores [ i ] = [
1167
+ feature ,
1168
+ this . getNumericalBrowserScoreByFeature ( browserIndex , feature , this . stable )
1169
+ ] ;
1145
1170
}
1146
1171
individualScores . sort ( ( a , b ) => a [ 1 ] - b [ 1 ] ) ;
1147
1172
for ( let i = 0 ; i < individualScores . length ; i ++ ) {
0 commit comments