1
+ import classic from "ember-classic-decorator" ;
2
+ import { tagName } from "@ember-decorators/component" ;
3
+ import { equal } from "@ember/object/computed" ;
1
4
import Component from "@ember/component" ;
2
5
import I18n from "I18n" ;
3
6
import { action } from "@ember/object" ;
4
7
import discourseComputed from "discourse-common/utils/decorators" ;
5
- import { equal } from "@ember/object/computed" ;
6
8
import { getColors } from "discourse/plugins/poll/lib/chart-colors" ;
7
9
import { htmlSafe } from "@ember/template" ;
8
10
import { propertyEqual } from "discourse/lib/computed" ;
9
11
10
- export default Component . extend ( {
12
+ @classic
13
+ @tagName ( "" )
14
+ export default class PollBreakdownOption extends Component {
11
15
// 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 ;
20
25
21
- tagName : "" ,
26
+ @propertyEqual ( "highlightedOption" , "index" )
27
+ highlighted ;
22
28
23
- highlighted : propertyEqual ( "highlightedOption ", "index" ) ,
24
- showPercentage : equal ( "displayMode" , "percentage" ) ,
29
+ @ equal ( "displayMode ", "percentage" )
30
+ showPercentage ;
25
31
26
32
@discourseComputed ( "option.votes" , "totalVotes" )
27
33
percent ( votes , total ) {
28
34
return I18n . toNumber ( ( votes / total ) * 100.0 , { precision : 1 } ) ;
29
- } ,
35
+ }
30
36
31
37
@discourseComputed ( "optionsCount" )
32
38
optionColors ( optionsCount ) {
33
39
return getColors ( optionsCount ) ;
34
- } ,
40
+ }
35
41
36
42
@discourseComputed ( "highlighted" )
37
43
colorBackgroundStyle ( highlighted ) {
38
44
if ( highlighted ) {
39
45
// TODO: Use CSS variables (#10341)
40
46
return htmlSafe ( "background: rgba(0, 0, 0, 0.1);" ) ;
41
47
}
42
- } ,
48
+ }
43
49
44
50
@discourseComputed ( "highlighted" , "optionColors" , "index" )
45
51
colorPreviewStyle ( highlighted , optionColors , index ) {
@@ -48,7 +54,7 @@ export default Component.extend({
48
54
: optionColors [ index ] ;
49
55
50
56
return htmlSafe ( `background: ${ color } ;` ) ;
51
- } ,
57
+ }
52
58
53
59
@action
54
60
onHover ( active ) {
@@ -57,5 +63,5 @@ export default Component.extend({
57
63
} else {
58
64
this . onMouseOut ( ) ;
59
65
}
60
- } ,
61
- } ) ;
66
+ }
67
+ }
0 commit comments