-
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.
Browse files
Browse the repository at this point in the history
implement the playlist next screen
- Loading branch information
Showing
12 changed files
with
274 additions
and
35 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
125 changes: 125 additions & 0 deletions
125
src/components/playlist-next-screen/_playlist-next-screen.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,125 @@ | ||
.player.state-idle { | ||
|
||
.playlist-next-screen-overlay { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(black, 0.5); | ||
|
||
.playlist-next-screen-content { | ||
position: relative; | ||
top: calc(50% - 107.5px); | ||
|
||
.playlist-next-screen-text { | ||
position: absolute; | ||
width: 100%; | ||
top: -90px; | ||
font-size: 15px; | ||
color: #fff; | ||
padding: 4px 8px 12px 8px; | ||
|
||
.playlist-next-screen-text-title { | ||
padding: 4px; | ||
font-weight: 100; | ||
} | ||
|
||
.playlist-next-screen-text-name { | ||
padding: 16px; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
} | ||
|
||
.playlist-next-screen-poster-placeholder { | ||
position: relative; | ||
margin: auto; | ||
width: 384px; | ||
|
||
.playlist-next-screen-poster-aspect-ratio { | ||
width: 100%; | ||
padding-top: 56%; | ||
|
||
.playlist-next-screen-poster { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
bottom: 0; | ||
right: 0; | ||
border: 2px solid rgba(255, 255, 255, 0.2); | ||
border-radius: 4px; | ||
cursor: pointer; | ||
|
||
.playlist-next-screen-poster-img { | ||
height: 100%; | ||
border-radius: 3px; | ||
background-size: contain; | ||
background-repeat: round; | ||
} | ||
|
||
.icon { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: 64px; | ||
height: 64px; | ||
margin: -32px 0 0 -32px; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
&.size-lg { | ||
.playlist-next-screen-content { | ||
top: 31.25%; | ||
|
||
.playlist-next-screen-poster-placeholder { | ||
width: 37.5%; | ||
} | ||
} | ||
} | ||
|
||
&.size-md { | ||
.playlist-next-screen-content { | ||
top: 29%; | ||
|
||
.playlist-next-screen-text { | ||
top: -58px; | ||
|
||
.playlist-next-screen-text-name { | ||
padding: 0; | ||
} | ||
} | ||
|
||
.playlist-next-screen-poster-placeholder { | ||
width: 42%; | ||
} | ||
} | ||
} | ||
|
||
&.size-sm { | ||
.playlist-next-screen-content { | ||
top: calc(50% - 16px); | ||
|
||
.playlist-next-screen-poster-placeholder { | ||
width: 32px; | ||
|
||
.playlist-next-screen-poster-aspect-ratio .playlist-next-screen-poster { | ||
border: 0; | ||
|
||
.playlist-next-screen-poster-img { | ||
display: none; | ||
} | ||
|
||
.icon { | ||
width: 32px; | ||
height: 32px; | ||
margin: -16px 0 0 -16px; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 {PlaylistNextScreen} from './playlist-next-screen'; |
93 changes: 93 additions & 0 deletions
93
src/components/playlist-next-screen/playlist-next-screen.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,93 @@ | ||
//@flow | ||
import style from '../../styles/style.scss'; | ||
import {h} from 'preact'; | ||
import {Localizer, Text} from 'preact-i18n'; | ||
import BaseComponent from '../base'; | ||
import {connect} from 'preact-redux'; | ||
import {default as Icon, IconType} from '../icon'; | ||
|
||
/** | ||
* mapping state to props | ||
* @param {*} state - redux store state | ||
* @returns {Object} - mapped state to this component | ||
*/ | ||
const mapStateToProps = state => ({ | ||
playlist: state.engine.playlist, | ||
isPlaybackEnded: state.engine.isPlaybackEnded | ||
}); | ||
|
||
@connect(mapStateToProps) | ||
/** | ||
* PlaylistNextScreen component | ||
* | ||
* @class PlaylistNextScreen | ||
* @example <PlaylistNextScreen player={this.player} type="next"/> | ||
* @extends {BaseComponent} | ||
*/ | ||
class PlaylistNextScreen extends BaseComponent { | ||
/** | ||
* should render component | ||
* @param {*} props - component props | ||
* @returns {boolean} - component element | ||
* @static | ||
*/ | ||
static shouldRender(props: any): boolean { | ||
return props.state.engine.playlist && props.state.engine.playlist.next && props.state.engine.playlist.next.sources; | ||
} | ||
|
||
/** | ||
* Creates an instance of PlaylistNextScreen. | ||
* @param {Object} obj obj | ||
* @memberof PlaylistNextScreen | ||
*/ | ||
constructor(obj: Object) { | ||
super({name: 'PlaylistNextScreen', player: obj.player}); | ||
} | ||
|
||
/** | ||
* next poster click handler | ||
* | ||
* @returns {void} | ||
* @memberof PlaylistNextScreen | ||
*/ | ||
onPosterClick() { | ||
this.player.playlist.playNext(); | ||
} | ||
|
||
/** | ||
* render component | ||
* | ||
* @param {*} props - component props | ||
* @returns {React$Element} - component element | ||
* @memberof PlaylistNextScreen | ||
*/ | ||
render(props: any): React$Element<any> | void { | ||
const next = props.playlist.next; | ||
return props.isPlaybackEnded ? ( | ||
<div className={style.playlistNextScreenOverlay}> | ||
<div className={style.playlistNextScreenContent}> | ||
<div className={style.playlistNextScreenText}> | ||
<Localizer> | ||
<div className={style.playlistNextScreenTextTitle}> | ||
<Text id="playlist.next" /> | ||
</div> | ||
</Localizer> | ||
<div className={style.playlistNextScreenTextName}>{`${next.sources.metadata ? next.sources.metadata.name : ''}`}</div> | ||
</div> | ||
<div className={style.playlistNextScreenPosterPlaceholder}> | ||
<div className={style.playlistNextScreenPosterAspectRatio}> | ||
<div className={style.playlistNextScreenPoster} onClick={() => this.onPosterClick()}> | ||
<div className={style.playlistNextScreenPosterImg} style={`background-image: url(${next.sources.poster || ''});`} /> | ||
<Icon type={IconType.Play} /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) : ( | ||
undefined | ||
); | ||
} | ||
} | ||
|
||
export {PlaylistNextScreen}; |
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
Oops, something went wrong.