@@ -768,6 +768,14 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
768768 afterNextRender ( this , this . addSortEvents ) ;
769769 }
770770
771+ /**
772+ * Generates a font and background color based on a score from 0 to 100.
773+ * The colors are calculated on a gradient from red to green.
774+ *
775+ * @param {number } score - The score, ranging from 0 to 100.
776+ * @returns {[string, string] } An array containing the font color as an RGB
777+ * string and the background color as an RGBA string with 15% opacity.
778+ */
771779 calculateColor ( score ) {
772780 const gradient = [
773781 // Red.
@@ -801,16 +809,16 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
801809 ] ;
802810 }
803811
804- getSubtotalScoreStyle ( section , stable ) {
812+ getSubtotalScoreStyle ( section , isStable ) {
805813 const interopIndex = this . dataManager . getYearProp ( 'numBrowsers' ) ;
806- const score = this . getNumericalSubtotalScore ( interopIndex , section , stable ) ;
814+ const score = this . getNumericalSubtotalScore ( interopIndex , section , isStable ) ;
807815 const colors = this . calculateColor ( score ) ;
808816 return `color: color-mix(in lch, ${ colors [ 0 ] } 70%, black); background-color: ${ colors [ 1 ] } ` ;
809817 }
810818
811- getScoreStyle ( feature , stable ) {
819+ getScoreStyle ( feature , isStable ) {
812820 const interopIndex = this . dataManager . getYearProp ( 'numBrowsers' ) ;
813- const score = this . getNumericalBrowserScoreByFeature ( interopIndex , feature , stable ) ;
821+ const score = this . getNumericalBrowserScoreByFeature ( interopIndex , feature , isStable ) ;
814822 const colors = this . calculateColor ( score ) ;
815823 return `color: color-mix(in lch, ${ colors [ 0 ] } 70%, black); background-color: ${ colors [ 1 ] } ` ;
816824 }
@@ -825,10 +833,10 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
825833 return feature === this . feature ;
826834 }
827835
828- featureLinks ( feature , stable ) {
836+ featureLinks ( feature , isStable ) {
829837 const data = this . getYearProp ( 'focusAreas' ) [ feature ] ;
830838 const rawURL = ( this . isMobileScoresView ) ? data ?. mobile_tests : data ?. tests ;
831- const testsURL = this . formatTestsURL ( rawURL , stable ) ;
839+ const testsURL = this . formatTestsURL ( rawURL , isStable ) ;
832840
833841 return [
834842 { text : 'Spec' , href : data ?. spec } ,
@@ -846,7 +854,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
846854 }
847855
848856 // Add the stable or experimental label to a tests URL depending on the view.
849- formatTestsURL ( testsURL , stable ) {
857+ formatTestsURL ( testsURL , isStable ) {
850858 // Don't try to add a label if the URL is undefined or empty.
851859 if ( ! testsURL ) {
852860 return '' ;
@@ -863,7 +871,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
863871 // Remove any existing stable or experimental label param.
864872 const newLabels = existingLabels . filter ( val => val !== 'stable' && val !== 'experimental' ) ;
865873 // Add the stable/experimental label depending on the dashboard view.
866- newLabels . push ( stable ? 'stable' : 'experimental' ) ;
874+ newLabels . push ( isStable ? 'stable' : 'experimental' ) ;
867875 // Delete the existing label params and re-add them.
868876 url . searchParams . delete ( 'label' ) ;
869877 for ( const labelValue of newLabels ) {
@@ -874,9 +882,9 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
874882 }
875883
876884 // Get the tests URL for a row and add the stable/experimental label.
877- getTestsURL ( name , stable ) {
885+ getTestsURL ( name , isStable ) {
878886 const urlKey = ( this . isMobileScoresView ) ? 'mobile_tests' : 'tests' ;
879- return this . formatTestsURL ( this . getRowInfo ( name , urlKey ) , stable ) ;
887+ return this . formatTestsURL ( this . getRowInfo ( name , urlKey ) , isStable ) ;
880888 }
881889
882890 getInvestigationScore ( rowName , isPreviousYear ) {
@@ -915,17 +923,16 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
915923 return `${ ( total / 10 ) . toFixed ( 1 ) } %` ;
916924 }
917925
918- getNumericalSubtotalScore ( browserIndex , section , stable ) {
919- const scores = stable ? this . scores . stable : this . scores . experimental ;
926+ getNumericalSubtotalScore ( browserIndex , section , isStable ) {
927+ const scores = isStable ? this . scores . stable : this . scores . experimental ;
920928 const totalScore = section . rows . reduce ( ( sum , rowName ) => {
921929 return sum + scores [ browserIndex ] [ rowName ] ;
922930 } , 0 ) ;
923- const avg = Math . floor ( totalScore / section . rows . length ) / 10 ;
924- return avg ;
931+ return Math . floor ( totalScore / section . rows . length ) / 10 ;
925932 }
926933
927- getSubtotalScore ( browserIndex , section , stable ) {
928- const score = this . getNumericalSubtotalScore ( browserIndex , section , stable ) ;
934+ getSubtotalScore ( browserIndex , section , isStable ) {
935+ const score = this . getNumericalSubtotalScore ( browserIndex , section , isStable ) ;
929936 // Don't display decimal places for a 100% score.
930937 if ( score >= 100 ) {
931938 return '100%' ;
@@ -954,8 +961,8 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
954961 return ! scoreAsGroup && ! this . showBrowserIcons ( index ) ;
955962 }
956963
957- getBrowserScoreForFeature ( browserIndex , feature , stable ) {
958- const scores = stable ? this . scores . stable : this . scores . experimental ;
964+ getBrowserScoreForFeature ( browserIndex , feature , isStable ) {
965+ const scores = isStable ? this . scores . stable : this . scores . experimental ;
959966 const score = scores [ browserIndex ] [ feature ] ;
960967 // Don't display decimal places for a 100% score.
961968 if ( score / 10 >= 100 ) {
@@ -964,15 +971,15 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
964971 return `${ ( score / 10 ) . toFixed ( 1 ) } %` ;
965972 }
966973
967- getInteropScoreForFeature ( feature , stable ) {
974+ getInteropScoreForFeature ( feature , isStable ) {
968975 const numBrowsers = this . getYearProp ( 'numBrowsers' ) ;
969- return this . getBrowserScoreForFeature ( numBrowsers , feature , stable ) ;
976+ return this . getBrowserScoreForFeature ( numBrowsers , feature , isStable ) ;
970977 }
971978
972979 // getNumericalBrowserScoreByFeature returns the same score as
973980 // getBrowserScoreForFeature but as a number instead of a string
974- getNumericalBrowserScoreByFeature ( browserIndex , feature , stable ) {
975- const scores = stable ? this . scores . stable : this . scores . experimental ;
981+ getNumericalBrowserScoreByFeature ( browserIndex , feature , isStable ) {
982+ const scores = isStable ? this . scores . stable : this . scores . experimental ;
976983 const score = scores [ browserIndex ] [ feature ] ;
977984 const roundedScore = Math . round ( score * 100 ) / 100 ;
978985 return roundedScore / 10 ;
@@ -1001,7 +1008,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
10011008 this . totalSafari = this . getBrowserScoreForFeature ( 2 , summaryFeatureName , this . stable ) ;
10021009 }
10031010
1004- updateUrlParams ( embedded , stable , feature , isMobileScoresView ) {
1011+ updateUrlParams ( embedded , isStable , feature , isMobileScoresView ) {
10051012 // Our observer may be called before the feature is set, so debounce that.
10061013 if ( feature === undefined ) {
10071014 return ;
@@ -1011,7 +1018,7 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
10111018 if ( feature && feature !== this . getYearProp ( 'summaryFeatureName' ) ) {
10121019 params . push ( `feature=${ feature } ` ) ;
10131020 }
1014- if ( stable ) {
1021+ if ( isStable ) {
10151022 params . push ( 'stable' ) ;
10161023 }
10171024 if ( embedded ) {
@@ -1075,12 +1082,12 @@ class InteropDashboard extends WPTFlags(PolymerElement) {
10751082 this . toggleMobileView ( true , false ) ;
10761083 }
10771084
1078- toggleMobileView ( showMobileScores , stable ) {
1085+ toggleMobileView ( showMobileScores , isStable ) {
10791086 let queryString = '' ;
10801087 if ( showMobileScores ) {
10811088 queryString += 'mobile-view' ;
10821089 }
1083- if ( stable ) {
1090+ if ( isStable ) {
10841091 queryString += ( queryString . length ) ? '&stable' : 'stable' ;
10851092 }
10861093 if ( queryString . length ) {
0 commit comments