File tree Expand file tree Collapse file tree 4 files changed +28
-16
lines changed
Expand file tree Collapse file tree 4 files changed +28
-16
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,15 @@ export default function DropDownMenu(props) {
4848 > {
4949 props . tooltip ? (
5050 < Tooltip >
51- < TooltipTrigger > { props . label ? props . label : '' } { props . icon && < i > { props . icon } </ i > } </ TooltipTrigger >
51+ < TooltipTrigger > { props . icon && < i > { props . icon } </ i > } { props . label ? props . label : '' } </ TooltipTrigger >
5252 < TooltipContent root = { props . root } > { props . tooltip } </ TooltipContent >
5353 < ul role = "listbox" >
5454 { props . children }
5555 </ ul >
5656 </ Tooltip >
5757 ) : (
5858 < >
59- < div > { props . label ? props . label : '' } { props . icon && < i > { props . icon } </ i > } </ div >
59+ < div > { props . icon && < i > { props . icon } </ i > } { props . label ? props . label : '' } </ div >
6060 < ul role = "listbox" >
6161 { props . children }
6262 </ ul >
Original file line number Diff line number Diff line change @@ -6,6 +6,17 @@ import SpeakerSilentIcon from '../icons/speaker-silent.svg';
66import SpeakerMutedicon from '../icons/speaker-muted.svg' ;
77
88
9+ export function renderSpeakerIcon ( volume ) {
10+ if ( volume === 0.0 ) {
11+ return < SpeakerMutedicon /> ;
12+ }
13+ if ( volume < 0.33 ) {
14+ return < SpeakerSilentIcon /> ;
15+ }
16+ return < SpeakerLoudIcon /> ;
17+ }
18+
19+
920export default function VolumeControl ( props : any ) {
1021 const [ audioSettings , setAudioSettings ] = useAudioSettings ( ) ;
1122
@@ -15,19 +26,9 @@ export default function VolumeControl(props: any) {
1526 props . webAudio . gainNode . gain . setValueAtTime ( volume , props . webAudio . context . currentTime ) ;
1627 }
1728
18- function renderSpeakerIcon ( ) {
19- if ( audioSettings . volume === 0.0 ) {
20- return < SpeakerMutedicon /> ;
21- }
22- if ( audioSettings . volume < 0.33 ) {
23- return < SpeakerSilentIcon /> ;
24- }
25- return < SpeakerLoudIcon /> ;
26- }
27-
2829 return (
2930 < DropDownMenu
30- icon = { renderSpeakerIcon ( ) }
31+ icon = { renderSpeakerIcon ( audioSettings . volume ) }
3132 role = "menuitem"
3233 className = "volume-control"
3334 tooltip = { gettext ( "Change volume level" ) }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import RegionsPlugin from 'wavesurfer.js/dist/plugins/regions.js';
44import FileDetails from '../../admin/FileDetails' ;
55import { useAudioSettings } from '../../common/Storage' ;
66import DropDownMenu from '../../common/DropDownMenu' ;
7+ import { renderSpeakerIcon } from '../../common/VolumeControl' ;
78import PauseIcon from '../../icons/pause.svg' ;
89import PlayIcon from '../../icons/play.svg' ;
910
@@ -56,7 +57,13 @@ export default function Audio(props) {
5657 < button type = "button" onClick = { onPlayPause } > < PauseIcon /> { gettext ( "Pause" ) } </ button > :
5758 < button type = "button" onClick = { onPlayPause } > < PlayIcon /> { gettext ( "Play" ) } </ button >
5859 } </ Fragment > ,
59- < DropDownMenu key = "volume-control" className = "volume-control with-caret" label = { gettext ( "Set Volume" ) } >
60+ < DropDownMenu
61+ key = "volume-control"
62+ className = "volume-control with-caret"
63+ label = { gettext ( "Set Volume" ) }
64+ icon = { renderSpeakerIcon ( audioSettings . volume ) }
65+ wrapperElement = "div"
66+ >
6067 < li >
6168 < label htmlFor = "volume_level" > { gettext ( "Volume level" ) } :</ label >
6269 < input name = "volume_level" type = "range" min = "0.0" max = "1.0" step = "0.001" value = { audioSettings . volume } onChange = { setVolume } />
Original file line number Diff line number Diff line change @@ -724,8 +724,8 @@ ul.messagelist {
724724 margin-bottom : 10px ;
725725 display : flex ;
726726 flex-wrap : wrap ;
727- button , a {
728- display : block ;
727+ button , a , [ role = " combobox " ] {
728+ display : flex ;
729729 appearance : none ;
730730 border : none ;
731731 font-weight : 400 ;
@@ -745,6 +745,10 @@ ul.messagelist {
745745 cursor : not-allowed ;
746746 }
747747
748+ i {
749+ vertical-align : middle ;
750+ }
751+
748752 svg {
749753 margin-right : 0.5rem ;
750754 vertical-align : text-bottom ;
You can’t perform that action at this time.
0 commit comments