-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FEC-8632): add graphic indication to chrome picture in picture m…
…ode (#326) * add an overlay when playing inn PIP mode * change docs * fix es lint
- Loading branch information
1 parent
2ae9925
commit 9be71ac
Showing
9 changed files
with
185 additions
and
2 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
63 changes: 63 additions & 0 deletions
63
src/components/picture-in-picture-overlay/_picture-in-picture-overlay.scss
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 '~styles/variables'; | ||
|
||
.picture-in-picture-overlay{ | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
font-family: $font-family; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
.picture-in-picture-poster { | ||
all: inherit; | ||
background-size: contain; | ||
background: black no-repeat center center; | ||
|
||
&.has-poster { | ||
background-color: #000; | ||
} | ||
|
||
.dark-layer { | ||
background-color: rgba(0, 0, 0, 0.4); | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
|
||
.picture-in-picture-control { | ||
position: absolute; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.picture-in-picture-text { | ||
color: $white; | ||
font-size: $headline-font-size; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
} | ||
|
||
.picture-in-picture-button { | ||
height: 36px; | ||
width: 120px; | ||
border: 2px solid $grayscale2; | ||
border-radius: 18px; | ||
background-color: $grayscale1; | ||
color: $white; | ||
font-size: 15px; | ||
font-weight: bold; | ||
line-height: 30px; | ||
cursor: pointer; | ||
margin-top: 20px; | ||
align-self: center; | ||
&:hover{ | ||
background-color: $grayscale2; | ||
} | ||
} | ||
} |
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 @@ | ||
export {PictureInPictureOverlay} from './picture-in-picture-overlay'; |
92 changes: 92 additions & 0 deletions
92
src/components/picture-in-picture-overlay/picture-in-picture-overlay.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,92 @@ | ||
//@flow | ||
import style from '../../styles/style.scss'; | ||
import {h} from 'preact'; | ||
import BaseComponent from '../base'; | ||
import {connect} from 'preact-redux'; | ||
import {Localizer, Text} from 'preact-i18n'; | ||
|
||
/** | ||
* mapping state to props | ||
* @param {*} state - redux store state | ||
* @returns {Object} - mapped state to this component | ||
*/ | ||
const mapStateToProps = state => ({ | ||
poster: state.engine.poster, | ||
isInPictureInPicture: state.engine.isInPictureInPicture, | ||
isChangingSource: state.engine.isChangingSource | ||
}); | ||
|
||
@connect(mapStateToProps) | ||
/** | ||
* PictureInPictureOverlay component | ||
* | ||
* @class PictureInPictureOverlay | ||
* @example <PictureInPictureOverlay player={this.player} /> | ||
* @extends {BaseComponent} | ||
*/ | ||
class PictureInPictureOverlay extends BaseComponent { | ||
/** | ||
* Creates an instance of PictureInPictureOverlay. | ||
* @param {Object} obj obj | ||
* @memberof PictureInPictureOverlay | ||
*/ | ||
constructor(obj: Object) { | ||
super({name: 'PictureInPictureOverlay', player: obj.player}); | ||
} | ||
|
||
/** | ||
* The button is clicked, play the video in the player instead of in picture in picture | ||
* @returns {void} | ||
* @memberof PictureInPictureOverlay | ||
*/ | ||
_handleClick(): void { | ||
this.player.exitPictureInPicture(); | ||
} | ||
|
||
/** | ||
* render component | ||
* | ||
* @returns {?React$Element} - component element | ||
* @memberof PictureInPictureOverlay | ||
*/ | ||
render(): ?React$Element<any> { | ||
if (!this.props.isInPictureInPicture) { | ||
return; | ||
} | ||
|
||
let posterStyle = {}; | ||
const posterClasses = [style.pictureInPicturePoster]; | ||
if (this.props.poster) { | ||
const backgroundImage = this.props.isChangingSource ? '' : `url(${this.props.poster})`; | ||
posterStyle = { | ||
backgroundImage, | ||
backgroundSize: 'contain' | ||
}; | ||
posterClasses.push(style.hasPoster); | ||
} | ||
|
||
return ( | ||
<div> | ||
<div className={style.pictureInPictureOverlay}> | ||
<div className={posterClasses.join(' ')} style={posterStyle} onMouseOver={e => e.stopPropagation()}> | ||
<div className={style.darkLayer} /> | ||
</div> | ||
<div className={style.pictureInPictureControl}> | ||
<Localizer> | ||
<span className={style.pictureInPictureText}> | ||
<Text id="pictureInPicture.overlay_text" /> | ||
</span> | ||
</Localizer> | ||
<Localizer> | ||
<button className={[style.pictureInPictureButton, style.controlButtonContainer].join(' ')} onClick={() => this._handleClick()}> | ||
<Text id="pictureInPicture.overlay_button" /> | ||
</button> | ||
</Localizer> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export {PictureInPictureOverlay}; |
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