1+ import classic from "ember-classic-decorator" ;
2+ import { tagName } from "@ember-decorators/component" ;
3+ import { equal } from "@ember/object/computed" ;
14import Component from "@ember/component" ;
25import I18n from "I18n" ;
36import { action } from "@ember/object" ;
47import discourseComputed from "discourse-common/utils/decorators" ;
5- import { equal } from "@ember/object/computed" ;
68import { getColors } from "discourse/plugins/poll/lib/chart-colors" ;
79import { htmlSafe } from "@ember/template" ;
810import { propertyEqual } from "discourse/lib/computed" ;
911
10- export default Component . extend ( {
12+ @classic
13+ @tagName ( "" )
14+ export default class PollBreakdownOption extends Component {
1115 // Arguments:
12- option : null ,
13- index : null ,
14- totalVotes : null ,
15- optionsCount : null ,
16- displayMode : null ,
17- highlightedOption : null ,
18- onMouseOver : null ,
19- onMouseOut : null ,
16+ option = null ;
17+
18+ index = null ;
19+ totalVotes = null ;
20+ optionsCount = null ;
21+ displayMode = null ;
22+ highlightedOption = null ;
23+ onMouseOver = null ;
24+ onMouseOut = null ;
2025
21- tagName : "" ,
26+ @propertyEqual ( "highlightedOption" , "index" )
27+ highlighted ;
2228
23- highlighted : propertyEqual ( "highlightedOption ", "index" ) ,
24- showPercentage : equal ( "displayMode" , "percentage" ) ,
29+ @ equal ( "displayMode ", "percentage" )
30+ showPercentage ;
2531
2632 @discourseComputed ( "option.votes" , "totalVotes" )
2733 percent ( votes , total ) {
2834 return I18n . toNumber ( ( votes / total ) * 100.0 , { precision : 1 } ) ;
29- } ,
35+ }
3036
3137 @discourseComputed ( "optionsCount" )
3238 optionColors ( optionsCount ) {
3339 return getColors ( optionsCount ) ;
34- } ,
40+ }
3541
3642 @discourseComputed ( "highlighted" )
3743 colorBackgroundStyle ( highlighted ) {
3844 if ( highlighted ) {
3945 // TODO: Use CSS variables (#10341)
4046 return htmlSafe ( "background: rgba(0, 0, 0, 0.1);" ) ;
4147 }
42- } ,
48+ }
4349
4450 @discourseComputed ( "highlighted" , "optionColors" , "index" )
4551 colorPreviewStyle ( highlighted , optionColors , index ) {
@@ -48,7 +54,7 @@ export default Component.extend({
4854 : optionColors [ index ] ;
4955
5056 return htmlSafe ( `background: ${ color } ;` ) ;
51- } ,
57+ }
5258
5359 @action
5460 onHover ( active ) {
@@ -57,5 +63,5 @@ export default Component.extend({
5763 } else {
5864 this . onMouseOut ( ) ;
5965 }
60- } ,
61- } ) ;
66+ }
67+ }
0 commit comments