-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(controls): Base React controls for Dash (#1390)
- Loading branch information
Conrad Chan
authored
May 26, 2021
1 parent
09fadfa
commit 6954be0
Showing
9 changed files
with
273 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@import '../controls//media/styles'; | ||
|
||
.bp-DashControls { | ||
@include bp-VideoControls; | ||
} | ||
|
||
.bp-DashControls-bar { | ||
@include bp-VideoControls-bar; | ||
} | ||
|
||
.bp-DashControls-group { | ||
@include bp-VideoControls-group; | ||
} | ||
|
||
.bp-DashControls-settings { | ||
@include bp-VideoControls-settings; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import DurationLabels, { Props as DurationLabelsProps } from '../controls/media/DurationLabels'; | ||
import MediaFullscreenToggle, { Props as MediaFullscreenToggleProps } from '../controls/media/MediaFullscreenToggle'; | ||
import MediaSettings, { Props as MediaSettingsProps } from '../controls/media/MediaSettings'; | ||
import PlayPauseToggle, { Props as PlayControlsProps } from '../controls/media/PlayPauseToggle'; | ||
import TimeControls, { Props as TimeControlsProps } from '../controls/media/TimeControls'; | ||
import VolumeControls, { Props as VolumeControlsProps } from '../controls/media/VolumeControls'; | ||
import './DashControls.scss'; | ||
|
||
export type Props = DurationLabelsProps & | ||
MediaFullscreenToggleProps & | ||
MediaSettingsProps & | ||
PlayControlsProps & | ||
TimeControlsProps & | ||
VolumeControlsProps; | ||
|
||
export default function DashControls({ | ||
autoplay, | ||
bufferedRange, | ||
currentTime, | ||
durationTime, | ||
isPlaying, | ||
onAutoplayChange, | ||
onFullscreenToggle, | ||
onMuteChange, | ||
onPlayPause, | ||
onRateChange, | ||
onTimeChange, | ||
onVolumeChange, | ||
rate, | ||
volume, | ||
}: Props): JSX.Element { | ||
return ( | ||
<div className="bp-DashControls"> | ||
<TimeControls | ||
bufferedRange={bufferedRange} | ||
currentTime={currentTime} | ||
durationTime={durationTime} | ||
onTimeChange={onTimeChange} | ||
/> | ||
|
||
<div className="bp-DashControls-bar"> | ||
<div className="bp-DashControls-group"> | ||
<PlayPauseToggle isPlaying={isPlaying} onPlayPause={onPlayPause} /> | ||
<VolumeControls onMuteChange={onMuteChange} onVolumeChange={onVolumeChange} volume={volume} /> | ||
<DurationLabels currentTime={currentTime} durationTime={durationTime} /> | ||
</div> | ||
|
||
<div className="bp-DashControls-group"> | ||
{/* CC Toggle */} | ||
<MediaSettings | ||
autoplay={autoplay} | ||
className="bp-DashControls-settings" | ||
onAutoplayChange={onAutoplayChange} | ||
onRateChange={onRateChange} | ||
rate={rate} | ||
/> | ||
<MediaFullscreenToggle onFullscreenToggle={onFullscreenToggle} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,12 +34,4 @@ | |
opacity: 1; | ||
} | ||
} | ||
|
||
.bp-VideoControlsRoot { | ||
position: absolute; | ||
right: 0; | ||
bottom: -1px; | ||
left: 0; | ||
width: 100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,17 @@ | ||
@import '../controls/media/styles'; | ||
|
||
.bp-MP4Controls { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
background-image: linear-gradient(to top, rgba($black, .6) 0%, rgba($black, 0) 100%); | ||
|
||
.bp-FullscreenToggle { | ||
width: $bp-MediaControl-width; | ||
height: $bp-MediaControl-height; | ||
} | ||
@include bp-VideoControls; | ||
} | ||
|
||
.bp-MP4Controls-bar { | ||
display: flex; | ||
justify-content: space-between; | ||
padding: 0 10px 5px; | ||
@include bp-VideoControls-bar; | ||
} | ||
|
||
.bp-MP4Controls-group { | ||
display: flex; | ||
align-items: center; | ||
@include bp-VideoControls-group; | ||
} | ||
|
||
.bp-MP4Controls-settings { | ||
.bp-SettingsFlyout { | ||
right: 15px; | ||
} | ||
|
||
.bp-SettingsToggle { | ||
width: $bp-MediaControl-width; | ||
height: $bp-MediaControl-height; | ||
} | ||
@include bp-VideoControls-settings; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import DashControls from '../DashControls'; | ||
import MediaFullscreenToggle from '../../controls/media/MediaFullscreenToggle'; | ||
import MediaSettings from '../../controls/media/MediaSettings'; | ||
import PlayPauseToggle from '../../controls/media/PlayPauseToggle'; | ||
import TimeControls from '../../controls/media/TimeControls'; | ||
import VolumeControls from '../../controls/media/VolumeControls'; | ||
|
||
describe('DashControls', () => { | ||
describe('render', () => { | ||
test('should return a valid wrapper', () => { | ||
const onAutoplayChange = jest.fn(); | ||
const onFullscreenToggle = jest.fn(); | ||
const onMuteChange = jest.fn(); | ||
const onRateChange = jest.fn(); | ||
const onPlayPause = jest.fn(); | ||
const onTimeChange = jest.fn(); | ||
const onVolumeChange = jest.fn(); | ||
const wrapper = shallow( | ||
<DashControls | ||
autoplay={false} | ||
onAutoplayChange={onAutoplayChange} | ||
onFullscreenToggle={onFullscreenToggle} | ||
onMuteChange={onMuteChange} | ||
onPlayPause={onPlayPause} | ||
onRateChange={onRateChange} | ||
onTimeChange={onTimeChange} | ||
onVolumeChange={onVolumeChange} | ||
rate="1.0" | ||
/>, | ||
); | ||
|
||
expect(wrapper.hasClass('bp-DashControls')).toBe(true); | ||
expect(wrapper.find(MediaFullscreenToggle).prop('onFullscreenToggle')).toEqual(onFullscreenToggle); | ||
expect(wrapper.find(MediaSettings).prop('onAutoplayChange')).toEqual(onAutoplayChange); | ||
expect(wrapper.find(MediaSettings).prop('onRateChange')).toEqual(onRateChange); | ||
expect(wrapper.find(PlayPauseToggle).prop('onPlayPause')).toEqual(onPlayPause); | ||
expect(wrapper.find(TimeControls).prop('onTimeChange')).toEqual(onTimeChange); | ||
expect(wrapper.find(VolumeControls).prop('onMuteChange')).toEqual(onMuteChange); | ||
expect(wrapper.find(VolumeControls).prop('onVolumeChange')).toEqual(onVolumeChange); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,11 @@ | |
display: none; | ||
} | ||
} | ||
|
||
.bp-VideoControlsRoot { | ||
position: absolute; | ||
right: 0; | ||
bottom: -1px; | ||
left: 0; | ||
width: 100%; | ||
} |