-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add page fullscreen,rate switch,custom definition and some ui r…
…efactor
- Loading branch information
Showing
23 changed files
with
451 additions
and
71 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
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
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
44 changes: 44 additions & 0 deletions
44
packages/griffith/src/components/Controller/items/PageFullScreenButtonItem.js
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 {css} from 'aphrodite/no-important' | ||
import {ua} from 'griffith-utils' | ||
import styles from '../styles' | ||
import Icon from '../../Icon' | ||
import * as icons from '../../Icon/icons/controller' | ||
import Tooltip from '../../Tooltip' | ||
import Hover from '../../Hover' | ||
|
||
const {isMobile} = ua | ||
|
||
const PageFullScreenButtonItem = ({isFullScreen, onClick}) => ( | ||
<Hover className={css(styles.menuContainer)}> | ||
{isFullScreenHovered => ( | ||
<React.Fragment> | ||
<button className={css(styles.button)} onClick={onClick}> | ||
<Icon | ||
icon={isFullScreen ? icons.exitPageScreen : icons.enterPageScreen} | ||
/> | ||
</button> | ||
<div | ||
className={css( | ||
styles.fullScreenTooltip, | ||
styles.menu, | ||
isFullScreenHovered && styles.menuShown, | ||
isFullScreen && styles.fullScreenTooltipWide | ||
)} | ||
> | ||
{!isMobile && ( | ||
<Tooltip | ||
content={ | ||
isFullScreen | ||
? 'action-exit-page-fullscreen' | ||
: 'action-enter-page-fullscreen' | ||
} | ||
/> | ||
)} | ||
</div> | ||
</React.Fragment> | ||
)} | ||
</Hover> | ||
) | ||
|
||
export default PageFullScreenButtonItem |
79 changes: 79 additions & 0 deletions
79
packages/griffith/src/components/Controller/items/PlaybackRateMenuItem.js
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,79 @@ | ||
import React from 'react' | ||
import {css} from 'aphrodite/no-important' | ||
|
||
import {VideoSourceContext} from '../../../contexts/VideoSource' | ||
import reverseArray from '../../../utils/reverseArray' | ||
|
||
import styles from '../styles' | ||
import TranslatedText from '../../TranslatedText' | ||
|
||
class PlaybackRateMenuItem extends React.PureComponent { | ||
state = { | ||
isPlaybackRateHovered: false, | ||
} | ||
|
||
handlePlaybackRatePointerEnter = () => { | ||
this.setState({isPlaybackRateHovered: true}) | ||
} | ||
|
||
handlePlaybackRatePointerLeave = () => { | ||
this.setState({isPlaybackRateHovered: false}) | ||
} | ||
handleClickItem = (q, handler) => { | ||
this.handlePlaybackRatePointerLeave() | ||
handler(q) | ||
} | ||
|
||
render() { | ||
const {isPlaybackRateHovered} = this.state | ||
return ( | ||
<VideoSourceContext.Consumer> | ||
{({playbackRates, setCurrentPlaybackRate, currentPlaybackRate}) => | ||
playbackRates.length > 1 && ( | ||
<div | ||
className={css(styles.menuContainer)} | ||
onMouseEnter={this.handlePlaybackRatePointerEnter} | ||
onMouseLeave={this.handlePlaybackRatePointerLeave} | ||
> | ||
<button className={css(styles.button, styles.qualityButton)}> | ||
<span className={css(styles.qualityButtonText)}> | ||
{currentPlaybackRate.value === 1.0 ? ( | ||
<TranslatedText name={'playback-rate'} /> | ||
) : ( | ||
`${currentPlaybackRate.text}` | ||
)} | ||
</span> | ||
</button> | ||
<div | ||
className={css( | ||
styles.menu, | ||
isPlaybackRateHovered && styles.menuShown | ||
)} | ||
> | ||
<div className={css(styles.qualityMenu)}> | ||
{reverseArray(playbackRates).map(q => ( | ||
<button | ||
key={q.value} | ||
className={css( | ||
styles.qualityMenuItem, | ||
currentPlaybackRate.value === q.value && | ||
styles.qualityMenuActiveItem | ||
)} | ||
onClick={() => { | ||
this.handleClickItem(q, setCurrentPlaybackRate) | ||
}} | ||
> | ||
{q.text} | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
</VideoSourceContext.Consumer> | ||
) | ||
} | ||
} | ||
|
||
export default PlaybackRateMenuItem |
Oops, something went wrong.