1
1
import style from '../../styles/style.scss' ;
2
2
import { h , Component , VNode } from 'preact' ;
3
- import { Text , withText } from 'preact-i18n' ;
3
+ import { withText } from 'preact-i18n' ;
4
4
import { Icon , IconType } from '../icon' ;
5
5
import { withEventDispatcher } from '../event-dispatcher' ;
6
6
import { Tooltip } from '../tooltip' ;
@@ -35,14 +35,17 @@ const mapStateToProps = ({config, settings}) => ({
35
35
@connect ( mapStateToProps , bindActions ( actions ) )
36
36
@withPlayer
37
37
@withEventDispatcher ( COMPONENT_NAME )
38
- @withText ( { AdvancedAudioDescText : 'settings.advancedAudioDescription' } )
38
+ @withText ( {
39
+ advancedAudioDescEnabledText : 'settings.advanced_audio_description_enabled' ,
40
+ advancedAudioDescDisabledText : 'settings.advanced_audio_description_disabled'
41
+ } )
39
42
class AdvancedAudioDesc extends Component < any , any > implements IconComponent {
40
43
constructor ( props : any ) {
41
44
super ( ) ;
42
45
registerToBottomBar ( COMPONENT_NAME , props . player , ( ) => this . registerComponent ( ) ) ;
43
46
}
44
47
45
- registerComponent ( ) : any {
48
+ public registerComponent ( ) : any {
46
49
return {
47
50
ariaLabel : ( ) => this . getComponentText ( ) ,
48
51
displayName : COMPONENT_NAME ,
@@ -56,11 +59,11 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
56
59
} ;
57
60
}
58
61
59
- getComponentText = ( ) : any => {
60
- return this . props . AdvancedAudioDescText ;
62
+ public getComponentText = ( ) : any => {
63
+ return this . props . advancedAudioDescEnabled ? this . props . advancedAudioDescEnabledText : this . props . advancedAudioDescDisabledText ;
61
64
} ;
62
65
63
- getSvgIcon = ( ) : any => {
66
+ public getSvgIcon = ( ) : any => {
64
67
return {
65
68
type : redux . useStore ( ) . getState ( ) . settings . advancedAudioDesc ? IconType . AdvancedAudioDescriptionActive : IconType . AdvancedAudioDescription
66
69
} ;
@@ -70,7 +73,7 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
70
73
* should render component
71
74
* @returns {boolean } - whether to render the component
72
75
*/
73
- _shouldRender ( ) : boolean {
76
+ private _shouldRender ( ) : boolean {
74
77
return this . props . showAdvancedAudioDescToggle ;
75
78
}
76
79
/**
@@ -79,7 +82,7 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
79
82
* @returns {void }
80
83
* @memberof AdvancedAudioDesc
81
84
*/
82
- onClick = ( ) : void => {
85
+ private onClick = ( ) : void => {
83
86
const checked = ! this . props . advancedAudioDescEnabled ;
84
87
this . props . updateAdvancedAudioDesc ( checked ) ;
85
88
this . props . notifyClick ( { type : 'AdvancedAudioDescription' , checked} ) ;
@@ -92,11 +95,11 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
92
95
* @returns {React$Element } - component element
93
96
* @memberof AdvancedAudioDesc
94
97
*/
95
- render ( { AdvancedAudioDescText , innerRef} : any ) : VNode < any > | undefined {
98
+ public render ( { innerRef} : any ) : VNode < any > | undefined {
96
99
return ! this . _shouldRender ( ) ? undefined : (
97
100
< ButtonControl name = { COMPONENT_NAME } className = { [ style . noIdleControl , this . props . classNames ? this . props . classNames . join ( ' ' ) : '' ] . join ( ' ' ) } >
98
- < Tooltip label = { AdvancedAudioDescText } >
99
- < Button tabIndex = "0" aria-label = { AdvancedAudioDescText } className = { `${ style . controlButton } ` } ref = { innerRef } onClick = { this . onClick } >
101
+ < Tooltip label = { this . getComponentText ( ) } >
102
+ < Button tabIndex = "0" aria-label = { this . getComponentText ( ) } className = { `${ style . controlButton } ` } ref = { innerRef } onClick = { this . onClick } >
100
103
< Icon type = { this . props . advancedAudioDescEnabled ? IconType . AdvancedAudioDescriptionActive : IconType . AdvancedAudioDescription } />
101
104
</ Button >
102
105
</ Tooltip >
0 commit comments