1414
1515import { css , html , LitElement } from 'lit' ;
1616import { customElement , property } from 'lit/decorators.js' ;
17+ import { styleMap } from 'lit/directives/style-map.js' ;
1718
1819import { BatchSelection } from './batch_selection' ;
19- import { areFieldsComparable , Batch , Field } from './entry' ;
20+ import { areFieldsComparable , Batch , Field , FieldId } from './entry' ;
2021import { dispatch , EventType } from './events' ;
2122import { FieldMatcher , Match } from './matcher' ;
2223import { FieldMetric , getRatio } from './metric' ;
@@ -47,20 +48,37 @@ export class MatchesTableUi extends LitElement {
4748 selection : Batch , selectionFieldIndex : number , selectionRowIndex : number ,
4849 reference : Batch , referenceFieldIndex : number ,
4950 referenceRowIndex : number ) {
51+ const selectionField = selection . fields [ selectionFieldIndex ] ;
5052 const selectionValue =
5153 selection . rows [ selectionRowIndex ] [ selectionFieldIndex ] ;
5254 const referenceValue =
5355 reference . rows [ referenceRowIndex ] [ referenceFieldIndex ] ;
54- if ( selection . fields [ selectionFieldIndex ] . isNumber &&
55- reference . fields [ referenceFieldIndex ] . isNumber ) {
56+ if ( selectionField . id === FieldId . EFFORT ||
57+ selectionField . id === FieldId . QUALITY ) {
58+ const referenceStyle = { 'color' : reference . color } ;
59+ const selectionStyle = { 'color' : selection . color } ;
60+ return html `
61+ <td class= "encodingSettingCell" >
62+ <span style= ${ styleMap ( referenceStyle ) } > ${ referenceValue } </ span>
63+ <span style= ${ styleMap ( selectionStyle ) } > ${ selectionValue } </ span>
64+ </ td> ` ;
65+ }
66+
67+ const referenceField = reference . fields [ referenceFieldIndex ] ;
68+ const isNumber = selectionField . isNumber && referenceField . isNumber ;
69+ const cssClass = isNumber ? 'numberCell' : '' ;
70+
71+ if ( isNumber && selectionField . id !== FieldId . WIDTH &&
72+ selectionField . id !== FieldId . HEIGHT ) {
5673 const ratio =
5774 getRatio ( selectionValue as number , referenceValue as number ) ;
58- return html `<td> ${ getRelativePercent ( ratio ) } </ td> ` ;
75+ return html `<td class = " ${ cssClass } " > ${ getRelativePercent ( ratio ) } </ td> ` ;
5976 }
6077 if ( selectionValue === referenceValue ) {
61- return html `<td> ${ selectionValue } </ td> ` ;
78+ return html `<td class = " ${ cssClass } " > ${ selectionValue } </ td> ` ;
6279 }
63- return html `<td> ${ selectionValue } ≠ ${ referenceValue } </ td> ` ;
80+ return html `
81+ <td class= "${ cssClass } " > ${ selectionValue } ≠ ${ referenceValue } </ td> ` ;
6482 }
6583
6684 // Header rows (two needed because some cells use a rowspan)
@@ -201,7 +219,7 @@ export class MatchesTableUi extends LitElement {
201219 ${ metricIndices . map ( ( metricIndex ) => {
202220 const mean =
203221 this . batchSelection . stats [ metricIndex ] . getMean ( /*geometric=*/ false ) ;
204- return html `<td> ${ getRelativePercent ( mean ) } </ td> ` ;
222+ return html `<td class = "numberCell" > ${ getRelativePercent ( mean ) } </ td> ` ;
205223 } ) }
206224 <td colspan= ${ selectionSharedFieldIndices . length } class= "missing" >
207225 </ td>
@@ -215,7 +233,7 @@ export class MatchesTableUi extends LitElement {
215233 ${ metricIndices . map ( ( metricIndex ) => {
216234 const mean =
217235 this . batchSelection . stats [ metricIndex ] . getMean ( /*geometric=*/ true ) ;
218- return html `<td> ${ getRelativePercent ( mean ) } </ td> ` ;
236+ return html `<td class = "numberCell" > ${ getRelativePercent ( mean ) } </ td> ` ;
219237 } ) }
220238 <td colspan= ${ selectionSharedFieldIndices . length } class= "missing" >
221239 </ td>
@@ -258,6 +276,12 @@ export class MatchesTableUi extends LitElement {
258276 font-family : monospace;
259277 font-size : 10px ;
260278 }
279+ .numberCell {
280+ text-align : right;
281+ }
282+ .encodingSettingCell {
283+ text-align : center;
284+ }
261285
262286 tr {
263287 background : var (--mdc-theme-background );
0 commit comments